Skip to content

Instantly share code, notes, and snippets.

@sofroniewn
Last active February 25, 2016 03:17
Show Gist options
  • Select an option

  • Save sofroniewn/7adfca4529e7662ba550 to your computer and use it in GitHub Desktop.

Select an option

Save sofroniewn/7adfca4529e7662ba550 to your computer and use it in GitHub Desktop.
Moving line
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)
@sofroniewn

Copy link
Copy Markdown
Author

Update now supports setting of the axes

@sofroniewn

Copy link
Copy Markdown
Author

Revision #4 now uses 'xlim' and 'ylim' feature of lightning-line

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment