PDA

View Full Version : Adding chart Item click in the Controller



bevara.siva
6 Jan 2015, 11:24 PM
Hi,

We are using Ext Js 4.2.2.

We need to implement the Stacked column charts ItemClick event in the controller.
I have tried adding event to the controller as below.




Chart:

{
xtype: 'chart',
id: 'SummaryChart',
itemId: 'SummaryChart',
action: 'SummaryDrillDown',
axes: [
{
type: 'Numeric',
: 'left',
fields: ['Physical',
'Contractual'],
grid: true,
minimum: 0
},
{
type: 'Category',
: 'bottom',
fields: ['Sec']
}
],
series: [
{
type: 'column',
axis: 'left',
xField: 'Sec',
yField: [
'Physical',
'Contractual'
],
stacked: true,


}
]
}

Controller:

Ext.define('MasterLayout.controller.SummaryController', {
extend: 'Ext.app.Controller',


init: function () {
this.control({
'container button[action=Summarysearch]': {
click: this.onbtnSummarySearchClick
},
'container textfield[action=Summarysearch]': {
keypress: this.ontxtSummarySearchKeypress
},
'container chart[action=SummaryDrillDown]': {
itemclick: this.onColumnItemClick
}
});
},
onColumnItemClick: function (column) {
alert("ItemClick");
},
onbtnSummarySearchClick: function (button) {
alert("button click");
},
ontxtSummarySearchKeypress: function (textfield, e, eOpts) {
alert("key press");
}
});




Button and keypress events are working. But ItemClick event is not working.
When I click on the item, the event is not firing. Its not showing error.

Please help!

Regards,
SivaPrasad.B

lumberjack
8 Jan 2015, 12:54 PM
You might need to relay the series' itemclick event up to the chart.



Ext.define('Fiddle.controller.MyController', {
extend: 'Ext.app.Controller',
init: function() {
this.control({
'chart': {
boxready: function (chart) {
var series = chart.series.items;
Ext.Array.each(series, function (theSeries) {
this.relayEvents(theSeries, ['itemclick']);
}, chart);
},
itemclick: function (seriesItem) {
console.log(seriesItem);
Ext.Msg.alert('Fiddle', 'Series item clicked');
}
}
});
}
});

Regards,
Brian

g38