Home Forums Chart Support Call 2 arrays in the datapoints[ ] Reply To: Call 2 arrays in the datapoints[ ]

#11432

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.

Chart with user input data and parsing from array

—-
Sanjoy Debnath
Team CanvasJS