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>
After clearing the browser cache and reloading the page, it was reflected.
© 2024 OneMinuteCode. All rights reserved.