Tuesday, November 11, 2014

Bar chart's item info Gesture not passing the selected bar/item to the show Event

A normal requirement, is that when a particular item is selected/tapped in the chart, we display its information or do some activity.

We had a similar requirement and had decided to use the iteminfo Gesture. However when the show event was handled, the correct item information of the selected item was not passes correctly to the handler. We can do that, by overriding the gesture: Have shown, how to get the selected object below, implementation will depend on the requirement.


 Ext.define('AppName.override.chart.interactions.ItemInfo', {  
   override: 'Ext.chart.interactions.ItemInfo',  
   onGesture: function (series, item) {  
        var me = this,  
       panel = me.getPanel();  
     me.item = item;  
         var chart = me.getChart(),  
       chartXY = chart.getEventXY(series);  
     var chartitem= chart.getItemForPoint(chartXY[0], chartXY[1]);  
         console.log(item);  
         console.log(chartitem);  
     /*me.fireEvent('show', me, item, panel);  
     Ext.Viewport.add(panel);  
     panel.show('pop');  
     series.setAttributesForItem(item, { highlighted: true });  
     me.sync();*/  
     return false;  
   }  
 });