neurodon
13 Jun 2012, 9:51 AM
Hello,
I have an application which uses a single store across multiple views. It binds a 'chart' xtype to a store, which right now generates random data to graph.
Here is my code:
items: {
xtype: 'chart',
theme: 'Core',
style: 'background:#fff',
store: new Core.store.LiveChartStore({}),
animate: true,
shadow: true,
axes: [{...
This approach works fine in another part of my application (I use a gridview bound to a store with a backend PHP/AJAX proxy that generates random data).
This is my store code:
window.generateLiveData = function(n, floor){
var d = new Date();
var x = d.getUTCMilliseconds();
console.log("LiveData");
var data = [],
p = (Math.random() * 11) + 1,
i;
floor = (!floor && floor !== 0)? 20 : floor;
for (i = 0; i < (n || 12); i++) {
data.push({
name: Ext.Date.monthNames[i % 12].substring(0,3),
data1: Math.floor(Math.max((Math.random() * 100), floor)),
data2: Math.floor(Math.max((Math.random() * 100), floor)),
data3: Math.floor(Math.max((Math.random() * 100), floor)),
data4: Math.floor(Math.max((Math.random() * 100), floor)),
data5: Math.floor(Math.max((Math.random() * 100), floor)),
data6: Math.floor(Math.max((Math.random() * 100), floor)),
data7: Math.floor(Math.max((Math.random() * 100), floor)),
data8: Math.floor(Math.max((Math.random() * 100), floor)),
data9: Math.floor(Math.max((Math.random() * 100), floor))
});
}
return data;
};
Ext.define('Core.store.LiveChartStore', {
extend: 'Ext.data.Store',
fields: ['name', 'data1', 'data2', 'data3', 'data4', 'data5', 'data6', 'data7', 'data9', 'data9'],
data: this.generateLiveData(),
autoLoad:true,
initComponent: function() {
me.callParent(arguments);
}
});
The issue is that all of my charts (6 in total) use the same instance of the store, and therefore graph the same dataset.
What am I doing wrong?
I have an application which uses a single store across multiple views. It binds a 'chart' xtype to a store, which right now generates random data to graph.
Here is my code:
items: {
xtype: 'chart',
theme: 'Core',
style: 'background:#fff',
store: new Core.store.LiveChartStore({}),
animate: true,
shadow: true,
axes: [{...
This approach works fine in another part of my application (I use a gridview bound to a store with a backend PHP/AJAX proxy that generates random data).
This is my store code:
window.generateLiveData = function(n, floor){
var d = new Date();
var x = d.getUTCMilliseconds();
console.log("LiveData");
var data = [],
p = (Math.random() * 11) + 1,
i;
floor = (!floor && floor !== 0)? 20 : floor;
for (i = 0; i < (n || 12); i++) {
data.push({
name: Ext.Date.monthNames[i % 12].substring(0,3),
data1: Math.floor(Math.max((Math.random() * 100), floor)),
data2: Math.floor(Math.max((Math.random() * 100), floor)),
data3: Math.floor(Math.max((Math.random() * 100), floor)),
data4: Math.floor(Math.max((Math.random() * 100), floor)),
data5: Math.floor(Math.max((Math.random() * 100), floor)),
data6: Math.floor(Math.max((Math.random() * 100), floor)),
data7: Math.floor(Math.max((Math.random() * 100), floor)),
data8: Math.floor(Math.max((Math.random() * 100), floor)),
data9: Math.floor(Math.max((Math.random() * 100), floor))
});
}
return data;
};
Ext.define('Core.store.LiveChartStore', {
extend: 'Ext.data.Store',
fields: ['name', 'data1', 'data2', 'data3', 'data4', 'data5', 'data6', 'data7', 'data9', 'data9'],
data: this.generateLiveData(),
autoLoad:true,
initComponent: function() {
me.callParent(arguments);
}
});
The issue is that all of my charts (6 in total) use the same instance of the store, and therefore graph the same dataset.
What am I doing wrong?