Page 1 of 1

[SOLVED] Chart : tooltips callbacks ignored ?

Posted: 07 Jul 2022, 10:32
by Nacros79
Hi,

I'm trying to add a percent character at the end of labels in my chart tooltip.
It works well with pure chart.js like in this fiddle : https://codepen.io/apertureless/pen/BZKBdX

But if i use it in my options for primevue compoentn, it's just ignored. Nothing in the console, no change on my tooltip (see option below).

Is PrimeVue chart handle plugin / tooltips / callbacks ? I can't find any example in documentation nor in the theme I've buy (Atlantis)

Code: Select all

            barOptions: {
                interaction: {
                    intersect: false,
                    mode: 'index',
                },
                plugins: {
                    tooltips: {
                        mode: 'index',
                        intersect: false,
                        callbacks: {
                            label: ((tooltipItem, data) => {
                                console.log(this)
                                return data['labels'][tooltipItem['index']] + ': ' + data['datasets'][0]['data'][tooltipItem['index']] + '%'
                            }),
                        }
                    },
                    legend: {
                        labels: {
                            color: '#A0A7B5'
                        }
                    }
                },
                responsive: true,
                scales: {
                    x: {
                        stacked: true,
                        ticks: {
                            color: '#A0A7B5'
                        },
                    },
                    y: {
                        stacked: true,
                        ticks: {
                            color: '#A0A7B5'
                        },
                    }
                }
            }

Re: Chart : tooltips callbacks ignored ?

Posted: 26 Jul 2022, 13:20
by tugce.kucukoglu
Hi,

I've just tried a simple thing and it seems working. https://codesandbox.io/s/competent-brow ... ue:975-996

Re: Chart : tooltips callbacks ignored ?

Posted: 26 Jul 2022, 14:57
by Nacros79
Hi,

Thx for your answer, I made it works. The problem was I use "tooltips" (note the 's') instead of "tooltip" (without the 's')
However, all tooltip example in the PrimeVue documentation use 'tooltips'

With ChartJS 2.X, it's 'tooltips'
With ChartJS 3.X, it's 'tooltip'

You should update the PrimeVue documentation.

Re: [SOLVED] Chart : tooltips callbacks ignored ?

Posted: 26 Jul 2022, 16:18
by tugce.kucukoglu
Hi,

Thank you for your attention. I will fix them. Documentation seems out of date.