How to show tooltip on load time in React Chart?
This article explains how to show the tooltip on load time in the React Chart.
Customize the settings to show the tooltip on load time in the chart
By default, the tooltip is not visible in the chart. To enable the tooltip, set the enable property to true in tooltip. Alternatively, you can show the tooltip programmatically during the chart loading time using the loaded event and the showTooltip method.
In the following code example, the tooltip is shown during chart rendering.
Index.js
import { createRoot } from 'react-dom/client';
import * as React from 'react';
import { ChartComponent, SeriesCollectionDirective, SeriesDirective, Inject, ColumnSeries, Category, Tooltip
} from '@syncfusion/ej2-react-charts';
const Line = () => {
const onChartLoad = (args) => {
let x = args.chart.series[0].points[2].x;
let y = args.chart.series[0].points[2].y;
args.chart.showTooltip(x, y, true);
};
return (
<ChartComponent
id="charts"
primaryXAxis={{
valueType: 'Category'
}}
primaryYAxis={{
minimum: 0,
maximum: 20,
interval: 4
}}
tooltip={{ enable: true, enableMarker: false, format: '${point.y}' }}
loaded={onChartLoad.bind(this)}
>
<Inject services={[ColumnSeries, Category, Tooltip]} />
<SeriesCollectionDirective>
<SeriesDirective
dataSource={data}
xName="x"
yName="y"
type="Column"
animation={{ enable: false }}
></SeriesDirective>
</SeriesCollectionDirective>
</ChartComponent>
);
};
export default Line;
const root = createRoot(document.getElementById('sample'));
root.render(<Line />);
The following screenshot portrays the results of the code snippet mentioned above.
Screenshot:
Conclusion
I hope you enjoyed learning how to show the tooltip on load time in the React Chart Component.
You can refer to our React 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 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, support portal, or feedback portal. We are always happy to assist you!