[Chartjs]-Chart.js coming up as blank

2👍

Please assign data key in config to assign chartdata

const labels = [
  'January',
  'February',
  'March',
  'April',
  'May',
  'June',
];
const chartData = {
  labels: labels,
  datasets: [{
    label: 'My First dataset',
    
    data: [0, 10, 5, 2, 20, 30, 45],
  }]
};

const config = {
  type: 'line',
  data: chartData,
  options: {}
};


var myChart = new Chart(
  document.getElementById('myChart'),
  config
);
<script src="https://cdn.jsdelivr.net/npm/chart.js"></script>
<div class="container">
  <div>
    <canvas id="myChart" width="200" height="200"></canvas>
  </div>
</div>

Leave a comment