1

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],
      }]
  };
1
  • please share stackblitz link to know more in detail Commented Mar 12, 2021 at 21:31

1 Answer 1

2

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,
      }]
  };
Sign up to request clarification or add additional context in comments.

1 Comment

Despite a late reply, thank you for helping me

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.