Skip to content

Commit

Permalink
Better chinmaymk#66 fix according to 8361419 comment
Browse files Browse the repository at this point in the history
Resetting config.colors array on every call at prepareData with:
[?acConfig.colors, defaultColors]
  • Loading branch information
soyuka committed Jun 22, 2014
1 parent 8361419 commit eba1c23
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion src/angular-charts.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ angular.module('angularCharts').directive('acChart', function($templateCache, $c
"padding:5px;",
"color:#fff;"].join('');

var defaultColors = ['steelBlue', 'rgb(255,153,0)', 'rgb(220,57,18)', 'rgb(70,132,238)', 'rgb(73,66,204)', 'rgb(0,128,0)'];

/**
* Utility function to call when we run out of colors!
* @return {String} Hexadecimal color
Expand Down Expand Up @@ -77,7 +79,7 @@ angular.module('angularCharts').directive('acChart', function($templateCache, $c
//could be 'left, right'
position: 'left'
},
colors: ['steelBlue', 'rgb(255,153,0)', 'rgb(220,57,18)', 'rgb(70,132,238)', 'rgb(73,66,204)', 'rgb(0,128,0)'],
colors: [],
innerRadius: 0, // Only on pie Charts
lineLegend: 'lineEnd', // Only on line Charts
lineCurveType: 'cardinal',
Expand Down Expand Up @@ -167,9 +169,22 @@ angular.module('angularCharts').directive('acChart', function($templateCache, $c
chartType = scope.acChart;
series = (data) ? data.series || [] : [];
points = (data) ? data.data || [] : [];

if(scope.acConfig) {

var arr = [];

if(scope.acConfig.colors) {
;[].push.apply(arr, scope.acConfig.colors);
}

;[].push.apply(arr, defaultColors);

angular.extend(config, scope.acConfig);
config.colors = arr;

}

}

/**
Expand Down

0 comments on commit eba1c23

Please sign in to comment.