Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
x = d3.scaleBand()
.domain(data.map(d => d.x))
.range([margin.left, width - margin.right])
.padding(0.1);
Insert cell
xAxis = g => g
.attr("transform", `translate(0,${height - margin.bottom})`)
.call(d3.axisBottom(x).tickSizeOuter(0).tickFormat(d => d3.timeFormat("%a")(d).substring(0, 1)));
Insert cell
y = d3.scaleLinear()
.domain([0, d3.max(data, d => d.y)]).nice()
.range([height - margin.bottom, margin.top]);
Insert cell
yAxis = g => g
.attr("transform", `translate(${margin.left},0)`)
.call(d3.axisLeft(y))
.call(g => g.select(".domain").remove())
.call(g => g.select(".tick:last-of-type text").clone()
.attr("x", 3)
.attr("text-anchor", "start")
.style("font-weight", 800)
.text(data.yAxisLabel));
Insert cell
lineGenerator = d3.line()
.x(d => x(d.x))
.y(d => y(d.y))
.curve(d3.curveLinear);
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
accessibleDataTable = render_data_table(data, {caption: data.tableCaption, columns: data.slice[0], focusable: false})
Insert cell
Insert cell
Insert cell
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