klhebs
Posts: 16
Joined: Thu Apr 01, 2021 8:24 am

acess vue component on tooltip.pointFormatter

hi , I am having trouble to get the translation (i18n) which used like this.$t('somestring') on the pointformatter. I tried to use arrow function like but the console log of the point are some string, it is possible to access to vue componment data within the pointFormatter? thanks!

Code: Select all

tooltip:{
                pointFormatter:({point})=>{ 
                		return `<strong>${this.$t('price')}:</strong>`+point.y+'<br>'

                    }
       }
dominik.c
Posts: 2081
Joined: Fri Aug 07, 2020 7:07 am

Re: acess vue component on tooltip.pointFormatter

Hello klhebs!

Welcome to our forum and thanks for contacting us with your question!

Maybe you need to save it differently to get the data. Check out this demo: https://codesandbox.io/s/highcharts-vue ... /Chart.vue

If it doesn't help, please reproduce your issue in an online editor.

Best regards!
Dominik Chudy
Highcharts Developer
klhebs
Posts: 16
Joined: Thu Apr 01, 2021 8:24 am

Re: acess vue component on tooltip.pointFormatter

dominik.c wrote: Fri Apr 09, 2021 8:37 am Hello klhebs!

Welcome to our forum and thanks for contacting us with your question!

Maybe you need to save it differently to get the data. Check out this demo: https://codesandbox.io/s/highcharts-vue ... /Chart.vue

If it doesn't help, please reproduce your issue in an online editor.

Best regards!

hi , here is the issue https://codesandbox.io/s/highcharts-vue ... /Chart.vue

if I used arrow function to get the translate message from data, I don't know how to get the point when mouse hover to the point
dominik.c
Posts: 2081
Joined: Fri Aug 07, 2020 7:07 am

Re: acess vue component on tooltip.pointFormatter

Hi again!

Basically, the best option would be to replace the arrow function with the basic one, thanks to that we've got proper point context inside the function. We also need to add a variable inside data function that will store the context of the component.

Demo: https://codesandbox.io/s/highcharts-vue ... rked-51luy

Best regards!
Dominik Chudy
Highcharts Developer
klhebs
Posts: 16
Joined: Thu Apr 01, 2021 8:24 am

Re: acess vue component on tooltip.pointFormatter

Thanks! That's solve my problem, thanks for the reply!
dominik.c
Posts: 2081
Joined: Fri Aug 07, 2020 7:07 am

Re: acess vue component on tooltip.pointFormatter

You're welcome!

In case of any further questions, feel free to contact us again.
Dominik Chudy
Highcharts Developer

Return to “Highcharts Stock”