Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Chart.js tooltip not showing

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.

like image 936
djbberko Avatar asked Jul 21 '14 14:07

djbberko


2 Answers

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])
like image 125
Jesper Paulsen Avatar answered Oct 12 '22 06:10

Jesper Paulsen


var ctx = document.getElementById("canvas").getContext("2d");
    window.myLine = new Chart(ctx).Line(lineChartData, {
        responsive: true,
        showTooltips: true,
        multiTooltipTemplate: "<%= value %>",
    });

use this (global settings)

like image 45
Arun Yokesh Avatar answered Oct 12 '22 06:10

Arun Yokesh