1 | 'use strict';
|
2 |
|
3 | var plotly = require('../.')('plotlyUsername','apiKey');
|
4 |
|
5 | var initdata = [{x:[], y:[], stream:{token:'streamToken', maxpoints:200}}];
|
6 | var initlayout = {fileopt : 'overwrite', filename : 'nodenodenode'};
|
7 |
|
8 | plotly.plot(initdata, initlayout, function (err, msg) {
|
9 | if (err) return console.log(err);
|
10 | console.log(msg);
|
11 |
|
12 | var stream1 = plotly.stream('streamToken', function (err, res) {
|
13 | if (err) return console.log(err);
|
14 | console.log(res);
|
15 | clearInterval(loop);
|
16 | });
|
17 |
|
18 | var i = 0;
|
19 | var loop = setInterval(function () {
|
20 | var data = { x : i, y : i * (Math.random() * 10) };
|
21 | var streamObject = JSON.stringify(data);
|
22 | stream1.write(streamObject+'\n');
|
23 | i++;
|
24 | }, 1000);
|
25 | });
|
26 |
|