In ChartJS to change the line style between different points - Javascript Chart.js

Javascript examples for Chart.js:Line Chart

Description

In ChartJS to change the line style between different points

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.2.2/Chart.min.js"></script> 
      <script type="text/javascript">
    window.onload=function(){/*from ww w  .  j  a  va 2  s  .c o  m*/
var lineChartData = {
    labels: ['1', '2', '3', '4', '5', '6'],
    datasets: [{
        label: "My First dataset - dotted",
        data: [12, 19, 3, 5, 2, 3],
        borderDash: [5, 5],
        borderWidth: 1,
        borderColor: '#922893',
        pointBorderColor: '#922893',
        pointBackgroundColor: "transparent"
    },{
        label: "My First dataset",
        data: [12, 19, 3, 5, 2, ],
        borderWidth: 1,
        borderColor: '#922893',
        pointBorderColor: '#922893',
        pointBackgroundColor: "transparent"
    }]
};
var ctx = document.getElementById("chart").getContext("2d");
var lineChart = new Chart(ctx, {
    type: "line",
    data: lineChartData,
    options: {
       legend: {
           display: false
        },
        scales: {
           yAxes: [{
               ticks : {
                   beginAtZero: true
                }
              }]
        },
        elements: {
            line: {
                fill: false,
                tension: 0
            }
        }
    }
});
    }

      </script> 
   </head> 
   <body> 
      <canvas id="chart" height="100"></canvas>  
   </body>
</html>

Related Tutorials