Mega Code Archive

 
Categories / Flex / Chart
 

Creating a custom Legend control

<!-- Code from Flex 4 Documentation "Using Adobe Flex 4". This user guide is licensed for use under the terms of the Creative Commons Attribution  Non-Commercial 3.0 License.  This License allows users to copy, distribute, and transmit the user guide for noncommercial  purposes only so long as    (1) proper attribution to Adobe is given as the owner of the user guide; and    (2) any reuse or distribution of the user guide contains a notice that use of the user guide is governed by these terms.  The best way to provide notice is to include the following link.  To view a copy of this license, visit http://creativecommons.org/licenses/by-nc-sa/3.0/ --> <!-- charts/MultipleAxesWithCustomLegend.mxml --> <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml">     <mx:Script>         import mx.collections.ArrayCollection;         [Bindable]         public var SMITH:ArrayCollection = new ArrayCollection([             {date: "22-Aug-05", close: 41.87},             {date: "23-Aug-05", close: 45.74},             {date: "24-Aug-05", close: 42.77},             {date: "25-Aug-05", close: 48.06},             ]);         [Bindable]         public var DECKER:ArrayCollection = new ArrayCollection([             {date: "22-Aug-05", close: 157.59},             {date: "23-Aug-05", close: 160.3},             {date: "24-Aug-05", close: 150.71},             {date: "25-Aug-05", close: 156.88},             ]);       </mx:Script>     <mx:Panel title="Column Chart With Multiple Series">         <mx:ColumnChart id="myChart" dataProvider="{SMITH}"             secondDataProvider="{DECKER}" showDataTips="true">             <mx:horizontalAxis>                 <mx:CategoryAxis dataProvider="{SMITH}" categoryField="date" />             </mx:horizontalAxis>             <mx:verticalAxis>                 <mx:LinearAxis minimum="40" maximum="50" />             </mx:verticalAxis>             <mx:series>                 <mx:ColumnSeries id="cs1" dataProvider="{SMITH}" xField="date"                     yField="close" displayName="SMITH" />             </mx:series>             <mx:secondVerticalAxis>                 <mx:LinearAxis minimum="150" maximum="170" />             </mx:secondVerticalAxis>             <mx:secondSeries>                 <mx:LineSeries id="cs2" dataProvider="{DECKER}" xField="date"                     yField="close" displayName="DECKER" />             </mx:secondSeries>         </mx:ColumnChart>         <mx:Legend>             <mx:LegendItem label="SMITH" fontWeight="bold">                 <mx:fill>                     <mx:SolidColor color="0xFF9900" />                 </mx:fill>                 <mx:stroke>                     <mx:Stroke color="0x000000" weight="1" />                 </mx:stroke>             </mx:LegendItem>             <mx:LegendItem label="DECKER" fontWeight="bold">                 <mx:fill>                     <mx:SolidColor color="{0x999933}" />                 </mx:fill>                 <mx:stroke>                     <mx:Stroke color="0x000000" weight="1" />                 </mx:stroke>             </mx:LegendItem>         </mx:Legend>     </mx:Panel> </mx:Application>