tags:

views:

1418

answers:

1

hi All, how to change the bar chart color in bar charts?

Thanks, AravindakumarThangaraju

A: 
<?xml version="1.0"?>

<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"&gt;
  <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>
Shua
thanks shua.but i need not like thatplease go through this like i need like that type of bar chartshttp://img200.imageshack.us/img200/1666/barcharts.pngThanks,aravindakumarThangaraju
aravindakumarThangaraju
ok.... check out http://demo.quietlyscheming.com/ChartSampler/app.htmland look at the customization -> per column colors
Shua
Thanks Shua.It's very usefull for me and thank for your Patience.i have one more question there is any way to without using xml to load color dynamically?
aravindakumarThangaraju
no prob. but I'm not sure what you mean by not using xml because the example uses and array to determine the fill colors. Make sure you are looking at the PerColumnFill Class in the examples.customizing Package. The fill Array has all the colors used
Shua
@Aravinda: - please help me out the same for me also. I also need same example. Thanks
Ravi K Chowdary