Published
Edited
Sep 8, 2020
2 forks
8 stars
Insert cell
md`# Stackable Multi-chart(line, area, bar)`
Insert cell
Insert cell
viewof numOfSeries = html`<input type="range" min= "1" max="200" step="1" value="9">`
Insert cell
viewof xAxisCount = html`<input type="range" min="1" max="200" step="1" value="30">`
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
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);
}
});
}
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
margin = ({top: 20, right: 30, bottom: 80, left: 40})
Insert cell
height = 350
Insert cell
d3 = require("d3@6")
Insert cell

Purpose-built for displays of data

Observable is your go-to platform for exploring data and creating expressive data visualizations. Use reactive JavaScript notebooks for prototyping and a collaborative canvas for visual data exploration and dashboard creation.
Learn more