PDA

View Full Version : Change chart's theme dynamically



czrocklee
23 Jul 2012, 10:07 AM
Hi,

I know that i can pass the theme config when creating a Ext.chart.Chart, but how can i change the theme after it has been rendered? A little hack inspired me to try


chart.initTheme(newTheme);
chart.redraw();

But it doesn't work as it supposed to be, any suggestions?

Thanks!

scottmartin
23 Jul 2012, 11:30 AM
To change the theme:



var colors = ['rgb(47, 162, 223)',
'rgb(60, 133, 46)',
'rgb(234, 102, 17)',
'rgb(154, 176, 213)',
'rgb(40, 40, 40)'];

Ext.chart.theme.Browser = Ext.extend(Ext.chart.theme.Base, {
constructor: function(config) {
Ext.chart.theme.Base.prototype.constructor.call(this, Ext.apply({
colors: colors
}, config));
}
});

theme: 'Browser',
theme: 'Browser:gradients', // alternate call



Regards,
Scott.

czrocklee
23 Jul 2012, 6:25 PM
Thanks Scott, I think this can only set the theme when the chart was created, i'm wondering how to change it after rendered.

Regards.


To change the theme:



var colors = ['rgb(47, 162, 223)',
'rgb(60, 133, 46)',
'rgb(234, 102, 17)',
'rgb(154, 176, 213)',
'rgb(40, 40, 40)'];

Ext.chart.theme.Browser = Ext.extend(Ext.chart.theme.Base, {
constructor: function(config) {
Ext.chart.theme.Base.prototype.constructor.call(this, Ext.apply({
colors: colors
}, config));
}
});

theme: 'Browser',
theme: 'Browser:gradients', // alternate call



Regards,
Scott.

scottmartin
23 Jul 2012, 6:59 PM
This is not currently available.

Scott.