How to show custom tooltip with a redirection link in the Javascript Charts?
Description
This article explains on how to show the custom tooltip with a redirection link in the Javascript Charts.
Solution
The tooltip is used to show additional information about the data point on which the mouse hovers. Any HTML element can be displayed in the tooltip by using the template property in the tooltip of the Chart.
You can add the redirection link in the tooltip by using the anchor tag in the div element where the id of the div element is set in the template property of the tooltip.
Code Snippet
index.html
<script id="Tooltip" type="text/x-template">
<div id="wrap">
<table style="width:100%; border: 1px solid black;" class="table-borderless">
<tr>
<td style="background-color: #C1272D;">
<a style="color:white;font-size:12px;font-weight:bold" href="https://ej2.syncfusion.com/demos/#/material3/chart/overview.html">EJ2 Demos</a>
</td>
</tr>
<tr>
<td style="background-color: #C1272D; font-size: 12px; color: #E7C554; font-weight: bold; padding-left: 5px">Y : ${y}</td>
</tr>
<tr >
<td style="background-color: #C1272D; font-size: 12px; color: #FFFFFF; font-weight: bold; padding-left: 5px">X : ${x}</td>
</tr>
</table>
</div>
</script>
index.ts
tooltip: {
enable: true,
template: '#Tooltip'
},
The following image illustrates the output of the above code.
Conclusion
I hope you enjoyed learning how to show the custom tooltip with a redirection link in the Javascript Charts.
You can refer to our Javascript Charts feature tour page to learn about its other features and documentation, and how to quickly get started for configuration specifications. You can also explore our Javascript Charts example to understand how to create and visualize 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 comment section below. You can also contact us through our support forums, support portal, or feedback portal. We are always happy to assist you!