n8dogg592432
Posts: 17
Joined: Fri Aug 27, 2021 3:45 pm

dataLabels formatter help

I'm working on a project in angular that uses the highcharts-angular package and wrapper. One of the criteria from the customer is that I need to show the series name on the plotted data. To do this I use the formatter function inside dataLabels and I use this.point.index to determine which data point the label should show up on. My issue is that if that data point has a null value then it's obviously not printed on the chart which also means the label isn't printed on the chart. I've tried passing a parameter into the function to be able to calculate where the null values are in the data series but it doesn't seem like I'm allowed to do that. I've also tried to initialize a variable inside the function to track a null value but that just gets reset on each data point. Basically I'm at the point where if I can get the label to show up anywhere on the series I'd be pumped.

The codesandbox is located here https://codesandbox.io/s/angular-datala ... tter-sw7xx with the my issue replicated. You'll see the problem on the Volume series where the value is null in the location the label should be. Any help/advice is really appreciated. This is another one that I've been stuck on for a while and just not sure what else to try.
mateusz.b
Posts: 2006
Joined: Tue Jul 13, 2021 11:34 am

Re: dataLabels formatter help

Hello n8dogg592432,

Thanks for contacting us with your question.

I would highly recommend using series.label option instead of a data label, as it is much more consistent and less prone to error.
API reference:https://api.highcharts.com/highcharts/p ... ries.label

Notice that this option requires series-label module.
Angular demo: https://stackblitz.com/edit/highcharts- ... ine-kjuqer

Please let me know what do you think about this solution.

Best regards!
Mateusz Bernacik
Highcharts Developer
n8dogg592432
Posts: 17
Joined: Fri Aug 27, 2021 3:45 pm

Re: dataLabels formatter help

That's awesome. Thank you so much again. You turned my very convoluted solution into something that works perfectly every time. Thank you again!
mateusz.b
Posts: 2006
Joined: Tue Jul 13, 2021 11:34 am

Re: dataLabels formatter help

You're welcome! In case of any further questions, feel free to contact us again.
Mateusz Bernacik
Highcharts Developer

Return to “Highcharts Usage”