Forum Replies Created by Saurabh singh

Viewing 1 post (of 1 total)
  • in reply to: Order by Value #15798

    yes it was very help full for string comparison you can you below code.

    
    function displayGraph(graphData){
    var chart = new CanvasJS.Chart("chartContainer1",graphData);
    	chart.options.data.forEach(function(element) {
        element.dataPoints.sort(compareDataPoint);
    	});
    	chart.render();
    }
    
    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
    }
    
    
Viewing 1 post (of 1 total)