PDA

View Full Version : Chart set store



AlbertoMD
10 Sep 2013, 8:58 AM
Im trying to assign a store to a Chart, I have the next code:


var chartDataStore = Ext.create("Ext.data.ArrayStore", {
storeId: "chartData",
fields: [
"Material_Code",
{ name: "Actual_Amount", type: "integer" },
{ name: "cost", type: "integer" }
],
data: [
["Al", 100, 89],
["SiMn", 490, 274],
["75FeSil", 140, 149],
["Desul", 100, 37],
["QLime", 400, 44],
["DoloLime", 300, 330]
]


});

var rv = Ext.create('Ext.panel.Panel', {
id: "panel1",
width: 600,
height: 600,
top: 10,
left: 10,
renderTo: "demoChart",
title: "Chart",
items: [{
xtype: 'chart',
id: "chart1",
store: chartDataStore,
border: 1,
width: 600,
height: 500,
axes: [{
position: 'left',
fields: ['Actual_Amount', 'cost'],
type: 'Numeric',
title: 'values',
grid: true
}, {
position: 'bottom',
fields: ['Material_Code'],
type: 'category',
title: 'Material',
grid: true
}],
series: [{
yField: 'Actual_Amount',
xField: 'Material_Code',
type: 'line',
axis: 'left',
highlight: true
}, {
yField: 'cost',
xField: 'Material_Code',
type: 'column',
axis: 'left',
highlight: true
}]

}]
});




And works fine,but if i want to assign the store later something like this:


Ext.getCmp('chart1').getChartStore().loadData(chartDataStore);
Ext.getCmp('chart1').redraw();



The chart doesn't show the information. I want to load the store that way because I am trying to show the information that I obtain from a data base connection.

Does anyone know if I am doing something wrong?

Thanks in advance.

Alberto

ettavolt
10 Sep 2013, 9:24 PM
Try to obtain information from a data base connection with help of chartDataStore - for this you need to extend it from ordinary Store rather then ArrayStore.