Define three custom SolidColor objects and three custom SolidColorStroke objects, and applies them to the three AreaSeries objects in the AreaChart 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/AreaChartFills.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"
height="600">
<fx:Script>
import mx.collections.ArrayCollection;
[Bindable]
private var expenses:Array = [
{Month:"January", Profit:2000, Expenses:1500, Amount:450},
{Month:"February", Profit:1000, Expenses:200, Amount:600},
{Month:"March", Profit:1500, Expenses:500, Amount:300},
{Month:"April", Profit:500, Expenses:300, Amount:500},
{Month:"May", Profit:1000, Expenses:450, Amount:250},
{Month:"June", Profit:2000, Expenses:500, Amount:700}
];
</fx:Script>
<fx:Declarations>
<!-- Define custom colors for use as fills in the AreaChart control. -->
<mx:SolidColor id="sc1" color="blue" alpha=".3" />
<mx:SolidColor id="sc2" color="red" alpha=".3" />
<mx:SolidColor id="sc3" color="green" alpha=".3" />
<!-- Define custom SolidColorStrokes. -->
<mx:SolidColorStroke id="s1" color="blue" weight="2" />
<mx:SolidColorStroke id="s2" color="red" weight="2" />
<mx:SolidColorStroke id="s3" color="green" weight="2" />
</fx:Declarations>
<s:layout>
<s:VerticalLayout />
</s:layout>
<s:Panel title="AreaChart Control with Custom Fills Example"
height="100%" width="100%">
<s:layout>
<s:HorizontalLayout />
</s:layout>
<mx:AreaChart id="Areachart" height="100%" width="70%"
paddingLeft="5" paddingRight="5" showDataTips="true"
dataProvider="{expenses}">
<mx:horizontalAxis>
<mx:CategoryAxis categoryField="Month" />
</mx:horizontalAxis>
<mx:series>
<mx:AreaSeries yField="Profit" displayName="Profit"
areaStroke="{s1}" areaFill="{sc1}" />
<mx:AreaSeries yField="Expenses" displayName="Expenses"
areaStroke="{s2}" areaFill="{sc2}" />
<mx:AreaSeries yField="Amount" displayName="Amount"
areaStroke="{s3}" areaFill="{sc3}" />
</mx:series>
</mx:AreaChart>
<mx:Legend dataProvider="{Areachart}" />
</s:Panel>
</s:Application>
Related examples in the same category