Chartjs - make line position to vertical center and how to display dotted sharp in the background? - Javascript Chart.js

Javascript examples for Chart.js:Line Chart

Description

Chartjs - make line position to vertical center and how to display dotted sharp in the background?

Demo Code

ResultView the demo in separate window

<html lang="en">
   <head> 
      <style>

.myChartDiv {//from   w w w  . ja va  2 s  . c  om
   max-width: 600px;
   max-height: 400px;
}


      </style> 
   </head> 
   <body translate="no">   
      <div class="myChartDiv"> 
         <canvas id="myChart" width="600" height="400"></canvas> 
      </div>   
      <script src="https://npmcdn.com/chart.js@latest/dist/Chart.bundle.min.js"></script> 
      <script>
      var ctx = document.getElementById("myChart");
var myChart = new Chart(ctx, {
  type: 'line',
  data: {
    labels: ["1", "2", "3","4", "5", "6"],
    datasets: [{
      label: '# of Votes',
      data: [12, 19,12, 19, 3, 3],
    }]
  },
  options: {
    scaleLineColor: "red",
    scales: {
      xAxes: [{
        gridLines: {
          display: true,
          lineWidth: 1,
          borderDash: [1, 2],
          color: "black"
        }
      }],
      yAxes: [{
        gridLines: {
          display: true,
          lineWidth: 1,
          borderDash: [1, 2],
          color: "black"
        }
      }],
    }
  }
});
      //# sourceURL=pen.js
    
      </script>  
   </body>
</html>

Related Tutorials