Answers for "how to make chart using js"

2

simple chart js

<script src="https://cdn.jsdelivr.net/npm/chart.js"></script>
<div>
  <canvas id="myChart"></canvas>
</div>
 
<script>
  const labels = [
  'January',
  'February',
  'March',
  'April',
  'May',
  'June',
];
const data = {
  labels: labels,
  datasets: [{
    label: 'My First dataset',
    backgroundColor: 'rgb(255, 99, 132)',
    borderColor: 'rgb(255, 99, 132)',
    data: [0, 10, 5, 2, 20, 30, 45],
  }]
};
  
  const config = {
  type: 'line',
  data: data,
  options: {}
};
  
  var myChart = new Chart(
    document.getElementById('myChart'),
    config
  );
</script>
Posted by: Guest on August-23-2021

Browse Popular Code Answers by Language