I have added ng2-charts to my project and display 2 charts - donut & barchart. both are displayed in gray since I added
<base-chart class="chart" [colors]="chartColors" ... </base-chart>
to the component.template.html
, and
public chartColors:Array<any> =[ { fillColor:'rgba(225,10,24,0.2)', strokeColor:'rgba(11,255,20,1)', pointColor:'rgba(111,200,200,1)', pointStrokeColor:'#fff', pointHighlightFill:'#fff', pointHighlightStroke:'rgba(200,100,10,0.8)' }, ... (3x)
to the component.ts
.
Are any other package imports necessary to change the color or is the setup wrong?
Chromes html inspector shows the following html output rendered:
ng-reflect-colors="[object Object],[object Object],[object Object]"
To make changes in the chart color, go to the Format pane and select Data colors. You will see that blue is the default color. There are various options to change the color. You can select from the options, or click on Custom color to select a custom color as shown below.
We can use the borderColor property of the dataset to change the color of the line that exists in a line chart. You can assign a color to it in hex or RGBA format.
Also you can do it in this way:
<base-chart class="chart" [colors]="chartColors" ... </base-chart>
and
public chartColors: any[] = [ { backgroundColor:["#FF7360", "#6FC8CE", "#FAFFF2", "#FFFCC4", "#B9E8E0"] }];
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With