Articles in this section
Category / Section

How to display the sticky tooltip in JavaScript Charts?

2 mins read

Description

This article shows how to display the sticky tooltip in JavaScript Charts.

Solution

A tooltip in a chart is a small pop-up box that appears when the user hovers over a data point. It provides additional information about the specific data point being hovered.

To add a tooltip to a chart, you can enable it using the enable property in the tooltip configuration.

By default, the tooltip follows the mouse cursor as it moves over data points. However, if you prefer to display the tooltip at a fixed position on the chart, you can set specific coordinates using the x and y properties within the location setting of the tooltip. This is useful when you want the tooltip to always appear in a consistent spot, regardless of where the user hovers.

Code Snippet

let chart: Chart = new Chart({
tooltip: { 
  enable: true,
  shared: true, 
  location: {x: 80, y: 20}
},
...
});
chart.appendTo('#container');

The following image illustrates the output of the above code.

image.png

View Sample in Stackblitz

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