Javascript Extjs 4.2.1堆叠条形图最小值和最大值随存储而变化
您好,我正在开发一个extjs 4.2.1应用程序,其中我使用的是条形图(堆叠)。在x轴上,我希望范围从-100(最小)到最大(100),相差20(majorTickSteps=10) 下面是代码Javascript Extjs 4.2.1堆叠条形图最小值和最大值随存储而变化,javascript,jquery,extjs,Javascript,Jquery,Extjs,您好,我正在开发一个extjs 4.2.1应用程序,其中我使用的是条形图(堆叠)。在x轴上,我希望范围从-100(最小)到最大(100),相差20(majorTickSteps=10) 下面是代码 var store = Ext.create('Ext.data.JsonStore', { fields: ['name', 'cost','sell'], data: [ {'name': "2013", 'cost': -36.483395098129556, 'sell': 25.51
var store = Ext.create('Ext.data.JsonStore', {
fields: ['name', 'cost','sell'],
data: [
{'name': "2013", 'cost': -36.483395098129556, 'sell': 25.516604901870444},
{'name': "2013", 'cost': -27.483395098129556, 'sell': 8.516604901870444},
{'name': "2013", 'cost': -35.483395098129556, 'sell': 19.516604901870444},
{'name': "2013", 'cost': -25.483395098129556, 'sell': 33.516604901870444}
]
}))
- 如果stacked=true,则x轴最小值和最大值将根据存储更改
- 如果堆叠=false,则x轴最小值和最大值保持不变,但不堆叠
processView
功能
原始代码如下所示():
有关工作示例,请参见
Ext.create('Ext.chart.Chart', {
renderTo: Ext.getBody(),
id:'chart',
width: 580,
height: 165,
animate: true,
store: store,
axes: [{
type: 'Numeric',
position: 'bottom',
fields: ['cost','sell'],
grid: true,
minimum: -100,
maximum:100
}, {
type: 'Category',
position: 'left',
fields: ['name']
}],
series: [{
type: 'bar',
axis: 'bottom',
stacked: true,
xField: 'name',
yField: ['cost','sell']
}]
});
processView: function() {
var me = this,
chart = me.chart,
series = chart.series.items,
i, l;
for (i = 0, l = series.length; i < l; i++) {
if (series[i].stacked) {
// Do not constrain stacked charts (bar, column, or area).
delete me.minimum;
delete me.maximum;
me.constrain = false;
break;
}
}
if (me.constrain) {
me.doConstrain();
}
}
processView: function() {
var me = this;
if (me.constrain) {
me.doConstrain();
}
}