[Chartjs]-Change color of Polar Area datasets in Angular

1πŸ‘

βœ…

I think I found the answer.

Let’s say I want to represent 2 datasets (just for the example).

  public polarAreaChartData: number[] = [
    98, 82
  ];
  // Reasons
  public polarAreaChartLabels: string[] = [
    'Reason A',
    'Reason B'
  ];
  public polarAreaChartOptions: any = {
    responsive: true,
    legend: {
      display: false
    }
  };
  public polarAreaChartColors: Array<any> = [
    {
      backgroundColor: [
        '#2e67bf',
        '#7f8fa4'
      ],
    }
  ];

Apparently, I was adding less than 5 colors, and it was causing a problem, since I had 5 values and 5 labels. When I’ve tested with 2 + 2 + 2 (value, label + options) the colors have changed.

I will test for a longer dataset, but i think it was my mistake. Thank you anyway πŸ™‚

Leave a comment