Chartjs-Frontend and backend for chart using chartjs, mongodb, and controller

0👍

This happens because while making your chart you push each data point as a new dataset. Instead you just need to use a single dataset and pass the data array to it like so:

var myChart = new Chart(ctx, {
  type: 'bar',
  data: {
    labels: xLabels,
    datasets: [{
      borderColor: '#' + (0x1100000 + Math.random() * 0xffffff).toString(16).substr(1, 6),
      backgroundColor: "rgba(249, 238, 236, 0.74)",
      data: vData,
      spanGaps: true
    }]
  },
  options: {
    responsive: false
  }
});

Leave a comment