Published
Edited
Jun 21, 2020
3 stars
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.2);
Insert cell
y = d3.scaleLinear()
.domain([0, d3.max(data, d => d.y)]).nice()
.range([height - margin.bottom, margin.top]);
Insert cell
xAxis = g => g
.attr("transform", `translate(0,${height - margin.bottom})`)
.attr("aria-hidden", "true")
.call(d3.axisBottom(x)
.tickSizeOuter(0)
.tickFormat(d => d3.timeFormat("%a")(d).substring(0, 1))
)
.call(g => g.select(".domain").style("stroke", "#202630"))
.call(g => g.selectAll(".tick line").remove())
.call(g => g.selectAll(".tick text")
.style("font-size", "clamp(.7rem, 2.5vw, 1.0rem)")
.style("fill", "#767676"))
;
Insert cell
chartTitle = g => g
.append("text")
.attr("id", "chart-title")
.attr("x", 0)
.attr("y", 0)
.attr("dy", "1em")
.style("font-weight", "400")
.style("font-size", "clamp(.8rem, 2.5vw, 1.2rem)") // minimum, preferred, maximum
.text(data.barChartTitle);
Insert cell
chartBy = g => g
.attr("transform", `translate(${width}, ${height})`)
.append("text")
.attr("id", "chartBy")
.attr("x", 0)
.attr("y", 0)
.attr("dy", "-0.5em")
.attr("text-anchor", "end")
.text('@DiDoesDigital');
Insert cell
Insert cell
margin = ({top: 48, right: 0, bottom: 60, left: 0})
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
data[0]
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