Published
Edited
Jun 30, 2019
Importers
2 stars
Insert cell
Insert cell
Insert cell
md`Variables defined as below:
**size, margin, data, xScale, yScale, fillScale**`
Insert cell
// data.push({x:100,y:0.3})
Insert cell
data = Array.from({length: 20}, () => ({x: Math.round(Math.random()*40,2), y: 0.3}))
Insert cell
size = ({width: Math.min(window.innerWidth, 800), height: 400})
Insert cell
margin = ({top: 12, right: 10, bottom: 26, left: 26})
Insert cell
xScale = d3.scaleLinear()
.domain([d3.min(data, d => d.x)-5, d3.max(data, d => d.x)+5]).nice()
.range([margin.left, size.width - margin.right])
Insert cell
yScale = d3.scaleLinear()
.domain([0, 1])
.range([margin.left, size.width - margin.right])
Insert cell
d3=require("d3")
Insert cell
math =require("https://cdnjs.cloudflare.com/ajax/libs/mathjs/5.10.3/math.min.js")
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