Public
Edited
1 fork
Importers
1 star
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
p5(sketch => {
sketch.setup = function() {
sketch.createCanvas(width, height);
sketch.textAlign(sketch.CENTER, sketch.CENTER);


sketch.noStroke();
sketch.fill(0);
for(let i = 0; i < data.length; i++) {
sketch.ellipse(data[i], margin, 5, 5);
sketch.text(data[i], data[i], 30)
}
}

})
Insert cell
Insert cell
Insert cell
Insert cell
data[0]
Insert cell
Insert cell
map(data[0], 4, 92, 0, 800)
Insert cell
Insert cell
xScale = d3.scaleLinear().domain(d3.extent(data)).range([0, width])
Insert cell
Insert cell
Insert cell
d3.extent(data)
Insert cell
Insert cell
Insert cell
xScale(data[0])
Insert cell
Insert cell
p5(sketch => {
sketch.setup = function() {
sketch.createCanvas(width, height);
sketch.textAlign(sketch.CENTER, sketch.CENTER);

// draw a line as an axis
sketch.line(0, margin, screen.width, margin)
sketch.noStroke();
for(let i = 0; i < data.length; i++) {
const screenX = xScale(data[i]);
// blue for dots
sketch.fill(70, 130, 180)
sketch.ellipse(screenX, margin, 5, 5);
// black for labels
sketch.fill(0)
sketch.text(data[i], screenX, 30)
}
}

})
Insert cell
Insert cell
xScaleWithMargin = d3.scaleLinear().domain(d3.extent(data)).range([margin, width - margin])
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
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