[Chartjs]-How do you set pie chart colors in angular-chart.js

1👍

Your JS:

$scope.colours = ["rgba(224, 108, 112, 1)",
            "rgba(224, 108, 112, 1)",
            "rgba(224, 108, 112, 1)"]

Your directive Markup:

<canvas id="pie" class="chart chart-pie" chart-colours="colours"></canvas>

The docs say you can override default colors by setting the array :

Chart.defaults.global.colours

0👍

For version 1.x
There are two ways either object instances or simple RGBA values as string:

colors = ["rgba(159,204,0,0.5)","rgba(250,109,33,0.7)","rgba(154,154,154,0.5)"];

colors = [
        {
            backgroundColor: "rgba(159,204,0, 0.2)",
            pointBackgroundColor: "rgba(159,204,0, 1)",
            pointHoverBackgroundColor: "rgba(159,204,0, 0.8)",
            borderColor: "rgba(159,204,0, 1)",
            pointBorderColor: '#fff',
            pointHoverBorderColor: "rgba(159,204,0, 1)"
        },"rgba(250,109,33,0.5)","#9a9a9a","rgb(233,177,69)"
    ];

View:

      <canvas id="doughnut"
              class="chart chart-doughnut"
              chart-data="$ctrl.piChartData"
              chart-labels="$ctrl.labels"
              chart-options="$ctrl.options"
              chart-colors="$ctrl.colors"
      >
      </canvas>

That’s worked for me as mentioned in their docs.

Docs Link

Leave a comment