Home Forums Chart Support Order by Value Reply To: Order by Value

#9292

tufweb,

Sort feature is not available out of the box. However, with just a few lines of code, you can sort the dataPoint before rendering the chart. Please check out the code snippet below for the same.

function compareDataPointYAscend(dataPoint1, dataPoint2) {
		return dataPoint1.y - dataPoint2.y;
}

chart.options.data[0].dataPoints.sort(compareDataPointYAscend);

Also, please take a look at this JSFiddle for complete working code.

Sorting Data Points in Charts

—-
Naveen Venugopal
Team CanvasJS