Articles in this section
Category / Section

How to customize the Crosshair Label Text dynamically in jQuery Chart?

1 min read

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.

JS

<div id="container"></div>
<script type="text/javascript">
    //Event handler for crosshair label text
    function crosshairLabel(sender) {
        if (sender.data.chartAxis.orientation == 'horizontal')
            sender.data.currentTrackText = 'Item No: ' + sender.data.currentTrackText;
    }
    $(function () {                
        $("#container").ejChart({
            trackAxisToolTip: 'crosshairLabel',
            primaryXAxis: {
                crosshairLabel: { visible: true }
            },
            primaryYAxis: {
                crosshairLabel: { visible: true }
            },
            commonSeriesOptions: {                
                type: 'line',
                dashArray: '10, 5',                
            },
            crosshair: {
                visible:true
            }
        });
    });
</script>

 

The following screenshot displays the chart with customized crosshair label text.

Chart with customized crosshair label text.

JS Playground sample link: Crosshair tooltip customization

 

Did you find this information helpful?
Yes
No
Help us improve this page
Please provide feedback or comments
Comments (0)
Please sign in to leave a comment
Access denied
Access denied