如何更改条形图中的条形颜色

时间:2009-07-15 09:26:10

标签: actionscript-3 flex flex3

如何更改条形图中的条形图颜色?

谢谢, AravindakumarThangaraju

2 个答案:

答案 0 :(得分:1)

<?xml version="1.0"?>

<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml">
  <mx:Script><![CDATA[
     import mx.collections.ArrayCollection;
     [Bindable]
     public var expenses:ArrayCollection = new ArrayCollection([
        {Month:"Jan", Profit:2000, Expenses:1500},
        {Month:"Feb", Profit:1000, Expenses:200},
        {Month:"Mar", Profit:1500, Expenses:500}
     ]);
  ]]></mx:Script>
  <mx:Panel title="Bar Chart">
     <mx:BarChart id="myChart" dataProvider="{expenses}" showDataTips="true">
        <mx:verticalAxis>
           <mx:CategoryAxis 
                dataProvider="{expenses}" 
                categoryField="Month"
           />
        </mx:verticalAxis>
        <mx:series>
           <mx:BarSeries 
                yField="Month" 
                xField="Profit" 
                displayName="Profit"
            >
            <mx:stroke>
                <mx:Stroke 
                    color="0x808080" 
                    weight="2" 
                    alpha=".8"
                />
            </mx:stroke>
           </mx:BarSeries>
           <mx:BarSeries 
                yField="Month" 
                xField="Expenses" 
                displayName="Expenses"
           >
            <mx:stroke>
                <mx:Stroke 
                    color="0xC0C0C0" 
                    weight="2" 
                    alpha=".8"
                />
            </mx:stroke>
           </mx:BarSeries>
        </mx:series>
     </mx:BarChart>
     <mx:Legend dataProvider="{myChart}"/>
  </mx:Panel>
</mx:Application>

答案 1 :(得分:0)

而不是使用笔画我们可以使用

<mx:SolidColor id="sc1" color="blue" alpha=".3"/>

并使用填充属性

提及纯色ID
<mx:series>
       <mx:ColumnSeries
            yField="work" 
            minField="age"
            displayName="work"
            fill="{sc1}"/>