Removing exceeding parts of axis in line chart - Javascript Chart.js

Javascript examples for Chart.js:Line Chart

Description

Removing exceeding parts of axis in line 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.2/Chart.min.js"></script> 
      <script type="text/javascript">
    window.onload=function(){/*from  ww  w . ja v  a 2  s. co  m*/
var ctx = document.getElementById("myChart");
var myChart = new Chart(ctx, {
  type: 'line',
  data: {
    labels: ["Red", "Blue", "Yellow", "Green", "Purple", "Orange"],
    datasets: [{
      label: '# of Votes',
      data: [12, 19, 3, 5, 2, 3],
        fill: false,
      borderColor: 'rgba(34, 91, 104, 0.75)'
    }]
  },
  options: {
    scales: {
      yAxes: [{
        gridLines: {
             display: false
          },
        ticks: {
          beginAtZero:true
        }
      }],
      xAxes: [{
        gridLines: {
             display: false
          },
         ticks: {
          beginAtZero:true
        }
      }]
    }
  }
});
    }

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

Related Tutorials