Published
Edited
Apr 16, 2021
Insert cell
Insert cell
LinePlotFunction = {
const container = html`<div>`;
const svg = d3
.select(container)
.append("svg")
.attr("viewBox", `0 0 ${width} ${height}`);
svg.append("path")
.attr("fill", "None")
.attr("stroke", "steelblue")
.attr("d", line(data_synth));

return container
}
Insert cell
data_synth = [{x:30, y:100.}, {x:70, y:110}, {x:120, y:93}, {x:150, y:102}, {x:350, y:74}]
Insert cell
line = d3.line().x(d => x(d.x)).y(d => y(d.y))
Insert cell
x = d3.scaleLinear()
.domain(d3.extent(data_synth, d => d.x))
.range([margin.left, width-margin.right])
Insert cell
y = d3.scaleLinear()
.domain(d3.extent(data_synth, d => d.y))
.range([height-margin.top, margin.bottom])
Insert cell
margin = ({top: 20, right: 20, bottom: 20, left: 20})
Insert cell
width = 200
Insert cell
height = width
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