You found a bug! We've classified it as
CHARTS-214
.
We encourage you to continue the discussion and to find an acceptable workaround while we work on a permanent fix.
-
Sencha User
Sure, I agree. It is just a work around for anyone struggling with it at the moment.
-
Sencha User
Same problem. I did kind of UI fix that works for me:
Code:
'load' : function() {
var visiblity = 'visible';
if (this.getCount() == 0) {
visiblity = 'hidden';
}
Ext.getCmp('adtypes-pie').getEl().setStyle({visibility : visiblity});
}
-
Sencha User
A side effect of keeping items in the chart visible when the store is cleared is invalid store references in records. Consider the following example:
Code:
Ext.onReady(function() {
Ext.create("Ext.window.Window", {
width:500,
height:500,
layout:"fit",
items:[
{
xtype:"chart",
store:{
proxy:{
type:"memory",
reader:{
type:"json"
}
},
model:Ext.define("MyModel", {
extend:"Ext.data.Model",
fields:[
"x",
"y"
]
}) && "MyModel",
data:[
{
x:1,
y:2
},
{
x:2,
y:5
}
]
},
axes:[
{
type:"Numeric",
position:"bottom",
fields:["x"]
},
{
type:"Numeric",
position:"left",
fields:["y"]
}
],
series:[
{
type:"bar",
axis:"bottom",
xField:"x",
yField:"y",
tips:{
renderer:function(inRecord) {
alert(inRecord.store.getCount());
}
}
}
],
listeners:{
afterrender:function() {
var me = this;
setTimeout(function() {
me.store.removeAll();
}, 5000);
}
}
}
]
}).show();
});
After 5 seconds, the data in the store is removed, but the bars still show up. The series tip renderer expects the record it's passed to contain a reference to the store that contains the record, but that reference is unset when the data was removed. Now the only way to get the store from the parameter passed is to look at the item.series.chart.store
-
Sencha User
This seems to be fixed for bar charts in 4.1, but pie charts still intermittently remain when there's no data - the legend disappears and the pie segments no longer move on mouse-over, but the chart itself still doesn't update. Seems to happen about 1 time in 3 or 4. Any news on this?