Skip to content

Plot from .json file #1104

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

Closed
SimoneTosato opened this issue Nov 1, 2016 · 2 comments
Closed

Plot from .json file #1104

SimoneTosato opened this issue Nov 1, 2016 · 2 comments

Comments

@SimoneTosato
Copy link

Hi,
I'm currently developing an app based on Electron and i'm implementing real time plotting of a timeseries using plotly.js. Currently i'm using lowdb to create a json file in which I save my (x,y) points and some other infos, is it possible in plotly to use the file as a source to plot data from? I hope this is not a duplicated issue, i haven't found anything about this yet.
If it could be useful my .json file has the following structure

{
    '_data_':[
        { 'series': , 'timestamp': , 'value': }
        .
        .
        .
   ],
  'other data'....
}
@etpinard
Copy link
Contributor

etpinard commented Nov 1, 2016

plotly.js has no notion of source plot data. In essence, plotly.js can only plot coordinates (e.g. x, y) arrays out of the box.

So, you can either convert your json into x and y arrays as e.g.

Plotly.plot('graph', [{
  x: _data_.map((d) => d.timestamp),
  y: _data_.map((d) => d.value)
}])

or write + register a custom transform plugin. See example: http://codepen.io/etpinard/pen/mrNvbg

@etpinard
Copy link
Contributor

etpinard commented Nov 3, 2016

Closing the issue.

Further questions may be asked on https://community.plot.ly/

@etpinard etpinard closed this as completed Nov 3, 2016
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

2 participants