PDA

View Full Version : Chart' won't update when database is changed



Cody Anderson
10 Apr 2013, 2:45 PM
So I have 4 charts that pull data from a database, for three of them if I change something in the database it will update the charts if I refresh the page however one of the charts and I cant figure out why requires me to reset the server before it updates the data. I dont know where this error is coming from so I am posting the code related to the chart that isn't working. I have compared this code with the other charts and can't see any visible differences. If there is something else that could cause the problem I appreciate any suggestions
Thanks.

This is my Store code

Ext.define('Agile_GoLink.store.MinMaxAvg', { extend: 'Ext.data.Store',

constructor: function(cfg) {
var me = this;

cfg = cfg || {};
me.callParent([Ext.apply({
autoLoad: true,
storeId: 'MinMaxAvg',
sortRoot: 'dayValue',
proxy: {
type: 'ajax',
url: 'minmaxavg.jsp',
reader: {
type: 'json',
root: 'results'
}
},
fields: [
{
name: 'dayValue',
sortType: 'asUCString',
type: 'Category',
dateFormat: ('n-j-Y')
},
{
name: 'minValue',
type: 'int'
},
{
name: 'maxValue',
type: 'int',
},
{
name: 'avgValue',
type: 'int'
}
],
listeners: {
load: {
fn: me.onLoad,
scope: me
}
}
}, cfg)]);
},




onLoad: function(store, records, successful, operation, options) {
if (!successful) {
if (store) {
var proxy = store.getProxy();
if (proxy) {
var reader = proxy.getReader();
if (reader && reader.rawData && reader.rawData.message) {
Ext.Msg.alert("Error", reader.rawData.message);
return;
}
}
}


Ext.Msg.alert("Error", "Could not get the Mix Max Average data");
}


}


});

here is the view code

Ext.define('Agile_GoLink.view.ProcesTime', { extend: 'Ext.panel.Panel',
alias: 'widget.ProcesTime',

height: 260,
width: 330,
layout: {
type: 'fit'
},
title: 'DTR Processing Time Past 30 Days',


initComponent: function() {
var me = this;

Ext.applyIf(me, {
items: [
{
xtype: 'chart',
height: 274,
id: 'chtProcTime',
width: 349,
stateful: false,
shadow: false,
animate: true,
insetPadding: 20,
store: 'MinMaxAvg',
theme: 'Purple',

axes: [
{
type: 'Category',
fields: [
'dayValue'
],
label: {
renderer : Ext.util.Format.dateRenderer('n/j/Y'),
},
position: 'left',
title: 'Date',
dateFormat: 'n/j/Y'
},
{
type: 'Numeric',
fields: [
'minValue',
'avgValue',
'maxValue'
],
majorTickSteps: 1,
position: 'bottom',
title: 'Min Max Avg Proc Time (min)',
adjustMaximumByMajorUnit: true,
decimals: 1,
minimum: 0
}
],
series: [
{
type: 'bar',
highlight: false,
label: {
display: 'outside',
field: 'maxValue',
color: '#333',
'text-anchor': 'middle'
},
axis: 'bottom',
xField: 'dayValue',
yField: [
'minValue',
'avgValue',
'maxValue'
],
stacked: false
}
],
legend: {
position: 'float',
x:-19,
y:160
}

}

]

});



me.callParent(arguments);
}


});

slemmon
12 Apr 2013, 9:56 AM
Can you load data manually?
*see the Reload Data in this example (http://docs.sencha.com/ext-js/4-2/extjs-build/examples/charts/Area.html).

If so, then I suspect the issue is not in the Ext chart, but may instead be on how the server is delivering the data down to the store used by the chart.