angular-chart.js
angular-chart.js copied to clipboard
Set global color broken
Hei
I have a problem while setting the color on global. According to the documentation I have to do someting like:
(function` (ChartJsProvider) {
ChartJsProvider.setOptions({ colors : [ '#803690', '#00ADF9', '#DCDCDC', '#46BFBD', '#FDB45C', '#949FB1', '#4D5360'] });
});
but this does not work.
As a workaround I can do:
(function (ChartJsProvider) {
ChartJsProvider.setOptions("global",{ colors : [ '#803690', '#00ADF9', '#DCDCDC', '#46BFBD', '#FDB45C', '#949FB1', '#4D5360'] });
})
or
(function (ChartJsProvider) {
ChartJsProvider.setOptions({global: { colors : [ '#803690', '#00ADF9', '#DCDCDC', '#46BFBD', '#FDB45C', '#949FB1', '#4D5360'] }});
})
**This would fix the problem**
/**
* Allow to set global options during configuration
*/
this.setOptions = function (type, customOptions) {
// If no type was specified set option for the global object
if (! customOptions) {
_customOptions = {
"global": type;
}
options = angular.merge(options, customOptions);
} else {
// Set options for the specific chart
options[type] = angular.merge(options[type] || {}, customOptions);
}
angular.merge(ChartJs.Chart.defaults, options);
};
Thanks for reporting the issue. I confirmed that this is indeed an issue and will fix soon.
Hello,
Is there a particular version we can go back to before this issue is resolved ?
I'm running the following versions.
"chart.js": "2.3.0",
"angular-chart.js": "1.0.3"
I'm running into the problem that the global colors are not changing according to my object:
Chart.defaults.global.colors = [{ // blue fillColor: 'rgb(0,0,0)', strokeColor: 'rgba(0,94,184,1)', pointColor: 'rgba(0,94,184,1)', pointStrokeColor: '#fff', pointHighlightFill: '#fff', pointHighlightStroke: 'rgba(0,94,184,0.8)' }, { // cherry fillColor: 'rgb(0,0,0)', strokeColor: 'rgba(206,0,88,1)', pointColor: 'rgba(206,0,88,1)', pointStrokeColor: '#fff', pointHighlightFill: '#fff', pointHighlightStroke: 'rgba(206,0,88,0.8)' }, { // light blue fillColor: 'rgb(0,0,0)', strokeColor: 'rgba(0,169,224,1)', pointColor: 'rgba(0,169,224,1)', pointStrokeColor: '#fff', pointHighlightFill: '#fff', pointHighlightStroke: 'rgba(0,169,224,0.8)' }, { // purple fillColor: 'rgb(0,0,0)', strokeColor: 'rgba(112,48,160,1)', pointColor: 'rgba(112,48,160,1)', pointStrokeColor: '#fff', pointHighlightFill: '#fff', pointHighlightStroke: 'rgba(112,48,160,0.8)' }, { // yellow fillColor: 'rgb(0,0,0)', strokeColor: 'rgba(210,159,19,1)', pointColor: 'rgba(210,159,19,1)', pointStrokeColor: '#fff', pointHighlightFill: '#fff', pointHighlightStroke: 'rgba(210,159,19,0.8)' }, { // light grey fillColor: 'rgb(0,0,0)', strokeColor: 'rgba(215,210,203,1)', pointColor: 'rgba(215,210,203,1)', pointStrokeColor: '#fff', pointHighlightFill: '#fff', pointHighlightStroke: 'rgba(215,210,203,0.8)' }, { // dark blue fillColor: 'rgb(0,0,0)', strokeColor: 'rgba(0,56,110,1)', pointColor: 'rgba(0,56,110,1)', pointStrokeColor: '#fff', pointHighlightFill: '#fff', pointHighlightStroke: 'rgba(0,56,110,1)' } ];
I've tried alternatively throwing the following in an angular.module('app').config block, : ChartJsProvider.setOptions("global", { colors: Chart.defaults.global.colors });
Any help is greatly appreciated!
thanks !
The original comment showed a workaround that should work:
(function (ChartJsProvider) {
ChartJsProvider.setOptions("global",{ colors : [ '#803690', '#00ADF9', '#DCDCDC', '#46BFBD', '#FDB45C', '#949FB1', '#4D5360'] });
})
for me specifying chartColors instead of colors worked,
.config(function(ChartJsProvider) {
ChartJsProvider.setOptions({ chartColors : [ '#536DFE', '#536DFE', '#536DFE', '#46BFBD', '#FDB45C',
'#949FB1', '#4D5360'] });
})