indexLabelFormatter: Function

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

  • indexLabelFormatter overrides indexLabel property.
  • indexLabel & indexLabelFormatter on dataPoints override corresponding properties in dataSeries.

var  chart =  new  CanvasJS.Chart("container",
    dataPoint :[
       { x: 10, y : 12,  
                indexLabelFormatter: function (e) { return  e.dataPoint.y ; } 

  • 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
           index,        // Available only in range charts
           total,        // Available only in stacked, pie and doughnut charts
           percent,      // Available only in stacked, pie and doughnut charts
  • index parameter is available only in case of range charts. It is undefined in case of other chart types.

Try it Yourself by Editing the Code below.

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