I am attempting to add tooltips to my chart, the options are correctly loading, however tooltips are not showing, any ideas?
<script>
var lineChartData = {
labels : ["January","February","March","April","May","June","July"],
datasets : [
{
fillColor : "rgba(139, 157, 195, 1)",
strokeColor : "#4c66a4",
pointColor : "#fff",
pointStrokeColor : "#3b5998",
pointHighlightFill: "#fff",
data : [{{implode(',', $fanCounts)}}]
}
]
}
var options = {
showTooltips: true,
tooltipEvents: ["mousemove", "touchstart", "touchmove"],
tooltipFillColor: "rgba(0,0,0,0.8)"
}
var myLine = new Chart(document.getElementById("fancanvas").getContext("2d")).Line(lineChartData, options);
</script>
I have also changed the chart.js global config to enable tooltips for line charts.
For anyone having problems with this using Chartjs v3, you need to make sure you have registered the Tooltip plugin:
import { Chart, Tooltip } from 'chart.js'
Chart.register([Tooltip])
var ctx = document.getElementById("canvas").getContext("2d");
window.myLine = new Chart(ctx).Line(lineChartData, {
responsive: true,
showTooltips: true,
multiTooltipTemplate: "<%= value %>",
});
use this (global settings)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With