Published
Edited
Jun 28, 2020
Insert cell
md`# Visualization as scaffolding

Exploring how by default all code should be a visualized scaffolding only optionally hidden. Motivated by https://twitter.com/utopiah/status/1277150095356637186 and earlier Bret Victor talks.
`
Insert cell
{
const context = DOM.context2d(width, 100);
while (true) {
history.map( (v,i) => context.fillRect(i*10,v*100,2,2) )
yield context.canvas;
}
}
Insert cell
md`Reset the values`
Insert cell
history = []
Insert cell
md`Add random values`
Insert cell
addValue()
Insert cell
variableVisualHistoricalInspection = (currentValue, pastValues=[], yOffset=0) => {
// code from https://codesandbox.io/s/keen-neumann-9wfly?file=/sketch.js:1043-1544
/*
var internalHeight = 100
pastValues.push(currentValue)
push()
stroke(0)
fill(255)
rect (0,yOffset,width,internalHeight)
for (var i in pastValues){
let adjustedTimeFrame = map(i, 0, pastValues.length, 0, width)
let adjustedValue = map(pastValues[i], min(pastValues), max(pastValues), 0, internalHeight)
point(adjustedTimeFrame, internalHeight-adjustedValue+yOffset)
}
pop()
return pastValues
*/
}
Insert cell
md`![alt text](https://pbs.twimg.com/media/EbloJhIWsAEjCrW?format=jpg "Logo Title Text 1")`
Insert cell
rand = Math.random()
Insert cell
addValue = _ => { history.push(Math.random()) }
Insert cell
history
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