Define a custom SolidColor object and a custom SolidColorStroke object, and applies them to the ColumnSeries object in the ColumnChart 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/BasicColumnFills.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]
public var expenses:ArrayCollection = new ArrayCollection([
{Month:"Jan", Profit:20, Expenses:15, Amount:145},
{Month:"Feb", Profit:1, Expenses:2, Amount:60},
{Month:"Mar", Profit:15, Expenses:5, Amount:3}
]);
</fx:Script>
<fx:Declarations>
<!-- Define custom colors for use as column fills. -->
<mx:SolidColor id="sc1" color="blue" alpha=".3" />
<mx:SolidColor id="sc2" color="red" alpha=".3" />
<!-- Define custom SolidColorStrokes for the columns. -->
<mx:SolidColorStroke id="s1" color="blue" weight="2" />
<mx:SolidColorStroke id="s2" color="red" weight="2" />
</fx:Declarations>
<s:layout>
<s:VerticalLayout />
</s:layout>
<s:Panel title="ColumnChart Control with Custom Column Styles">
<s:layout>
<s:VerticalLayout />
</s:layout>
<mx:ColumnChart id="myChart" dataProvider="{expenses}"
showDataTips="true">
<mx:horizontalAxis>
<mx:CategoryAxis categoryField="Month" />
</mx:horizontalAxis>
<mx:series>
<mx:ColumnSeries xField="Month" yField="Profit"
displayName="Profit" fill="{sc1}" stroke="{s1}" />
<mx:ColumnSeries xField="Month" yField="Expenses"
displayName="Expenses" fill="{sc2}" stroke="{s2}" />
</mx:series>
</mx:ColumnChart>
<mx:Legend dataProvider="{myChart}" />
</s:Panel>
</s:Application>
Related examples in the same category