Articles in this section
Category / Section

How to Add a Header to the Tooltip in Angular Stacked Bar Chart?

To display a custom header in the tooltip of a Stacked Bar Angular Chart, use the sharedTooltipRender event of the ejs-chart component. This event is triggered just before the shared tooltip is rendered, allowing you to modify its content.

In the example below, the sharedTooltipRender method calculates the sum of all Y-values from the stacked series at the hovered x-axis point and sets it as the tooltip header using args.headerText.

Code Example

app.component.html

<ejs-chart style='display:block;' (sharedTooltipRender)='sharedTooltipRender($event)'>...
       </ejs-chart> 

app.component.ts

public sharedTooltipRender(args) {
       let sum =0 ;
       for (let i = 0; i < args.data.length; i++) {
       sum = sum + args.data[i].pointY;
       }
     args.headerText= 'Total' + ' ' + sum.toString();
   } 

Output

image.png

Live Sample

StackBlitz Sample

Conclusion

I hope you enjoyed learning about how to add a header to the tooltip in Angular Stacked Bar Chart.

You can refer to our Angular Chart’s feature tour page to learn about its other groundbreaking feature representations. You can also explore our Angular Chart Documentation to understand how to present and manipulate data.

For current customers, you can check out our Angular components on the License and Downloads page. If you are new to Syncfusion, you can try our 30-day free trial to explore our Angular Chart and other Angular components.

If you have any queries or require clarifications, please let us know in the comments below. You can also contact us through our support forums, Direct-Trac or feedback portal, or the feedback portal. We are always happy to assist you!

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