Published
Edited
May 18, 2019
1 fork
Insert cell
Insert cell
viewof height = slider({
min: 100,
max: 1000,
step: 1,
value: 500
})
Insert cell
height
Insert cell
width = 600
Insert cell
margin = ({top: 20, right: 30, bottom: 30, left: 50})
Insert cell
x = d3.scaleLinear()
.domain(d3.extent(data, d => d[0]))
.range([margin.left, width - margin.right])
Insert cell
y = d3.scaleLinear()
.domain([d3.min(data, d => d[1] * 0.9), d3.max(data, d => d[1] / 0.9)])
.range([height - margin.bottom, margin.top])
Insert cell
xAxis = g => g
.attr("transform", `translate(0,${height - margin.bottom})`)
.call(d3.axisBottom(x))
Insert cell
yAxis = g => g
.attr("transform", `translate(${margin.left},0)`)
.call(d3.axisLeft(y))

Insert cell
line = d3.line()
.x(d => x(d[0]))
.y(d => y(d[1]))
Insert cell
data = {
return [[0, 1], [1, 0], [2, 4]];
}
Insert cell
d3 = require("https://d3js.org/d3.v5.min.js")
Insert cell
Insert cell
import {slider} from "@jashkenas/inputs"
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