Home Forums Chart Support Want to use push to add two line plots Reply To: Want to use push to add two line plots

#43156

@ispybadguys,

The datapoint object only accepts x and y values as of now. Your JSON can be in this format – {“x”:1687209355000,”y1″:10,”y2″:40}, however, you will have to parse the JSON data in the format accepted by CanvasJS and then pass them as datapoints to the chart. Please check the code snippet below:

for(var i = 0; i < jsonData.length; i++) {
    chart.options.data[0].dataPoints.push({x: jsonData[i].x, y: jsonData[i].y1})
    chart.options.data[1].dataPoints.push({x: jsonData[i].x, y: jsonData[i].y2})
}


Thangaraj Raman
Team CanvasJS