PDA

View Full Version : How to add a listeners on the legend item (EXT JS MVC)



UpendraKumar
2 Jan 2013, 10:01 PM
Is it possible to add a listeners on the legend item(EXT JS MVC).

i tried but it is working for the first time click but it is not working on the second time click event.
{
xtype : 'lineChart',
listeners : {
afterrender : function(chart, eOpts){
setTimeout(function(){
var legendItems = chart.legend.items;
if(legendItems){
for(var i = 0; i < legendItems.length; i++){
legendItems[i].on('mousedown', function(event){
console.log('Mouse Down : ' + event);
});
legendItems[i].on('mousedown', function(event){
console.log('Mouse Over : ' + event);
});
/* legendItems[i].un("mousedown", legendItems[i].events.mousedown.listeners[0].fn);*/
}
}

}, 200);
}
}
}

Also how i can disable and enable the series lines or any chart through programmetically using extjs mvc.

Is it possible to replace the Legend Item feature(Hide and show the charts box or lines) with the check boxes.

mitchellsimoens
4 Jan 2013, 11:59 AM
You should study the source a bit more. The showAll method on the series is a key method. This is how the legenditem does the showing/hiding of the associated series:


me.on('mousedown', function() {
if (!toggle) {
series.hideAll(index);
label.setAttributes({
opacity: 0.5
}, true);
} else {
series.showAll(index);
label.setAttributes({
opacity: 1
}, true);
}
toggle = !toggle;
me.legend.chart.redraw();
}, me);