Set ticklines no grid in bar chart - Javascript Chart.js

Javascript examples for Chart.js:Bar Chart

Description

Set ticklines no grid in bar chart

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/2.1.6/Chart.min.js"></script> 
      <script type="text/javascript">
    window.onload=function(){//from  w w w. j ava 2 s . c o  m
/*************
   Usual chart generation from here
*************/
var data = {
  labels: ["January", "February", "March", "April", "May", "June"],
  datasets: [{
    backgroundColor: "rgba(20,50,125,0.5)",
    data: [40, 35, 50, 62, 37, 45],
  }]
};
var options = {
  elements: {
    rectangle: {
      borderWidth: 1,
      borderColor: 'rgba(0,0,0,1)',
    }
  },
  legend: {
    display: false
  },
  scales: {
    xAxes: [{
      ticks: {
        beginAtZero: true
      }
    }],
    yAxes: [{
      labelOffset: 20,
      gridLines: {
        display: true,
        drawOnChartArea: false,
        lineWidth: 1,
        color: "rgba(0,0,0,0.5)"
      },
      ticks: {
        beginAtZero: true,
        display: true,
        padding: 20
      }
    }]
  }
};
var ctx = document.getElementById("canvas").getContext("2d");
var myChart = new Chart(ctx, {
  type: 'bar',
  data: data,
  options: options
});
console.log(myChart);
    }

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

Related Tutorials