> So I assume that since the people here are the best in the 
> business that being able to create a dragable legend on a 
> graph is not possible.

Scot,

Actually, it's documented how to make any UI component draggable. You
can use the drag and drop APIs documented here (conceptual info):

 http://livedocs.macromedia.com/flex/2/docs/00000954.html

and here (API reference):

http://livedocs.macromedia.com/flex/2/langref/mx/managers/DragManager.ht
ml
http://livedocs.macromedia.com/flex/2/langref/mx/core/DragSource.html
http://livedocs.macromedia.com/flex/2/langref/mx/events/DragEvent.html

Something like this should help you get you started (drag the legend
onto the canvas):

<?xml version="1.0"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml";>
    <mx:Script><![CDATA[
        import mx.core.DragSource;
        import mx.managers.DragManager;
        import mx.events.*;
        import mx.containers.Canvas;

     import mx.collections.ArrayCollection;
     [Bindable]
     public var expenses:ArrayCollection = new ArrayCollection([
        {Expense: "Taxes", Amount: 2000, Cost:321, Discount:131},
        {Expense: "Bills", Amount: 100, Cost: 478, Discount: 841}
     ]);

        private function dragIt(event:MouseEvent):void {
            var dragInitiator:Legend=Legend(event.currentTarget);
            var ds:DragSource = new DragSource();
            var legendProxy:Legend = new Legend();
            DragManager.doDrag(dragInitiator, ds, event, legendProxy);
        }

        private function doDragEnter(event:DragEvent):void {
            var dropTarget:Panel=Panel(event.currentTarget);
            DragManager.acceptDragDrop(dropTarget);
        }
                
        private function doDragDrop(event:DragEvent):void {
            var currentPanel:Panel = Panel(event.currentTarget);
            //var data:Object = event.dragSource.dataForFormat('title');
            currentPanel.addChild(myLegend);
        }
    ]]></mx:Script>

  <mx:Panel id="panel1" title="Bar Chart with Legend in Panel">
     <mx:BarChart id="myChart" dataProvider="{expenses}">
        <mx:verticalAxis>
           <mx:CategoryAxis dataProvider="{expenses}"
categoryField="Expense"/>
        </mx:verticalAxis>
        <mx:series>
           <mx:BarSeries xField="Amount" displayName="Amount (in
$USD)"/>
           <mx:BarSeries xField="Cost" displayName="Cost (in $USD)"/>

           <mx:BarSeries xField="Discount" displayName="Discount (in
$USD)"/>
        </mx:series>
     </mx:BarChart>
     <mx:Panel id="legendPanel" title="Legend">
        <mx:Legend id="myLegend" dataProvider="{myChart}"
mouseMove="dragIt(event)"/> 
     </mx:Panel>
  </mx:Panel>

    <mx:Panel id="myPanel" 
        width="300" height="150" 
        title="Drag Legend Onto Me"
        dragEnter="doDragEnter(event);" 
        dragDrop="doDragDrop(event);"/>
</mx:Application>

hth,

matt horn
flex docs



> -----Original Message-----
> From: flexcoders@yahoogroups.com 
> [mailto:[EMAIL PROTECTED] On Behalf Of dinger0007
> Sent: Monday, September 18, 2006 10:54 AM
> To: flexcoders@yahoogroups.com
> Subject: [flexcoders] Re: Can a legend be draggable?
> 
> So I assume that since the people here are the best in the 
> business that being able to create a dragable legend on a 
> graph is not possible.
> 
> --- In flexcoders@yahoogroups.com 
> <mailto:flexcoders%40yahoogroups.com> , "dinger0007" 
> <[EMAIL PROTECTED]> wrote:
> >
> > I was having space issues with a legend and thought that 
> the ability 
> > to drag a legend around the graph would be cool. Is that possible, 
> > maybe a simple setting that i have missed?
> > 
> > Thanks in advance!
> >
> 
> 
> 
>  
> 


--
Flexcoders Mailing List
FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/flexcoders/

<*> Your email settings:
    Individual Email | Traditional

<*> To change settings online go to:
    http://groups.yahoo.com/group/flexcoders/join
    (Yahoo! ID required)

<*> To change settings via email:
    mailto:[EMAIL PROTECTED] 
    mailto:[EMAIL PROTECTED]

<*> To unsubscribe from this group, send an email to:
    [EMAIL PROTECTED]

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/
 


Reply via email to