Home forums Using CanvasJS Multi Series Line Graphs Reply To: Multi Series Line Graphs

#4568

jamesf
Participant

Sunil thanks alot on this. I modified the above code to wok with 2 data sets now. See below for anyone having same issue.

Demo

$( document ).ready(function() { // Begin jQuery ready function

//Creating a multi-series line graph from 2 sets of data. Namely dps1 and dps2.

var dps1 = [ {x: 0, y: 10}, {x: 2, y: 17}, {x: 3, y: 29} ]; //dataPoints – line 1
var dps2 = [ {x: 1, y: 15}, {x: 2, y: 28}, {x: 3, y: 42} ]; //dataPoints. – line 2

var chart = new CanvasJS.Chart(“chartContainer”,{
title :{
text: “Live Data”
},
axisX: {
title: “Axis X Title”
},
axisY: {
title: “Units”
},

// begin data for 2 line graphs. Note dps1 and dps2 are
//defined above as a json object. See http://www.w3schools.com/json/
data: [
{ type: “line”, dataPoints : dps1},
{ type: “line”, dataPoints : dps2}
]
// end of data for 2 line graphs

}); // End of new chart variable

chart.render();

}); // End of jQuery ready function