I can’t figure out, why this isnt working. I’m getting data from three CSV, files. CSV format is this:
Date,Usage
2018-09-12 16:02,21
2018-09-12 16:05,20
2018-09-12 16:12,20
I’m trying to create three traces to one plot, but it’s always empty.
If I use any of the traces alone, it looks ok:
Plotly.newPlot(‘myDiv’, trace1, layout);
But when all traces are being used, plot is empty and x-axis values look wrong:
var AllData =[trace1, trace2, trace3];
Plotly.newPlot(‘myDiv’, AllData, layout);
Judging by looking at at your snippets quickly, it looks like your trace1 is an array containing one {} object (otherwise Plotly.newPlot(gd, trace1, layout) wouldn’t have worked and [trace1, trace2, trace3] must then be a 2D array, which plotly.js doesn’t accept. So, Plotly.newPlot(gd, [trace1[0], trace2[0], trace[0]], layout)` should work.
Thank you! this worked perfectly
If I may ask in this same topic, what would be the optimal way for live updating the graph that comes from a csv? I was able to do it so, that it runs this makeplot() every 1second, but it seems to use an unnecessary amount of processor. Using extendtraces might do the trick, but I can’t figure out how to implement it to a code below, that uses csv as data…
function makeplot() {
Plotly.d3.csv(“path to csv”, function(data){
Plotly.d3.csv(“path to csv”, function(data2){
Plotly.d3.csv(“path to csv”, function(data3){