PDA

View Full Version : How to register a evenr for chart series in initComponent



mrprabu
3 Mar 2014, 6:17 PM
Hi ,

how to register a event for chart serious in initComponent.

I tried below code but getting error like this

Uncaught TypeError: Object #<Object> has no method 'on'


this.series[0].on({ itemmouseover: this.onItemMouseOver,
scope: this
}
);

a.premkumar
4 Mar 2014, 12:01 AM
You can try doing it on the chart's render event.



chartRender : function (chart){
var lineSeries = chart.series.get(0);
lineSeries.listeners = {
itemmouseover:function(item){
// Code
}
}
}


Regards,
Premkumar. A

mrprabu
4 Mar 2014, 12:55 AM
Hi Prem,

thanks .. But I achieved my scenario in this way


initComponent: function () {
var me = this;
me.on({
afterlayout: me.onAfterLayout,
scope: this
});
},
onAfterLayout: function (cmp) { var chart = cmp.down('chart'),
surface = chart.surface,
series = chart.series;
/* Adding listeners for chart serious itemmouseover & itemmouseout */
if (series.items && series.items.length > 0) {
series.items[0].on({
itemmouseover: this.onItemMouseOver,
itemmouseout: this.onItemMouseOut,
scope: this
});
}
/*listeners for chart serious end */}

a.premkumar
4 Mar 2014, 1:57 AM
Great..:)