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

One platform to build and deploy the best data apps

Experiment and prototype by building visualizations in live JavaScript notebooks. Collaborate with your team and decide which concepts to build out.
Use Observable Framework to build data apps locally. Use data loaders to build in any language or library, including Python, SQL, and R.
Seamlessly deploy to Observable. Test before you ship, use automatic deploy-on-commit, and ensure your projects are always up-to-date.
Learn more