I use Angular-Chart.js (the AngularJS Chart.js version) to create a bar chart. The Chart is working with the options except for the colours.
Even if I set them it is indicated in the documentation, they stay grey.
<div class="graph-display" ng-controller="chartController">
<canvas class="chart chart-bar"
data="bilans.data"
labels="bilans.labels"
series="bilans.series"
options="{
scaleShowHorizontalLines: true,
scaleShowVerticalLines: false,
tooltipTemplate: '<%= value %> $',
responsive: true
}"
colours="{
fillColor: 'rgba(47, 132, 71, 0.8)',
strokeColor: 'rgba(47, 132, 71, 0.8)',
highlightFill: 'rgba(47, 132, 71, 0.8)',
highlightStroke: 'rgba(47, 132, 71, 0.8)'
}"
></canvas>
</div>
Actually, the options are working but the colours are not. Am I doing something wrong?
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.
It allows us to create responsive bar charts, pie charts, line plots, donut charts, scatter plots, and other graphs. Simply select where on your page you want a graph to appear, what type of graph you want to plot, and then provide data, labels, and other options to Chart js.
Your should declare colours
object as an array
"colours": [{
fillColor: 'rgba(47, 132, 71, 0.8)',
strokeColor: 'rgba(47, 132, 71, 0.8)',
highlightFill: 'rgba(47, 132, 71, 0.8)',
highlightStroke: 'rgba(47, 132, 71, 0.8)'
}];
Working Plunkr
For more info refer this post / this too.
For newer versions, see eli0tt's answer, as the parameter names have changed.
I was having the same difficulty. In the docs it says to use "colors" however once I updated my html to:
chart-colours
with an angular array of:
$scope.colours = ['#72C02C', '#3498DB', '#717984', '#F1C40F'];
It worked!
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