How to show the tooltip for annotation in Angular Charts?
Description
This article shows how to show a tooltip for the annotation in Angular Charts using the chartMouseLeave event.
Solution
The annotation is used to add explanatory text or graphical elements to a chart to provide additional information or context. The tooltip can be shown while hovering over an annotation by using the chartMouseLeave event in the chart.
The mouseMove event should be bound to the div element that contains the content of the annotation. While hovering on the annotation, this event gets triggered to show the tooltip in the appropriate position relative to the annotation.
Code Snippet
In the following example, the process above described is carried out using the mouseMove and chartMouseLeave methods. The following example shows how to render the tooltip for the annotation.
app.component.ts
public mouseMove(args): void {
this.annotationEle = document.getElementById('container_Annotation_0');
this.tooltipEle = document.getElementsByClassName("tooltip")[0];
this.tooltipEle.style.display = "block";
this.tooltipEle.style.left = parseFloat(this.annotationEle.style.left.split('px')[0]) + 35 + "px";
this.tooltipEle.style.top = this.annotationEle.style.top;
this.tooltipEle.innerHTML = "Custom Text";
}
public chartMouseLeave(args: IMouseEventArgs): void {
if(this.tooltipEle !=null)
this.tooltipEle.style.display = "none";
}
};
The following screenshot illustrates the output of the above code snippet
Conclusion
I hope you enjoyed learning how to show the tooltip for annotation in Angular Chart.
You can refer to our Angular 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 Angular 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!