PDA

View Full Version : Bar Chart Colors Without Theme



Supial
7 Mar 2012, 9:24 PM
Greetings,
I was wondering if it is possible to create a bar chart with custom colors, without the use of a theme? I am able to do this with a Pie chart via the Series colorSet parameter, but the Bar chart doesn't expose anything to specify colors.

Is Theming the only way Ext has implemented chart color definitions for Bar chart? If so, why do other charts support other means?

Thanks.
Marcel

mitchellsimoens
8 Mar 2012, 4:35 PM
This is what the theme is for.

Supial
9 Mar 2012, 6:20 PM
Agreed, however it is my chart extension that will define/extend the base chart theme. If this is done in the initializeComponent method, I get an error.
Object doesn't support property or method 'renderer'

Here is an example:


Ext.define('myChartPanel', {
extend: 'Ext.chart.Chart',
alias: 'widget.uichartpanel',

chartColors: [],

initComponent: function() {
var me = this;
Ext.define('myTestTheme', {
extend:'Ext.chart.theme.base',
constructor: function(config) {
this.callParent([Ext.apply({
colors: me.chartColors
}, config)]);
}
});
me.callParent();
}
}



And then the component is created as such:


{
xtype: 'uichartpanel',
chartColors: ['#568E14','#3F6075','#C9D6A3','#99D6DD','#A32638','#0DD590','#0F99BC'],
theme: 'myTestTheme',
...
}

If I comment out the "theme: 'myTestTheme', the chart renders properly, but using the default color scheme. So either this is a bug, or I need to be able to change the colors of the chart without a theme. Again, this can be done with the PieChart using the "colorSet" configuration on the Pie Series.

Thanks,
Marcel