Articles in this section
Category / Section

How to Display Date Values in Tooltip for Angular Range Column Chart?

2 mins read

Description

This article explains how to display date-time values in tooltips for an Angular Range Column Chart, specifically when the Y-axis represents time-based data (e.g., start and end times).

Solution

The chart component does not natively support displaying date-time values directly on the Y-axis. However, you can represent date-time values by providing the data in milliseconds (as double-type values) in the dataSource. These numeric values can then be converted to a readable date-time format in the tooltip using the tooltipRender event.

Implementation

The following code snippet demonstrates how to convert timestamp values on the Y-axis into formatted date-time strings within the tooltip.

app.component.ts

public tooltipRender(args: ITooltipRenderEventArgs): void {
   const intl: Internationalization = new Internationalization();
   const dateFormat: (date: Date) => string = intl.getDateFormat({ format: 'hh:mm a' }) as (date: Date) => string;
   const high: string = dateFormat(
   new Date(args.series.dataSource[args.point.index].y)
   );
   const low: string = dateFormat(
   new Date(args.series.dataSource[args.point.index].y1));
   args.text = `${args.point.x}: ${high} - ${low}`;
 } 

app.component.html

<ejs-chart (tooltipRender)="tooltipRender($event)">
</ejs-chart> 

Output

The tooltip will now display time values in a readable format such as 01:30 PM – 02:50 PM, even though the Y-axis values are provided as Date objects, which are internally handled as milliseconds.

image.png

Live Demo

Refer to the working sample for additional details and implementation:View Sample in Stackblitz

Conclusion

We hope you enjoyed learning how to display date-time values in tooltip for Angular Range Column Chart.

You can refer to our Angular Range Column Chart feature tour page to learn about its other groundbreaking feature representations and documentation, as well as how to quickly get started with configuration specifications. You can also explore our Angular 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, Direct-Trac, or 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)
Please  to leave a comment
Access denied
Access denied