ChartJS Line Chart

Multiple Line Chart

by michae1

HTML

<script src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/2.3.0/Chart.js"></script>
<body>
    <canvas id="chartJSContainer" width="600" height="400"></canvas>
</body>

CSS

canvas { background-color : #eee;
}

JavaScript

const generated = [];
const labels = [1,2,3,4,5,6,7];

for (let i = 0; i< 100; i++){
	
	generated.push({
        label: 'data' + i,
        borderColor: dynamicColors(),
        fill: false,
    data: Array.from({length: 40}, () => 																			Math.floor(Math.random() * 4000))
  })
}

function dynamicColors() {
    var r = Math.floor(Math.random() * 255);
    var g = Math.floor(Math.random() * 255);
    var b = Math.floor(Math.random() * 255);
    return "rgb(" + r + "," + g + "," + b + ")";
}

var options = {
  type: 'line',
  data: {
    labels: labels,
    datasets: generated
  },
  options: {
  elements: {
            line: {
                tension: 0, // disables bezier curves
            }
        },
  legend: {
            display: false
         },
  	scales: {
    	yAxes: [{
        ticks: {
					reverse: false
        }
      }]
    }
  }
}

var ctx = document.getElementById('chartJSContainer').getContext('2d');
new Chart(ctx, options);