Chartjs-Ng-chart.js – First data set always has color gray

1πŸ‘

βœ…

With this

$scope.colours = [{
  fillColor:"rgba(220,220,220,0.4)",
  strokeColor:"rgba(220,220,220,0.2)",
  highlightFill:"rgba(220,220,220,0.5)",
  highlightStroke:"rgba(220,220,220,0.1)"
}];

you are passing angular-chart one colorset. Since your have 2 datasets in your chart, angular-chart will use this colorset (i.e. gray) for the 1st dataset and for the 2nd dataset it will generate a random colour.

If you want random (randomized at each redraw) colours for both datasets do this

$scope.colours = [];

If you want fixed colours for both, pass it an array of 2 colorsets (instead of 1). If you want to use the global default, just set it to null

$scope.colours = null;

Leave a comment