1 Reply Latest reply on Jun 30, 2011 7:34 AM by rgwozdz

    Flex 4 chart mouse drive update data

    KAZatSAP

      Hello everyone,

       

      I am trying to develop a demo chart where user may move points with de mouse

      my idea is very simple

       

                              private function init():void{
                          
                          chart.addEventListener(ChartItemEvent.ITEM_CLICK,onItemClicDown);     
                          chart.addEventListener(MouseEvent.MOUSE_UP,onItemClicUp);
                     }
                     
                     private function onItemClicDown(event:ChartItemEvent):void{
                          var item:Object = event.hitData.item;
                          idx = provider.getItemIndex(item);
                          chart.addEventListener(MouseEvent.MOUSE_MOVE,onItemMouve);     
                     }     
                     
                     private function onItemMouve(event:MouseEvent):void{
                     
                          var item:Object = provider.getItemAt(idx);
                          
                          var tmpCollection:ArrayCollection = provider;
                                              
                          var p:Point = new Point(chart.mouseX,chart.mouseY);
                          
                          var d:Array = serie.localToData(p);
                          item.y = d[1];
                          
                          tmpCollection.setItemAt(item,idx);
                          provider = tmpCollection;
                     }
                     
                     private function onItemClicUp(event:MouseEvent):void{
                          chart.removeEventListener(MouseEvent.MOUSE_MOVE,onItemMouve);     
                     }  
      
      

       

      When the user move the point very slowly every this is ok, but otherwise exception is throw

      TypeError: Error #1009: Cannot access a property or method of a null object reference.

      at mx.charts.series::LineSeries/findDataPoints()[E:\dev\4.0.0\frameworks\projects\datavisual ization\src\mx\charts\series\LineSeries.as:1460]

      at mx.charts.chartClasses::ChartBase/findDataPoints()[E:\dev\4.0.0\frameworks\projects\datav isualization\src\mx\charts\chartClasses\ChartBase.as:2202]

      at mx.charts.chartClasses::ChartBase/mouseMoveHandler()[E:\dev\4.0.0\frameworks\projects\dat avisualization\src\mx\charts\chartClasses\ChartBase.as:4882]

       

      the error seams to come from the framework itself in the mouseMouveHandler of the basechart

      how should I solve this problem or disable the error throwing.

      An other strange behaviour is that instead of working with single click the function onItemClick down is call for double click only, it is a bug in the framework ?

       

      Thanks for reading, I will appreciate any help