How to customize the Crosshair Label Text dynamically in ASP.NET MVC Chart?
Essential Chart supports customization of the crosshair axis label dynamically in TrackAxisToolTip event. Refer to the Chart Events for more information about events available in Chart. Refer to the TrackAxisToolTip for more information about the argument available in event handler for TrackAxisToolTip event.
The event handler provides an object as an argument that contains the properties like cancel, data, model and type. The crosshair label text can be customized by using currentText property of data in the parameter object.
CSHTML
@(Html.EJ().Chart("container") .TrackAxisToolTip("crosshairLabel") .PrimaryXAxis(axis=>axis.CrosshairLabel(label=>label.Visible(true))) .PrimaryYAxis(axis=>axis.CrosshairLabel(label=>label.Visible(true))) .Crosshair(crosshair=> crosshair.Visible(true)) .CommonSeriesOptions(options=> options.Type(SeriesType.Line) .DashArray("5,5") ) ) <script type="text/javascript"> //Event handler for crosshair label text function crosshairLabel(sender) { if (sender.data.chartAxis.orientation == 'vertical') sender.data.currentTrackText = 'Price: $ ' + sender.data.currentTrackText; } </script>
The following screenshot displays the chart with customized crosshair label text.
Conclusion
I hope you enjoyed learning about how to customize the Crosshair Label Text dynamically in ASP.NET MVC Chart.
You can refer to our ASP.NET MVC Chart feature tour page to know about its other groundbreaking feature representations and documentation, and how to quickly get started for configuration specifications. You can also explore our ASP.NET MVC Chart example to understand how to create and manipulate data.
For current customers, you can check out our components from the License and Downloads page. If you are new to Syncfusion, you can try our 30-day free trial to check out our other controls.
If you have any queries or require clarifications, please let us know in the comments section below. You can also contact us through our support forums, Direct-Trac, or feedback portal. We are always happy to assist you!