0
我無法爲控制器中的系列圖表創建'itemmouseup'事件的監聽器。extjs4控制器中的MVC監聽器
控制器:
init: function() {
this.control({
'monthbalance > chart': {
render: this.onChartRendered,
itemmouseup : this.onChartClick
},
});
},
如果我插入 '鼠標鬆開' 事件而不是 'itemmouseup' 它工作正常。但我需要'itemmouseup'。我哪裏錯了?
謝謝。
更新與觀點摘錄:
},{
id: 'card-1',
xtype: 'chart',
store: 'MonthBalances',
title: 'This Year vs Previous Years',
theme: 'Category1',
legend: {position: 'right'},
shadow: true,
axes: [{
type: 'Numeric',
position: 'left',
fields: ['monthbalance','monthlastyear','monthpreviousyear'],
label: {
renderer: Ext.util.Format.numberRenderer('0,0')
},
grid: true,
minimum: 0
},{
type: 'Category',
position: 'bottom',
fields: ['month']
}],
series: [{
type: 'line',
title: 'this year',
itemId: 'lineone',
highlight: {
size: 7,
radius: 7
},
axis: 'left',
xField: 'month',
yField: 'monthbalance',
// listeners: {
// itemmouseup: function() {
// console.log('itemmouseup-thisyear');
// }
// },
},{
type: 'line',
title: 'one year ago',
itemId: 'linetwo',
highlight: {
size: 7,
radius: 7
},
axis: 'left',
xField: 'month',
yField: 'monthlastyear',
},{
type: 'line',
id: 'linethree',
name: 'linethree',
itemId: 'linethree',
alias: 'widget.linethree',
title: 'two years ago',
highlight: {
size: 7,
radius: 7
},
axis: 'left',
xField: 'month',
yField: 'monthpreviousyear',
}]
}];
好吧,我明白了。我把它當作一個監聽器,放在我的視圖中,就像在[docs]中一樣(http://docs.sencha.com/ext-js/4-1/#!/api/Ext.chart.series。系列),但我真的想要在我的控制器中。它只能在視圖中定義嗎? – polarbear
@polarbear我明白了。看我的編輯。 – sra
我可以在我的控制檯中通過'Ext.ComponentQuery.query('。chart')[0] .series.items'訪問系列行,但無法弄清楚如何在我的控制器的'init'中訪問它們。有任何想法嗎?謝謝 – polarbear