chart = {
const svg = d3.create("svg")
.attr("viewBox", [0, 0, width, height]);
const zx = x.copy();
const gx = svg.append("g").call(xAxis);
gx.selectAll("text").classed('axis-text', true)
const gy = svg.append("g").call(yAxis);
const chartArea = svg.append('g').attr('id', 'charts')
.call(addLine)
.call(addArea)
.call(addBar)
.call(initChartSelector)
.call(addLegend)
svg
.call(addBrush)
.call(hover);
return Object.assign(svg.node(), {
update(domain, stacked) {
const t = svg.transition().duration(transitionDuration);
x.domain(data.category);
gx.transition(t).call(xAxis, x);
gx.selectAll("text").classed('axis-text', true);
y.domain(domain);
gy.transition(t).call(yAxis, y);
chartArea
.call(addLine, true, stacked)
.call(addArea, true, stacked)
.call(addBar, true, stacked)
.call(initChartSelector)
svg.call(hover, stacked);
}
});
}