Published
Edited
Apr 3, 2018
8 stars
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
stdlib = require( "https://unpkg.com/@stdlib/stdlib@0.0.34/dist/stdlib-flat.min.js" )
Insert cell
Insert cell
Insert cell
Insert cell
sparkline = stdlib.UnicodeColumnChartSparkline
Insert cell
Insert cell
randi = stdlib.base.random.discreteUniform
Insert cell
Insert cell
randexp = stdlib.base.random.exponential
Insert cell
Insert cell
randbinom = stdlib.base.random.binomial
Insert cell
Insert cell
inmap = stdlib.inmap
Insert cell
Insert cell
countBy = stdlib.countBy
Insert cell
Insert cell
Insert cell
data1 = inmap( new Int8Array( 10 ), randi.factory( 0, 100 ) )
Insert cell
Insert cell
chart1 = sparkline( data1 )
Insert cell
Insert cell
str1 = chart1.render()
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
data2 = inmap( new Int32Array( 1000 ), randbinom.factory( n, p ) )
Insert cell
Insert cell
counts = countBy( data2, ( v ) => v )
Insert cell
Insert cell
values = inmap( new Int32Array( n ), ( v, i ) => counts[ i ] )
Insert cell
Insert cell
chart2 = sparkline( values )
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
minint = 0
Insert cell
maxint = 100
Insert cell
data3 = inmap( new Int32Array( 20 ), randi.factory( minint, maxint ) )
Insert cell
Insert cell
chart3 = sparkline( data3, {
'bufferSize': data3.length,
'yMin': minint,
'yMax': maxint
})
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
rendered_chart = {
yield chart3.render(); // render the chart at least once
while ( runFLG ) {
await Promises.delay( randexp( 1.0/(tau*1000.0) ) ); // convert tau to milliseconds
yield chart3.push( randi( minint, maxint ) ).render(); // push a new datum and re-render
}
}
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
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