ChartJS Tooltip callback function does not work.

Asked 1 years ago, Updated 1 years ago, 121 views

We use ChartJS to display bar graphs.
I defined callbacks in the tooltips property to edit the contents of the tooltips, but
The tooltip does not change the contents.Do you know the cause?

▼ Execution Environment
Operating System: Windows 10 browsers:Chrome 90.0.4430.93
ChartJS:ver 2.8

varctx= document.getElementById("myChart");
    
varbarChartData={
        labels: ["January", "February", "March", "April", "May", "June", "July",
        datasets: [{
            type: 'bar',
            label: "Sales",
            data: [4000, 4850, 5900, 6210, 2500, 4000, 6500],
            backgroundColor: 'rgba(0,0,255,0.3)'
        } ]
    };

var myChart = new Chart(ctx,
    {
        type: 'bar',
        data —barChartData,
        options: {
            tooltips:
                callbacks: {
                    title:function(){
                        return 'Test Title';
                    }
                }

            }
        }
    });
<script crossorigin 
 src="https://unpkg.com/[email protected]/dist/Chart.min.js">/script>

<canvasid="myChart" width="400" height="400"></canvas>

Enter a description of the image here

javascript html5-canvas chart.js

2022-09-29 22:14

1 Answers

After clearing the browser cache and reloading the page, it was reflected.


2022-09-29 22:14

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.