Last active
February 25, 2016 03:17
-
-
Save sofroniewn/7adfca4529e7662ba550 to your computer and use it in GitHub Desktop.
Moving line
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var line = require('lightning-line') | |
| var el = document.body.appendChild(document.createElement('div')) | |
| var i = 0 | |
| var xCoords = new Array(100).fill(0); | |
| var yCoords = new Array(100).fill(0); | |
| var interval = 100 | |
| var options = { | |
| "zoom": false | |
| } | |
| var viz = new line(el, { | |
| series: yCoords, | |
| index: xCoords, | |
| xaxis: 'time (s)', | |
| ylim: [0, 1], | |
| xlim: [-5, 0] | |
| }, [], options) | |
| setInterval(function () { | |
| yCoords.push(Math.random()) | |
| xCoords.push(i*interval/1000) | |
| yCoords.shift() | |
| xCoords.shift() | |
| viz.updateData({ | |
| series: yCoords, | |
| index: xCoords, | |
| ylim: [0, 1], | |
| xlim: [-5+i*interval/1000, i*interval/1000] | |
| }) | |
| viz.updateAxis() | |
| i++ | |
| }, interval) |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Revision #4 now uses 'xlim' and 'ylim' feature of lightning-line