Mega Code Archive

 
Categories / Flex / Chart
 

Define two colors and then uses those colors in the axis renderers and in the strokes and fills for the chart items

<!-- 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/StyledMultipleAxes.mxml --> <s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"     xmlns:mx="library://ns.adobe.com/flex/mx" xmlns:s="library://ns.adobe.com/flex/spark"     creationComplete="srv_fe.send();srv_strk.send()" height="600">     <fx:Script>                    [Bindable]          public var c1:Number = 0x224488;          [Bindable]          public var c2:Number = 0x884422;             </fx:Script>     <fx:Declarations>         <!--             To see data in an HTML table, go to             http://aspexamples.adobe.com/chart_examples/stocks.aspx         -->         <!--             View source of the following pages to see the structure of the data             that Flex uses in this example.         -->         <mx:HTTPService id="srv_fe"             url="http://aspexamples.adobe.com/chart_examples/stocks-xml.aspx?tickerSymbol=FE" />         <mx:HTTPService id="srv_strk"             url="http://aspexamples.adobe.com/chart_examples/stocks-xml.aspx?tickerSymbol=STRK" />         <mx:SolidColorStroke id="h1Stroke" color="{c1}"             weight="8" alpha=".75" caps="square" />         <mx:SolidColorStroke id="h2Stroke" color="{c2}"             weight="8" alpha=".75" caps="square" />     </fx:Declarations>     <s:layout>         <s:VerticalLayout />     </s:layout>     <s:Panel title="Multiple Axes with Multiple Data Series" width="400"         height="400">         <s:layout>             <s:VerticalLayout />         </s:layout>         <mx:ColumnChart id="myChart" showDataTips="true"             height="250" width="350">             <mx:horizontalAxis>                 <mx:DateTimeAxis id="h1" dataUnits="days" />             </mx:horizontalAxis>             <mx:horizontalAxisRenderers>                 <mx:AxisRenderer placement="bottom" axis="{h1}" />             </mx:horizontalAxisRenderers>             <mx:verticalAxisRenderers>                 <mx:AxisRenderer placement="left" axis="{v1}">                     <mx:axisStroke>{h1Stroke}</mx:axisStroke>                 </mx:AxisRenderer>                 <mx:AxisRenderer placement="right" axis="{v2}">                     <mx:axisStroke>{h2Stroke}</mx:axisStroke>                 </mx:AxisRenderer>             </mx:verticalAxisRenderers>             <mx:series>                 <mx:ColumnSeries dataProvider="{srv_fe.lastResult.data.result}"                     xField="date" yField="close" displayName="FE">                     <mx:verticalAxis>                         <mx:LinearAxis id="v1" minimum="2" maximum="5" />                     </mx:verticalAxis>                     <mx:fill>                         <mx:SolidColor color="{c1}" />                     </mx:fill>                 </mx:ColumnSeries>                 <mx:LineSeries dataProvider="{srv_strk.lastResult.data.result}"                     xField="date" yField="close" displayName="STRK">                     <mx:verticalAxis>                         <mx:LinearAxis id="v2" minimum="40" maximum="50" />                     </mx:verticalAxis>                     <mx:lineStroke>                         <mx:SolidColorStroke color="{c2}" weight="4"                             alpha="1" />                     </mx:lineStroke>                 </mx:LineSeries>             </mx:series>         </mx:ColumnChart>         <mx:Legend dataProvider="{myChart}" />     </s:Panel> </s:Application>