Dan
Dan

Reputation: 13

ChartJs error in displaying my array data

I have an error when I display my array with chartjs. its does not display my values ​​in the graph but its does display them as a label.

myChart

  var data  = {

      labels: [this.dataTime],
      datasets: [{
        label: 'Custom Label Name',
        backgroundColor: gradient,
        pointBackgroundColor: 'white',
        borderWidth: 1,
        borderColor: '#911215',
        data: [this.dataPrice],
      }]
  };

Upvotes: 1

Views: 268

Answers (1)

LeeLenalee
LeeLenalee

Reputation: 31361

Looking at your chart it's treating the labels als multiline since it's an array in an array.

If you remove the array brackets around the labels variable and the array brackets around the data variable it should work.

So you would get:

var data  = {
      labels: this.dataTime,
      datasets: [{
        label: 'Custom Label Name',
        backgroundColor: gradient,
        pointBackgroundColor: 'white',
        borderWidth: 1,
        borderColor: '#911215',
        data: this.dataPrice,
      }]
  };

Upvotes: 2

Related Questions