Hide labels on x-axis ChartJS - Javascript Chart.js

Javascript examples for Chart.js:Axis

Description

Hide labels on x-axis ChartJS

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(){/*  ww  w. j  a  va 2  s .c o m*/
Chart.types.Bar.extend({
  name: "BarAlt",
  initialize: function(data){
    var originalLabels = data.labels;
    data.labels = data.labels.map(function() { return '' });
    Chart.types.Bar.prototype.initialize.apply(this, arguments);
    this.datasets[0].bars.forEach(function(bar, i) {
      bar.label = originalLabels[i];
    });
    var xLabels = this.scale.xLabels;
    for (var i = 0; i < xLabels.length; i++)
      xLabels[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).BarAlt(data);
    }

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

Related Tutorials