How can I access the vue component instance inside callback of options.tooltips?
See original GitHub issueFirst of all, Thank You for this wonderful package 😍 . This package made my day ❤️ .
I’m in a situation where I need to construct the tooltip data using props. So I have used tooltips.callbacks.label
option referred from docs.
Inside the label: function(tooltipItem,data){}
I need to use props passed from the parent component, but what I’m getting is tooltip instance for this
(As per the docs).
Is there any way to get VueComponet instance inside that function? Thanks in Advance 😃
Environment
- vue.js version:
^2.5.16
- vue-chart.js version:
^3.4.0
- npm version:
6.4.1
Issue Analytics
- State:
- Created 5 years ago
- Comments:9 (4 by maintainers)
Top Results From Across the Web
javascript - Reference prop from callback - Stack Overflow
I am trying to reference the vue props inside ...
Read more >Tooltip | Components - BootstrapVue
A function (callback) that returns a reference to an HTMLElement or SVGElement. For more information on references, see the official Vue documentation. Note:....
Read more >Tooltip Component - ag-Grid (Vue)
The example below demonstrates how to provide custom tooltips to the grid. Notice the following: The Custom Tooltip Component is supplied by name...
Read more >Access component vm inside of non-arrow function - Laracasts
I am currently working with VueJS and HighchartsJS and running into a bit of a this issue. Whenever Highcharts provides a callback in...
Read more >Vue Tooltip | Popover Component - Syncfusion
Automatically adjust display position based on view page without inconsistent. · Customize the content with icons, images, or dynamic AJAX template and much...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
¯_(ツ)_/¯
Just like I said:
https://codepen.io/apertureless/pen/BZKBdX
Instead of
use
Well, this has nothing to to with either chart.js or vue-chartjs. Thats Javascript basics.
this
in callbacks always refers to the method that calls the callback. In this casethis
will refer to the window object / chartjs object and not to the vue compontent prototype.There are enough resources and tutorials on how to handle
this
in callbacks.The easiest way is to use arrow functions or
.bind(this)
. So put your options in a computed property and use arrow functions and you should be fine.