You must be logged in to post your query.
Home › Forums › Chart Support › Call 2 arrays in the datapoints[ ]
Tagged: graphs datapoints arrays dynamic
Hi, I have 2 arrays which is dynamically being made with some algorithm and it all depends on the user inputs.
I want to plot each of the arrays in respective axis of the graph. That is call the 1 array(with dates) for the x-axis values and 1 array with numbers for y-axis.
So how do I call the 2 arrays in the datapoints[ ] ?
Elina,
To render the dataPoint with one array for x value and other array for y values, you need to parse the arrays according to data format accepted by CanvasJS. Check out the below code snippet for parsing the arrays.
function parseDataPoints() { for (var i = dps.length; i < dateArray.length; i++) dps.push({ x: new Date(dateArray[i]), y: numberArray[i] }); };
Please take a look at this JSFiddle for complete code sample.
—- Sanjoy Debnath Team CanvasJS
Thanks Sanjoy,
The code works perfectly. Thanks you so much. You are the best!
Regards, Elina
You must be logged in to reply to this topic. Login/Register