How to apply bold styling in shared tooltip for Angular Charts?
This article demonstrates how to apply partially bold text in shared tooltips using the Angular Chart component.
Apply partial bold styling in shared tooltip
To render a shared tooltip with partially bold text, you can use the sharedTooltipRender event and customize the tooltip content dynamically.
In the example below, the date is formatted using a custom formatDate method. The tooltip text is modified within the sharedTooltipRender event to apply bold styling only to the series name (args.series[i].name) and the Y-value (args.data[i].pointY) of each data point.
index.html
<ejs-chart [primaryXAxis]='primaryXAxis' [primaryYAxis]='primaryYAxis'
[tooltip]='tooltip' (load)='load($event)' (sharedTooltipRender)='sharedTooltipRender($event)'
[chartArea]='chartArea' [width]='width' [legendSettings]='legend'>
app.component.ts
export class AppComponent {
public formatDate(date) {
const options: Intl.DateTimeFormatOptions = {
year: 'numeric',
month: '2-digit',
day: '2-digit',
hour: '2-digit',
minute: '2-digit',
second: '2-digit',
hour12: true,
};
const formattedDate = new Intl.DateTimeFormat('en-US', options).format(date);
return formattedDate;
}
public sharedTooltipRender(args) {
for (let i = 0; i < args.point.length; i++) {
const formattedDate = this.formatDate(args.data[i].pointX as Date);
args.text[i] =
'<b>' +
' ' +
args.series[i].name +
' ' +
args.data[i].pointY +
' ' +
'</b> ' +
',' +
formattedDate;
}
}
}
Output
Sample
Conclusion
I hope you enjoyed learning about how to apply bold styling in shared tooltip for Angular Charts.
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!