labelFormatter : Function

A custom formatter function that returns Crosshair’s label.

Notes
  • labelFormatter overrides the label property.
  • You can use formatNumber and formatDate functions to format number/date values inside the formatter function.
var  chart =  new  CanvasJS.Chart("container",
{
 .
 .
 axisY:{
       crosshair: 
	{
		enabled: true,
		labelFormatter: function ( e ) {
			return "Custom Point"  + e.value;  
		} 
	}      
  },
 
 .
 . 
});
chart.render();

  • By using labelFormatter, you can return any value to be displayed as crosshair’s label.
    Below is the structure of object passed as parameter to the function:

    e: { // parameter sent to function
           chart,
           axis,
           crosshair,
           value       
    }
        
Note

If you have to access any preset options of the chart, you can access them via e.chart.options. For example e.chart.options.title.text


Try Editing The Code

  Also See:    


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