2 Replies Latest reply on Feb 5, 2010 9:01 AM by reidabel

    mx:BarChart drag and drop issues

    reidabel Level 1

      I have an mx:BarChart and an mx:DataGrid, both with

       

      dragEnabled="true"

      dragMoveEnabled="true"

      dropEnabled="true"

       

      But the startDrag operation is not working with the barchart, only the datagrid. I get neither a drag cursor nor anything happening in the dragStartHandler. It works fine with a dataGrid:

       

      WORKS FINE:

      protected function dataGrid2_dragStartHandler(event:DragEvent):

      void

       

      {

      label1.text =

      'drag started!';

      Alert.show(

      'drag started', 'testing datagrid drag');

      }

       

      DOESN'T WORK AT ALL:

       

      {

      label1.text =

      'drag started!';

      Alert.show(

      'drag started', 'testing datagrid drag');

      }

       

      DOESN'T WORK AT ALL:

      {

      label1.text =

      'drag started!';

      Alert.show(

      'drag started', 'testing datagrid drag');

      }

       

      DOESN'T WORK AT ALL:

       

       

      protected function barchart1_dragStartHandler(event:DragEvent):void

      {

      label1.text =

      'drag started!';

      Alert.show(

      'drag started', 'testing barchart drag');

      }

       

       

       

       

        • 1. Re: mx:BarChart drag and drop issues
          reidabel Level 1

          Okay, I don't know why I ended up with multiple copies of my barchart startDrag handler in my original post ...

           

          Anyway, this still doesn't work for me, but I was able to code a workaround, following the instructions at:

           

          http://help.adobe.com/en_US/Flex/4.0/html/WS2db454920e96a9e51e63e3d11c0bf69084-7cfe.html

           

          1. code the barchart mouseDown to put data into an Array, then put that array into a DragSource and have the DragManager start a drag operation with it, like:

           

           

           

          protected function barchart1_mouseDownHandler(event:MouseEvent):void

          {

           

           

          var ds:DragSource = new DragSource();

           

          var a:Array = new Array;

           

           

          for (var i:int = barchart1.series.length; i >= 0; i--)

          {

          a.push(i); //I still need to find out how to get the data out of the barchart, but anyway ...

          }

          ds.addData(a, 'items'); //This HAS to be 'items', you can't make up your own.

          DragManager.doDrag(barchart1, ds, event);

           

           

          }

           

           

          protected function list1_dragEnterHandler(event:DragEvent):void

          {

           

          // Accept the drag only if the user is dragging data

           

          // identified by the 'items' format value.

           

          if (event.dragSource.hasFormat('items')) {

           

          // Get the drop target component from the event object.

           

          var dropTarget:BarChart=barchart1; //barchart1 is currently hardcoded, until I figure out how to accept any barchart

          // Accept the drop.

          DragManager.acceptDragDrop(dropTarget);

          }

          }

           

          After that, the list lets me drop the array data onto it and places it as expected.

           

          If anybody knows how to get the data out of the barchart (by series), please respond. Thank you ...

           

           

          • 2. Re: mx:BarChart drag and drop issues
            reidabel Level 1

            I got a lot further on this, I can now drag and drop from one chart into another - for more details, see my (Feb 3 to Feb 5) discussion by clicking on the link:

             

            Guidance on approach - ad hoc barcharts