[SOLVED] Chart : tooltips callbacks ignored ?

UI Components for Vue
Post Reply
Nacros79
Posts: 18
Joined: 19 Apr 2022, 14:26

07 Jul 2022, 10:32

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'
                        },
                    }
                }
            }
Last edited by Nacros79 on 26 Jul 2022, 14:59, edited 1 time in total.
---------------------------------------------------
Nacros
I'm french, sorry for my bad english :)

tugce.kucukoglu
Posts: 560
Joined: 23 Oct 2020, 09:28

26 Jul 2022, 13:20

Hi,

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

Nacros79
Posts: 18
Joined: 19 Apr 2022, 14:26

26 Jul 2022, 14:57

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.
---------------------------------------------------
Nacros
I'm french, sorry for my bad english :)

tugce.kucukoglu
Posts: 560
Joined: 23 Oct 2020, 09:28

26 Jul 2022, 16:18

Hi,

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

Post Reply

Return to “PrimeVue”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 8 guests