kamil.m
Posts: 892
Joined: Thu May 19, 2022 1:33 pm

Re: Getting point.dataLabel undefined at times

Hi there,

Good to hear from you again!

I'm glad that you have found a correct solution for your previous issue.
This time it actually looks like a bug, so feel free to report it on our GitHub Issues page, and wait for any fixes/workarounds there.

Alternatively, play around with the dataLabels formatter, maybe there is some custom formatting that might be causing this little bug?

GitHub Issues: https://github.com/highcharts/highcharts/issues

Thank you for your patience,
Best regards!
Kamil Musiałowski
Highcharts Developer
eraka
Posts: 123
Joined: Thu Apr 28, 2022 6:55 am

Re: Getting point.dataLabel undefined at times

Hi kamil,

if you see there is custom formatter that i am using i blv that is called but else case of formatter. Is there any way is can use formatter inside a flag and call it conditionally, please see the stackblitz shared earlier.
kamil.m
Posts: 892
Joined: Thu May 19, 2022 1:33 pm

Re: Getting point.dataLabel undefined at times

Hi there!

A formatter is a function that is called every time, for each dataLabel that is created on the chart. Even if you don't specify one, a default formatter is still called. So for a conditional formatter, I would suggest not calling it conditionally, but setting up a custom functionality, like an if statement - and then determining what should happen under each condition.

Let me know if you will have any issues with that,
Regards!
Kamil Musiałowski
Highcharts Developer
eraka
Posts: 123
Joined: Thu Apr 28, 2022 6:55 am

Re: Getting point.dataLabel undefined at times

I tried creating a counter variable counterFlag in class component but inside the formatter (custom) when i am trying to access it with if condtion its saying

Property 'counterFlag' does not exist on type 'PointLabelObject'.


if(this.counterFlag ){
}
kamil.m
Posts: 892
Joined: Thu May 19, 2022 1:33 pm

Re: Getting point.dataLabel undefined at times

Make sure to check where is your custom variable assigned, and see if you can access it from the formatter callback function. Maybe assign in on the chart? That way it should be accessible from every function in your chart.
Kamil Musiałowski
Highcharts Developer
eraka
Posts: 123
Joined: Thu Apr 28, 2022 6:55 am

Re: Getting point.dataLabel undefined at times

can u plz show in demo link
kamil.m
Posts: 892
Joined: Thu May 19, 2022 1:33 pm

Re: Getting point.dataLabel undefined at times

Sure,

Please prepare a working demo where you add your custom counterFlag variable, and where you try to access it from the formatter.
I'll have a look at your implementation and tell you what's wrong.

Regards!
Kamil Musiałowski
Highcharts Developer
kamil.m
Posts: 892
Joined: Thu May 19, 2022 1:33 pm

Re: Getting point.dataLabel undefined at times

Thank you, I got it now.

Basically, the this keyword in formatter method no longer points to the class AppComponent itself. To still have a reference to the AppComponent.counterFlag, assign it to the variable in the chartSet method, and then use that variable.

DEMO: https://stackblitz.com/edit/highcharts- ... service.ts

Best regards!
Kamil Musiałowski
Highcharts Developer
eraka
Posts: 123
Joined: Thu Apr 28, 2022 6:55 am

Re: Getting point.dataLabel undefined at times

thanks for the demo, but unfortunately those points on select still not getting aligned.
kamil.m
Posts: 892
Joined: Thu May 19, 2022 1:33 pm

Re: Getting point.dataLabel undefined at times

Well, you asked for the counterFlag variable reference and I gave you the exact explanation of why it didn't work, as well as the demo showing how you can access it via console.log.

You didn't mention the points selection in the latest post, so if you are talking about the dataLabels alignment, the answer is still the same - it might be a bug, which you'll have to report on GitHub, or play around with the formatter a bit more.

So is there anything more I can help you with?
Regards!
Kamil Musiałowski
Highcharts Developer
eraka
Posts: 123
Joined: Thu Apr 28, 2022 6:55 am

Re: Getting point.dataLabel undefined at times

Hi
yes correct, thanks for that demo.

nothing as of now ...thank you !!
kamil.m
Posts: 892
Joined: Thu May 19, 2022 1:33 pm

Re: Getting point.dataLabel undefined at times

That's good to hear!

In case of any other questions, feel free to ask,
Regards!
Kamil Musiałowski
Highcharts Developer

Return to “Highcharts Gantt”