Forum Replies Created by jamesf

Viewing 3 posts - 1 through 3 (of 3 total)
• in reply to: Multi Series Line Graphs #4570

Sunil,

Your Fiddle is just what I needed to know. Once you know the structure for 2 series,
then to build for N series becomes really easy.

Thanks,
Jim

in reply to: Multi Series Line Graphs #4568

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

//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

in reply to: Y data points do not graph #4546

Sunil this worked. For anyone else the Number conversion was critical. The code above is:
dataPoints.push({ x: i, y: Number(parsed_json.history.observations[i].tempi}));

But the parans are wrong (typo there). So fixing the typo you get:

dataPoints.push({ x: i, y: Number(parsed_json.history.observations[i].tempi)});

This works fine!

Thanks,
Jim

Viewing 3 posts - 1 through 3 (of 3 total)