PDA

View Full Version : Pie chart not reloading



ruchika
22 Jun 2009, 5:46 AM
Hi,
I am trying to refresh the pie chart based on the value selected by a combo box. The pie chart is working fine for the first time, but when i change the contents of the combo, the pie chart doesn't show up again. the store is getting refreshed, as I am able to see the legends with the new set of data.
Code for the combo with a submit button:
var groupStore = new Ext.data.JsonStore({
url: '/ext/testServlet',
root: 'userGroups.data',
id: 'userGroupId',
fields: ['userGroupId', 'userGroupName'],
baseParams: {'action': 'listGroups'}
});

var combo = new Ext.form.ComboBox({
store: groupStore,
displayField:'userGroupName',
valueField: 'userGroupId',
typeAhead: true,
triggerAction: 'all',
emptyText:'Select a group...',
selectOnFocus:true,
renderTo: 'content',
width: 250,
mode: 'local',
height: 0,
fieldLabel: 'GROUPList'
});

groupStore.load();

new Ext.Button({
text: 'Submit',
renderTo: 'chtButton',
handler: function() {
fetchDb=true;
var combovalue = combo.getValue();
var seccombo = secCombo.getValue();
LoadAndShow(combovalue,seccombo);
}
});
function LoadAndShow(combovalue,seccombo){

firstchartstore.on('load', loadChartSuccessful);
var urlStr = '/ext/testServlet?action=listTrades&fetchfromDb='+fetchDb+'&workgroupId='+combovalue
Ext.Ajax.request({
url: urlStr,
success: function(response) {
var data = splitResponse( response);
firstchartstore.loadData(data);

fetchDb = false;
}
});

}
function loadChartSuccessful(store, recordArray, options) {
exchangeChart.render(document.getElementById('exchChart'));
} The code for the chart and the store is:
var firstchartstore = new Ext.data.Store({
reader: new Ext.data.JsonReader({
root: 'firstchart.chartData',
totalProperty:'firstchart.totalProperty'
}, Ext.data.Record.create([
{name: 'key'},
{name: 'value'}
])
)
});

var exchangeChart = new Ext.Panel({
title: 'Pie chart ',
width:500,
height: 300,
layout: 'fit',
frame:true,
//hideMode: 'offsets',
items: {
xtype: 'piechart',
store: firstchartstore,
categoryField: 'key',
dataField: 'value',
series: [{
type: 'pie',
displayName: 'Total '
}],
chartStyle: {
legend: {
display: 'right'
}
}

},
url: '../../resources/charts.swf?nocache=' + Math.floor(Math.random()*10000)
//url: '../../resources/charts.swf?_dc='+new Date().getTime()
}); i have even tried the cache buster, but not able to render the chart once the combo value changes.

aconran
23 Jun 2009, 9:18 AM
There are a number of fixes related to Charts in SVN. These will be released with Ext 3.0 RC2.1.