Hide x-axis labels but show tooltips in chart.js - Javascript Chart.js

Javascript examples for Chart.js:Chart Tooltip

Description

Hide x-axis labels but show tooltips in chart.js

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://rawgit.com/nnnick/Chart.js/v1.0.2/Chart.min.js"></script> 
      <script type="text/javascript">
    window.onload=function(){/*from   w ww  . j a  va 2  s  .c o  m*/
Chart.types.Line.extend({
  name: "LineAlt",
  initialize: function(data){
    var originalLabels = data.labels;
    data.labels = data.labels.map(function() { return '' });
    Chart.types.Line.prototype.initialize.apply(this, arguments);
    this.datasets[0].points.forEach(function(bar, i) {
      bar.label = originalLabels[i];
    });
  }
});
var data = {
    labels: ["JanuaryAAAAAAAAAAAAAAAAAAAAAAA", "February", "March", "April", "May", "June", "July"],
    datasets: [
        {
            label: "My First dataset",
            fillColor: "rgba(220,220,220,0.5)",
            strokeColor: "rgba(220,220,220,0.8)",
            highlightFill: "rgba(220,220,220,0.75)",
            highlightStroke: "rgba(220,220,220,1)",
            data: [65, 59, 80, 81, 56, 55, 40]
        }
    ]
};
var ctx = document.getElementById("myChart").getContext("2d");
var myBarChart = new Chart(ctx).LineAlt(data);
    }

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

Related Tutorials