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",
{
 .
 .
 axisX:{
       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 it Yourself by Editing the Code below.

  Also See:    



In order to provide better support,we have closed the comments and switched completely to our Forums.
If you have any questions, please feel free to ask in our forums.