GiG*_*iGi 4 extjs sencha-touch sencha-touch-2 sencha-touch-2.1
我正在使用xtype:chart,这是我的轴.
axes: [{
type: 'numeric',
minimum: 0,
position: 'left',
fields: ['2011', '2012', '2013'],
title: 'Sales',
minorTickSteps: 1,
grid: {
odd: {
opacity: 1,
fill: '#ddd',
}
},
style: {
axisLine: false,
estStepSize: 20,
stroke: '#ddd',
'stroke-width': 0.5
},
minimum: 0,
maximum: 1000
}, {
type: 'category',
position: 'bottom',
fields: ['name'],
title: 'Month of the Year',
style: {
estStepSize: 1,
stroke: '#999'
}
}]
Run Code Online (Sandbox Code Playgroud)
这是我的问题,不同用户之间的最小值和最大值变化很大.如果我为某些用户给出最小-0和最大值10000,则图表不显示...而对于其他一些图表,如果我为0则不显示 - 1000,所以我想在加载图表之前更改商店中的最小值和最大值.这有可能吗?我请一个例子.谢谢
无需设置最小值和最大值,因为它将由sencha根据数据设置
如果您仍想这样做,那么可以通过监听图表的初始化事件来做到这一点
可以说,这是轴
axes: [{
type: 'numeric',
position: 'left',
fields: ['data1'],
title: {
text: 'Sample Values',
fontSize: 15
},
grid: true,
minimum: 0
}, {
type: 'category',
position: 'bottom',
fields: ['name'],
title: {
text: 'Sample Values',
fontSize: 15
}
}],
Run Code Online (Sandbox Code Playgroud)
并初始化监听器
listeners : {
initialize : function( me, eOpts ) {
Ext.getStore('chartstore').load({
callback: function(records, operation, success) {
var data = records[0].data;
var axes = me.getAxes();
var SampleValuesAxis = axes[0];
SampleValuesAxis.setMinimum(data.minimum);
SampleValuesAxis.setMaximum(data.maximum);
},
scope: this
});
}
}
Run Code Online (Sandbox Code Playgroud)