indexLabelFormatter: Function

A custom formatter function which returns the text to be displayed as indexLabel on dataPoints.

Note
  • indexLabelFormatter overrides indexLabel property.
  • indexLabel & indexLabelFormatter on dataPoints override corresponding properties in dataSeries.
var  chart =  new  CanvasJS.Chart("container",
{
 .
 .
 data:[{
    dataPoint :[
       { x: 10, y : 12,  
                indexLabelFormatter: function (e) { return  e.dataPoint.y ; } 
       },  
         
}],
 .
 . 
});
chart.render();

  • By using indexLabelFormatter, you can return any value to be displayed as indexLabel.
    Below is the structure of object passed as parameter to the function
e: { // parameter sent to function
       chart,
       dataSeries,
       dataPoint,
       index,        // Available only in range charts
       total,        // Available only in stacked, pie and doughnut charts
       percent,      // Available only in stacked, pie and doughnut charts
 }
Note
  • index parameter is available only in case of range charts. It is undefined in case of other chart types.

Try Editing The Code


If you have any questions, please feel free to ask in our forums.Ask Question