PDA

View Full Version : Problems with Chart in CardLayout - Please Help!!



omermx
9 Nov 2009, 3:53 AM
Hi, this is my second attempt to get help with a problem I'm having. I have a chart that is nested in a panel as part of a CardLayout. When switching between the panel with chart and others, the second time I try to go back to panel with chart, Firebug throws an error: this.swf.setDataProvider is not a function.

There is a previous thread (http://extjs.net/forum/showthread.php?t=76860) that identified this problem as a bug, that has been subsequently fixed? I believe the problem is caused by the fact that the onDestroy event was not removing the data store from the chart object.

So I modified ext-all.js with the following:



onDestroy: function(){
Ext.chart.Chart.superclass.onDestroy.call(this);
this.bindStore(null);
var tip = this.tipFnName;
if(!Ext.isEmpty(tip)){
delete window[tip];
}
}


The command to unbind the store is absent in the officially released version of extJS 3.0.0.

The change suppresses the error in firebug for the first couple of attempts. but eventually it is thrown again.

I'm sure there is only a subtle change required to fix this problem, my knowledge is limited.

Here is test case to reproduce the error in firebug:




Ext.chart.Chart.CHART_URL = '../../resources/charts.swf';

Ext.onReady(function(){

var store = new Ext.data.JsonStore({
fields:['name', 'visits', 'views'],
data: [
{name:'Jul 07', visits: 245000, views: 3000000},
{name:'Aug 07', visits: 240000, views: 3500000},
{name:'Sep 07', visits: 355000, views: 4000000},
{name:'Oct 07', visits: 375000, views: 4200000},
{name:'Nov 07', visits: 490000, views: 4500000},
{name:'Dec 07', visits: 495000, views: 5800000},
{name:'Jan 08', visits: 520000, views: 6000000},
{name:'Feb 08', visits: 620000, views: 7500000}
]
});

// extra extra simple
var window = new Ext.Window({
title: 'ExtJS.com Visits Trend, 2007/2008 (No styling)',
renderTo: 'container',
width:500,
height:300,
x: 100,
y: 100,
layout:'fit',
items: {
xtype: 'linechart',
store: store,
xField: 'name',
yField: 'visits',
listeners: {
itemclick: function(o){
var rec = store.getAt(o.index);
Ext.example.msg('Item Selected', 'You chose {0}.', rec.get('name'));
}
}
}
});
window.show();

new Ext.Button({
text: 'Press me after closing the window',
renderTo: 'container',
handler: function(b,e) {
store.removeAll();
}
});
});



This is really killing my project, so if you or someone you know can help fix this, it would be very much appreciated!!

Thanks,
Omer

Animal
9 Nov 2009, 4:33 AM
Yes, the code is fixed in SVN ready for the next release. But you can use your fix until then.

Don't modify ext-all-debug though. override the method.

Also, check whether you really need to destroy the chart.

omermx
12 Nov 2009, 6:06 AM
Thanks, btw if anyone else is experiencing this problem just paste this override into your code:



Ext.override(Ext.chart.Chart,{
onDestroy: function(){
Ext.chart.Chart.superclass.onDestroy.call(this);
this.bindStore(null);
var tip = this.tipFnName;
if(!Ext.isEmpty(tip)){
delete window[tip];
}
}
});

mzkr
15 Dec 2010, 9:07 AM
I am still getting error in IE7. How about following?



Ext.override(Ext.chart.Chart, {
onDestroy: function(){
Ext.chart.Chart.superclass.onDestroy.call(this);
this.bindStore(null);
var tip = this.tipFnName;
if (!Ext.isEmpty(tip)) {
if (Ext.isIE) {
window[tip] = undefined;
}
else {
delete window[tip];
}
}
}
});