Chart JS Line Example

by Vikash Kumar Gupta

HTML

<script src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/2.5.0/Chart.min.js"></script>
<div class="myChartDiv" style="height:500px">
  <canvas id="myChart" width="600" height="300"></canvas>
</div>

JavaScript

var ctx = document.getElementById("myChart");
var myChart = new Chart(ctx, {
    type: 'line',
    data: {
        labels: ["Label1", "Label2", "Label3"],
        datasets: [{
            label: 'legend1',
            data: [12, 19, 3],
            borderDash: [10,5],
            borderDashOffset: 20
        },{
            label: 'legend2',
            data: [22, 9, 13],
          
        }]
      
    },
    options: {
        scales: {
            yAxes: [{
                ticks: {
                    beginAtZero:true
                }
            }]
        }
    }
});