remove extra space and Horizontal line from Bar chart - Javascript Chart.js

Javascript examples for Chart.js:Bar Chart

Description

remove extra space and Horizontal line from 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.7.1/Chart.bundle.js"></script> 
      <style id="compiled-css" type="text/css">

#bar-canvas {//w w  w .j  av  a  2  s  . c o m
   background-color: yellow;
}


      </style> 
      <script type="text/javascript">
    window.onload=function(){
//Bar Chart
var bar = document.getElementById("bar-canvas");
var barChart = new Chart(bar, {
  type: 'bar',
  data: {
    labels: ["Jackets", "Pants", "Headwear", "Shirts", "Footwear"],
    datasets: [{
      label: 'Dataset 1',
      data: [12, 19, 3, 5, 2, 3],
      backgroundColor: [
        '#A7E3FF',
        '#A7E3FF',
        '#A7E3FF',
        '#A7E3FF',
        '#A7E3FF'
      ],
      borderColor: [
        '#A7E3FF',
        '#A7E3FF',
        '#A7E3FF',
        '#A7E3FF',
        '#A7E3FF'
      ],
      borderWidth: 1
    }, {
      label: 'Dataset 2',
      data: [20, 19, 10, 52, 2, 13],
      backgroundColor: [
        '#FD99EE',
        '#FD99EE',
        '#FD99EE',
        '#FD99EE',
        '#FD99EE'
      ],
      borderColor: [
        '#FD99EE',
        '#FD99EE',
        '#FD99EE',
        '#FD99EE',
        '#FD99EE'
      ],
      borderWidth: 1
    }]
  },
  responsive: true,
  options: {
    legend: {
      display: false
    },
    tooltips: {
      callbacks: {
        label: function(tooltipItem) {
          return tooltipItem.yLabel;
        }
      }
    },
    scales: {
      xAxes: [{
        stacked: true,
        gridLines: {
          display: false,
               color: "rgba(0, 0, 0, 0)"
        },
        ticks: {
               display: true, // removing this
          fontColor: '#0071bc',
        },
        scaleLabel: {
          display: false
        },
        barThickness: 110
      }],
      yAxes: [{
        stacked: true,
        gridLines: {
          color: "rgba(0, 0, 0, 0)",
          display: false,
        },
        scaleLabel: {
          display: false
        },
        ticks: {
          display: false,
        }
      }]
    }
  }
});
    }

      </script> 
   </head> 
   <body> 
      <canvas id="bar-canvas" width="100%" height="100%"></canvas>  
   </body>
</html>

Related Tutorials