I'm using Ext JS 5.1.
I have a very simple problem:
I have a pie chart, and a button. When I click on the button, I bind a new store to my chart. This works fine. But, if I make one element invisible in my chart (by clicking on one item in the legend) and bind a new store, the item at the same index of the new store will also be invisible. I don't want that. Is there any way to set everything visible for a chart ?
Here is the Sencha Fiddle to clearly explain my problem.
And the code if you're lazy!
Store A
var storeA = Ext.create('Ext.data.Store', {
fields: ['name', 'value'],
data: [
{"name": "A-0", "value": 18.34},
{"name": "A-1", "value": 2.67},
{"name": "A-2", "value": 1.90}
]
});
Store B
var storeB = Ext.create('Ext.data.Store', {
fields: ['name', 'value'],
data: [
{"name": "B-0", "value": 4.34},
{"name": "B-1", "value": 54.67},
{"name": "B-2", "value": 18.90}
]
});
Polar chart
var donut = Ext.create('Ext.chart.PolarChart', {
title: 'Test',
animation: true,
width: 300,
height: 300,
renderTo: Ext.getBody(),
store: storeA,
legend: {
docked: 'bottom'
},
series: [{
type: 'pie',
angleField: 'value',
colors: ["#9aff4f", "#35b4e3", "#ffb400"],
donut: 20,
label: {
field: 'name',
display: 'inside'
},
highlight: true
}]
});
Button - Swap stores
var button = Ext.create('Ext.Button', {
text: 'Click to change the pie store',
renderTo: Ext.getBody(),
margin: '10 10 10 63',
handler: function() {
if (donut.getStore() == storeA) {
donut.bindStore(storeB);
}
else {
donut.bindStore(storeA);
}
}
});
Ext.create('Ext.form.Label', {
html: '<br/><br/>To produce the bug:<br/><br/>' +
'1 - Make one item invisible by clicking on an item in the legend (A-0 for example).<br/>' +
'2 - Change the pie store by clicking on the blue button.<br/>' +
'3 - See with the new store the item at the same index is invisible. I don\'t want that to happen.<br/><br/>' +
'Is it possible to "enable" (make visible) every items of a pie chart?',
width: 300,
height: 300,
renderTo: Ext.getBody()
});