我们正试图使用堆积条形图分析各国公司的利润。国家数量不同,从数据库获得并在X轴上绘制。 根据数据库中可用的数据,要分析的利润也是动态的公司数量。
例如:
商店:
var store = Ext.create('Ext.data.JsonStore', {
model: 'com.model.MyModel',
autoLoad: true,
proxy: {
idProperty: 'id',
totalProperty: 'total',
successProperty: 'success',
type: 'ajax',
url:'profit.action',
reader: new Ext.data.JsonReader({
root:'data'
})
}
});
型号:
Ext.define('com.model.MyModel', {
extend: 'Ext.data.Model',
fields: [
{name:'countryName',type:'string'},
{name: 'profit', type:'auto'},
{name:'companyName',type :'auto'}
]
});
图表面板:
{
xtype:'panel',
width: 1160,
height: 200,
renderTo: Ext.getBody(),
layout: 'fit',
items: {
xtype: 'chart',
animate: true,
shadow: true,
store: store,
axes: [{
type: 'Numeric',
position: 'left',
fields: ['profit'],
title: 'Profit',
grid: true,
label: {
renderer: function(v) {
return String(v);
}
},
roundToDecimal: false
}, {
type: 'Category',
position: 'bottom',
fields: ['countryName'],
title: 'Country'
}],
series: [{
type: 'bar',
axis: 'bottom',
gutter: 80,
highlight: true,
column: true,
xField: 'countryName',
yField: ['profit'],
stacked: true,
tips: {
trackMouse: true,
width: 65,
height: 28,
renderer: function(storeItem, item) {
this.setTitle(String(item.value[1]));
}
}
}]
}
}
生成的JSON:
{
"data": [
{
"countryName": "Country1",
"company1": "100000000",
"company2": "200000000",
"company3": "300000000",
.. .. .. .. ..
.. .. .. .. ..
},
{
"countryName": "Country2",
"company1": "400000000",
"company2": "500000000",
"company3": "600000000",
.. .. .. .. ..
.. .. .. .. ..
},
{
"countryName": "Country3",
"company1": "400000000",
"company2": "600000000",
"company3": "700000000",
.. .. .. .. ..
.. .. .. .. ..
}
.. .. .. .. ..
.. .. .. .. ..
],
"total": 9,
"success": true
}
国家数量和公司数量未修复。我们将正确的数据存入商店并反映在json中,但图表是使用X轴渲染但没有条形。
请帮忙
由于