Ng2-charts: Second chart colors are all grey!!

Created on 7 Aug 2017  路  3Comments  路  Source: valor-software/ng2-charts

I placed two doughnut chart.
First one has colors but second one's colors are all grey.
please check the screenshot.

untitled

here's code for this issue.

<div class="col-xs-12 col-md-6">
        <div class="col-xs-12 text-center"> Your answer </div>
        <canvas baseChart
            [data]="localValues"
            [labels]="names"
            [chartType]="'doughnut'"></canvas>
</div>
<div class="col-xs-12 col-md-6">
        <div class="col-xs-12 text-center"> Average answer </div>
        <canvas baseChart
            [data]="avgValues"
            [labels]="names"
            [chartType]="'doughnut'"></canvas>
</div> 

I tried with changing second chart's label variable, but not working.
why is this happening?

Most helpful comment

you have to use color option

HTML
<canvas baseChart [data]="avgValues" [labels]="names" [colors]="doughnutChartColors" [chartType]="'doughnut'"></canvas>

in .ts File
public doughnutChartColors: Array<any> = [ { backgroundColor: ['#01dd93', '#4ce7b3', '#99f1d3'], borderColor: 'transparent' } ];

All 3 comments

you have to use color option

HTML
<canvas baseChart [data]="avgValues" [labels]="names" [colors]="doughnutChartColors" [chartType]="'doughnut'"></canvas>

in .ts File
public doughnutChartColors: Array<any> = [ { backgroundColor: ['#01dd93', '#4ce7b3', '#99f1d3'], borderColor: 'transparent' } ];

See this stackblitz for an example: https://stackblitz.com/edit/ng2-charts-multiple-charts-aor8tt

Even that example when you press "Update" it only gets grey color, is there an option to put colors automatically?

Was this page helpful?
0 / 5 - 0 ratings

Related issues

sarn3792 picture sarn3792  路  4Comments

tssobe picture tssobe  路  4Comments

hggeorgiev picture hggeorgiev  路  4Comments

dslima90 picture dslima90  路  3Comments

shenriksen4 picture shenriksen4  路  3Comments