Home Forums Chart Support Multiseries Line Chart Mixture on Draw Reply To: Multiseries Line Chart Mixture on Draw

#38800

@maestrofc27,

Data in the chart seems to move back & froth as CanvasJS renders chart with the data in the order you pass in the options without sorting. Passing data in ascending order of x-values or sorting it based on x-values before rendering the chart seems to work fine in this case. Please find the code-snippet for sorting datapoints in ascending order of x-values below.

for(var i = 0; i < chart.options.data.length; i++) {
	chart.options.data[i].dataPoints.sort(compareDataPointXAscend);
}

function compareDataPointXAscend(dataPoint1, dataPoint2) {
	return dataPoint1.x - dataPoint2.x;
}

Please take a look at this updated JSFiddle for complete code.
JavaScript Multi Series Chart with Sorted Data


Vishwas R
Team CanvasJS