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

#32600

rodolfo,

To sort the dataPoints for multi-series bar chart, you need to sort the dataPoints for each of data series present in the multi-series bar chart. Please take a look the code snippet below for the same.

chart.options.data.forEach(function(element) {
   element.dataPoints.sort(compareDataPoint);
});

function compareDataPoint(dataPoint1, dataPoint2) {
  // instead of label you can also use dataPoint.x  or dataPoint.y depends on you requirment
  if (dataPoint1.label < dataPoint2.label){return -1}
  if ( dataPoint1.label > dataPoint2.label){return 1}

  return 0
}

Also, check out this JSFiddle for the complete working code.

Sorting Data Points in Multi-Series Bar Charts

If you are still facing the issue, can you kindly create JSFiddle reproducing the issue you are facing and share it with us along with further briefing so that we can understand your scenario better and help you out?

—-
Manoj Mohan
Team CanvasJS