Is there a way to plot Multiple Lines with Plotly.JS?

Viewed 34

I am trying to use PLOTLY.JS to plot 2 line graphs. But nothing is showing up on the screen except an empty graph. Any help? It works fine with one lines, bar charts, etc.

var plot_data = {}
var trace1 = {
    x: [4, 3, 1],
    y: [1, 3, 6],mode: 'lines',
    type: 'scatter'
  };

var trace2 = {
    x: [6, 8, 9],
    y: [1, 2, 4],mode: 'lines',
    type: 'scatter'
};

var data = [trace1, trace2];
plot_data.push(data);
var layout = 
{
  title: { text: 'Task Plot', font: { family: 'Courier New, monospace', size: 24 }, xref: 'paper', x: 0.05,}
};

//var config = {responsive : true};
Tester = document.getElementById('myDash');

Plotly.newPlot(Tester, plot_data, layout);
1 Answers

If you look at the documentation here, you'll want to pass an array of traces to Plotly.newPlot, so you can replace plot_data with data:

Plotly.newPlot(Tester, data, layout);
Related