PDA

View Full Version : piechart - Refresh data issue - bug?



benny
19 Aug 2009, 3:05 AM
I cannot get a piechart to reload new data and do a refresh...

I've found a couple of posts regarding this a few months back - the conclusion was that fixes would be in 3.0 RC 2.1. This may be fixed and I'm just doing something wrong, or there may still be outstanding issues.


Some code:


var storeX = new Ext.data.ArrayStore({
fields: ['type', 'total'],
data: [{
type: 'Field 1',
total: 20
},{
type: 'Field 2',
total: 134
},{
type: 'Field 3',
total: 92
}]
});

var piePanel = new Ext.Panel({
width: 220,
height: 220,
title: 'My Pie Chart',
items: {
store: storeX,
xtype: 'piechart',
dataField: 'total',
categoryField: 'type',
//extra styles get applied to the chart defaults
extraStyle:
{
legend:
{
display: 'bottom',
padding: 5,
font:
{
family: 'Tahoma',
size: 13
}
}
}
}
});


// Reload the data when a row is selected in a grid
myGrid.getSelectionModel().on('rowselect', function() {
storeX.loadData(getNewData());
});

function getNewData() {
var data = [{
type: 'Field 1',
total: 200
},{
type: 'Field 2',
total: 150
},{
type: 'Field 3',
total: 60
}];
console.log(data);
return data;
}

// attach piePanel to some layout


I've tried to include all the important code parts in here, but not included my test grid or container layout for clarity.

Anyone know if this is my error, or a possible bug?

evant
19 Aug 2009, 4:26 AM
See here: http://extjs.com/deploy/dev/examples/chart/reload-chart.html

Chart reloading works.

benny
19 Aug 2009, 5:26 AM
As suspected, I had an error in my code... thanks for your reply.

I had to the data structure wrong, it should have been:



function getNewData() {
var data = [];
data.push('Field 1',200);
data.push('Field 2',150);
data.push('Field 3',60);
console.log(data);
return data;
}