Renames the class

This commit is contained in:
Roman Galochkin 2020-02-19 08:20:54 +03:00
parent 702044d4d5
commit 7301fea889

View File

@ -1,29 +1,7 @@
const d3 = require('d3');
const moment = require('moment');
d3.selection.prototype.patternify = function patternify(params) {
const selector = params.selector;
const elementTag = params.tag;
const data = params.data || [selector];
// Pattern in action.
const selection = this.selectAll('.' + selector).data(data, (d, i) => {
if (typeof d === 'object' && d.id) {
return d.id;
}
return i;
});
selection.exit().remove();
return selection
.enter()
.append(elementTag)
.merge(selection)
.attr('class', selector);
};
class Chartigo {
class Chart {
constructor() {
this.attrs = {
@ -351,8 +329,28 @@ class Chartigo {
}
}
d3.selection.prototype.patternify = function patternify(params) {
const selector = params.selector;
const elementTag = params.tag;
const data = params.data || [selector];
const selection = this.selectAll('.' + selector).data(data, (d, i) => {
if (typeof d === 'object' && d.id) return d.id;
return i;
});
selection.exit().remove();
return selection
.enter()
.append(elementTag)
.merge(selection)
.attr('class', selector);
};
function chart() {
return new Chartigo();
return new Chart();
}
export default chart;