Home > Software engineering >  Chart.js label callbacks are never called
Chart.js label callbacks are never called

Time:06-09

I'm working with Chart.js 3.8.0.

I'm trying to create custom tooltip text.

new Chart($('#truck-dwell'), {
    type: 'scatter',
    data: {
        datasets: [{
            label: 'Dwell Time (Minutes)',
            data: response,
            backgroundColor: Colors.Red,
        }],
    },
    options: {
        scales: {
            x: {
                type: 'linear',
                position: 'bottom'
            }
        },
        plugins: {
            tooltips: {
                callbacks: {
                    label: function(ctx) {
                        return 'Hello, World!';
                    }
                }
            }
        }
    }
});

Although I've found several sources say this is the newer, version 3 syntax, a breakpoint on my label function shows it is never called.

What am I missing?

CodePudding user response:

Your tooltips: property name is mislabelled it should be tooltip:.

  • Related