Skip to content
Advertisement

assign json object to javascript variable in CanvasJS

Im trying to assign a json object to a variable. Im not sure how to accomplish this.

This is my JSON array:

JavaScript

I wish to assign the value of sensorValue to variable yValue. how do i do this? Eg: for “sensorValue”:433, yValue = 433

JavaScript

Advertisement

Answer

CanvasJS accepts dataPoints as an array of objetcs as [{x: xValue1, y: yValue1}, {x: xValue2, y: yValue2},…]. Parsing your JSON to this format before passing it to chart-options should work fine.

JavaScript
JavaScript
User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement