Chartjs-Failing to render chart – "can't acquire context from the given item"

0πŸ‘

βœ…

It seem your calling a new Chart() twice. Once on your chart Data randomcoin.js and also on your createChart(id, chartData) method. Try to change your chart Data to an object like this:

export const coinCharts = {
type: 'line',

data: {
  labels: ['January', 'February', 'March', 'April', 'May', 'June', 'July'],
  datasets: [{
    label: 'My First dataset',
    backgroundColor: 'rgb(255, 99, 132)',
    borderColor: 'rgb(255, 99, 132)',
    data: [0, 10, 5, 2, 20, 30, 45]
  }]
},

options: {
  responsive:true,
  lineTension:1
}
}

export default coinCharts;

This should solve your problem.

Leave a comment