How to show the trackball on load time in React Chart?
This article explains how to display the trackball at load time in the React Chart.
Customize the settings to show the trackball on load time in the chart
To enable the trackball, set the enable property of the crosshair to true, and the shared property in the tooltip to true in the chart. Alternatively, you can show the trackball programmatically during the chart loading time using the loaded event and the showTooltip and showCrosshair methods.
In the following code example, the trackball is shown during chart rendering.
Index.js
import { createRoot } from 'react-dom/client';
import * as React from 'react';
import { ChartComponent, SeriesCollectionDirective, SeriesDirective, Inject, LineSeries, DateTime,
Tooltip, Crosshair } from '@syncfusion/ej2-react-charts';
import { john, andrew, thomas } from './trackball-data';
const TrackballChart = () => {
const onChartLoad = (args) => {
args.chart.showTooltip(200, 200, false);
args.chart.showCrosshair(200, 200);
};
return (
<chartcomponent id="charts" primaryxaxis="{{" minimum:="" new="" date(2000,="" 1,="" 1),="" maximum:="" date(2006,="" 2,="" 11),="" valuetype:="" 'datetime',="" skeleton:="" 'y',="" crosshairtooltip:="" {="" enable:="" true="" }="" }}="" primaryyaxis="{{" title:="" 'revenue="" (in="" million)',="" labelformat:="" '{value}m',="" 10,="" 80="" title="Average Sales per Person" loaded="{onChartLoad.bind(this)}" tooltip="{{" true,="" shared:="" format:="" '${point.y}',="" enablemarker:="" false,="" header:="" ''="" crosshair="{{" linetype:="" 'vertical'="">
<inject services="{[LineSeries," datetime,="" tooltip,="" crosshair]}="">
<seriescollectiondirective>
<seriesdirective datasource="{john}" xname="x" yname="y" width="{2}" name="John" type="Line" marker="{{" visible:="" true,="" isfilled:="" width:="" 7,="" height:="" 7="" }}="" animation="{{" enable:="" false="">
<seriesdirective datasource="{andrew}" xname="x" yname="y" width="{2}" name="Andrew" type="Line" marker="{{" visible:="" true,="" isfilled:="" width:="" 7,="" height:="" 7="" }}="" animation="{{" enable:="" false="">
<seriesdirective datasource="{thomas}" xname="x" yname="y" width="{2}" name="Thomas" type="Line" marker="{{" visible:="" true,="" isfilled:="" width:="" 7,="" height:="" 7="" }}="" animation="{{" enable:="" false="">
</seriesdirective></seriesdirective></seriesdirective></seriescollectiondirective>
</inject></chartcomponent>
);
};
export default TrackballChart;
const root = createRoot(document.getElementById('sample'));
root.render(<trackballchart>);
The following screenshot portrays the results of the code snippet mentioned above.
Screenshot:
Refer to the working sample for additional details and implementation: View Sample in Stackblitz
Conclusion
We hope you enjoyed learning how to show the trackball on load time in the React Chart component.
You can refer to our React Chart feature tour page to learn about its other groundbreaking feature representations and documentation, and how to quickly get started for configuration specifications. You can also explore our React 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, BoldDesk Support, or feedback portal. We are always happy to assist you!