Hide/disable tooltips - Javascript Chart.js

Javascript examples for Chart.js:Chart Tooltip

Description

Hide/disable tooltips

Demo Code

ResultView the demo in separate window

<html>
   <head> 
      <meta name="viewport" content="width=device-width, initial-scale=1"> 
      <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/1.0.2/Chart.min.js"></script> 
      <script type="text/javascript">
    window.onload=function(){//from   w w  w. j  av  a 2  s . c o  m
var data = {
    labels: ["JAN", "FEB", "MAR", "APR", "MAY", "JUN", "JUL", "AUG", "SEP", "OCT", "NOV", "DEC"],
    datasets: [{
        data: [10, 20, 10, 10, 40, 50, 70, 70, 80, 90, 90, 90]
    }]
};
var ctx = document.getElementById("LineWithLine").getContext("2d");
Chart.defaults.global.responsive = true;
Chart.defaults.global.showTooltips = false;
Chart.types.Line.extend({
    name: "LineWithLine",
    draw: function () {
        Chart.types.Line.prototype.draw.apply(this, arguments);
        var point = this.datasets[0].points[this.options.lineAtIndex]
        var scale = this.scale
        // draw line
        this.chart.ctx.beginPath();
        this.chart.ctx.moveTo(point.x, scale.startPoint + 24);
        this.chart.ctx.strokeStyle = '#ff0000';
        this.chart.ctx.setLineDash([1]);
        this.chart.ctx.lineTo(point.x, scale.endPoint);
        this.chart.ctx.stroke();
        // write TODAY
        this.chart.ctx.textAlign = 'center';
        this.chart.ctx.font="12px Arial";
        this.chart.ctx.fillText("INTEGRATION", point.x, scale.startPoint + 12);
    }
});
new Chart(ctx).LineWithLine(data, {
    datasetFill : false,
    bezierCurve: false,
    lineAtIndex: 3,
    scaleOverride:true,
    scaleSteps:10,
    scaleStartValue:0,
    scaleStepWidth:10,
    scaleLabel: function (valuePayload) {
    return Number(valuePayload.value).toFixed(0).replace('.',',') + '%';
}
});
    }

      </script> 
   </head> 
   <body> 
      <canvas id="LineWithLine" width="600" height="400"></canvas>  
   </body>
</html>

Related Tutorials