lead.js
lead.js copied to clipboard
interactive graph
drag left and right to change time period
This uses brushes, rather than dragging the graph itself:
params = new Bacon.Model {}
brush = new Bacon.Model()
cursor = new Bacon.Model()
button = input.button('update')
target = randomWalk 'random walk'
params.addSource brush.sampledBy(button).map (extent) ->
if extent?
from: moment(extent[0]).unix(), until: moment(extent[1]).unix()
else
Bacon.once {}
liveData =
params.flatMapLatest (params) ->
Bacon.fromPromise get_data target, params
options {
cursor
brush
height: 200
}
graph liveData, options()
graph target, from: '-1w'