Allows easy super trivial plotting of streaming data.
Dependencies: none. RequireJS-compatible.
plotter.plot('height', hand.palmPosition[1]);
(insert hand)
// call this once per page, after the DOM is ready.
window.plotter = new LeapDataPlotter();
Leap.loop(function(frame){
var hand = frame.hands[0];
if (!hand) return;
// call this once per frame per plot
plotter.plot('height', hand.palmPosition[1], {
precision: 3,
units: 'mm'
});
plotter.plot('y velocity', hand.palmVelocity[1], {
precision: 4,
units: 'mm/s'
});
// call this once per frame
plotter.update()
});
Calling plot will add a canvas to the page. The canvas will simply be appended to the body of `document.body`, with a classname of `leap-data-plotter`. Alternatively, you can pass in your own canvas element:
// basic
window.plotter = new LeapDataPlotter();
// custom canvas
window.plotter = new LeapDataPlotter({
el: document.getElementById('my_canvas')
});
id |
The name of the graph, persistent between frames
- The plot automatically resizes based upon input data |
||||||||||||
data | The datapoint to be added to the plot | ||||||||||||
opts |
|
Redraws the canvas, updating the plot. Nothing will be visible without this being called.
Thanks to @nashira for authoring this library.