mk.developer
Posts: 83
Joined: Wed Mar 17, 2021 6:07 pm

Access Angular component value in formatter function

I have the following formatter function within Angular application:

Code: Select all

dataLabels: [{
          enabled: true,
          formatter: function () {
            return Math.round(this.point.y * 10000) / 100 + "%";
          }]
I would like to access Angular component level property in the formatter function. I can do this by using .bind(this) however this.point.y is no longer accessible after binding.

Code: Select all

dataLabels: [{
          enabled: true,
          formatter: function () {
            return Math.round(this.point.y * 10000) / 100 + "%"; //// This does not work. 
          }.bind(this)]

How can I access value of point y after binding to this?
User avatar
sebastian.h
Posts: 1734
Joined: Fri Aug 07, 2020 7:08 am

Re: Access Angular component value in formatter function

Hi,
Thanks for your message, I will continue your thread at SO
https://stackoverflow.com/questions/728 ... r-function.

In the future please not repeat topic between support channels.

Best regards
Sebastian Hajdus
Sebastian Hajdus
Highcharts Developer
mk.developer
Posts: 83
Joined: Wed Mar 17, 2021 6:07 pm

Re: Access Angular component value in formatter function

Understood, thanks.
User avatar
sebastian.h
Posts: 1734
Joined: Fri Aug 07, 2020 7:08 am

Re: Access Angular component value in formatter function

Thanks,
I'm working on your case.

Regards
Sebastian Hajdus
Highcharts Developer

Return to “Highcharts Usage”