Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tried downloading plotly.js on node js #757

Closed
ghost opened this issue Jul 20, 2016 · 3 comments
Closed

Tried downloading plotly.js on node js #757

ghost opened this issue Jul 20, 2016 · 3 comments

Comments

@ghost
Copy link

ghost commented Jul 20, 2016

[\Users\intern\Documents\universal-ground-system\Node js\node_modules\plotly.js
rc\lib\index.js:397
      var style = document.createElement('style');
                  ^

ferenceError: document is not defined
  at Object.lib.addStyleRule (C:\Users\intern\Documents\universal-ground-syste
Node js\node_modules\plotly.js\src\lib\index.js:397:21)
  at Object.<anonymous> (C:\Users\intern\Documents\universal-ground-system\Nod
js\node_modules\plotly.js\build\plotcss.js:61:16)
  at Module._compile (module.js:409:26)
  at Object.Module._extensions..js (module.js:416:10)
  at Module.load (module.js:343:32)
  at Function.Module._load (module.js:300:12)
  at Module.require (module.js:353:17)
  at require (internal/module.js:12:17)
  at Object.<anonymous> (C:\Users\intern\Documents\universal-ground-system\Nod
js\node_modules\plotly.js\src\plotly.js:30:1)
  at Module._compile (module.js:409:26)](url)

Getting this error when require(plotly.js) is used in my code. This issue has been brought up before, but was not specified on how to fix. My code is below

var plotly= require('plotly')
var initdata = [{x:[], y:[], stream:{token:'t2166m92ft', maxpoints:100000}}];
    var initlayout = {fileopt : 'overwrite', filename : 'nodenodenode5'};

    plotly.plot(initdata, initlayout, function (err, msg) {
      if (err) return console.log(err);
      console.log(msg);

      var stream1 = plotly.stream('t2166m92ft', function (err, res) {
        if (err) return console.log(err);
        console.log(res);
        clearInterval(loop); // once stream is closed, stop writing
      });
      var varCounter = 0;
      var i = 0;
      var loop = setInterval(function () {
        if(varCounter <= 100) {
          client.once('message', function (message) {
            var data = { x : i , y :  message.toString()};
            var streamObject = JSON.stringify(data);
            stream1.write(streamObject+'\n');
            i++;
          });
          varCounter++;
        }
        else {
          clearInterval(loop);
        }
      }, 3000);
    });
  }
@etpinard
Copy link
Contributor

duplicate of #437

@ghost
Copy link
Author

ghost commented Jul 20, 2016

I know its a duplicate, but was wondering if the server side problem is now fixed? Also if you corrected your code to work. Also if it is working, how do you stream data using the plotly.js since you need stream token. Looking for an example

@etpinard
Copy link
Contributor

but was wondering if the server side problem is now fixed?

I haven't looked at this in a while now. This is not a priority for us.

I know that jsdom has just added native support for DOMParser (see discussion) so starting from https://gist.github.com/etpinard/bee7d62b43b6bb286950 it might worth trying it out now.

If you find anything interesting please let us know by commenting on #437.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant