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
x = d3.scaleBand()
.domain(data.map(d => d.x))
.range([0, width - margin.right])
.padding(0.1);
Insert cell
xAxis = g => g
.attr("transform", `translate(0,${height - margin.bottom})`)
.call(d3.axisBottom(x).tickSizeOuter(0));
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.curveMonotoneX);
Insert cell
height = 450;
Insert cell
Insert cell
Insert cell
typographyStyles = html`<style>
@import url('https://fonts.googleapis.com/css2?family=Noto+Sans:wght@400;700&display=swap');

text, table {
fill: #282541;
font: 400 16px/1.4 "Noto Sans", sans-serif;
}

.heading,
.paragraph {
fill: #282541;
font: 400 16px/1.4 "Noto Sans", sans-serif;
}
.heading {
font: 700 24px/1.4 "Noto Sans", sans-serif;
}
`
Insert cell
barChartStyles = html`<style>
.domain {
stroke: #cdcccf;
}
.tick line {
stroke: #cdcccf;
}
</style>
`
Insert cell
dataTableStyles = html`<style>
caption {
white-space: initial;
text-align: left;
padding: 8px 0;
max-width: 35em;
}

table {
border-collapse: collapse;
}

th {
background: #F6F6F6;
}

th, td {
border: 1px solid #ECECEF;
text-align: left;
padding: 8px;
}

td:first-of-type {
font-weight: 800;
}

.table-container {
overflow-x: auto;
white-space: nowrap;
width: ${width}px;
min-width: ${width}px;
}
</style>
`
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