Sunday, April 3, 2011

how to change the bar color in bar charts

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

Thanks, AravindakumarThangaraju

From stackoverflow
  • <?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>
    
    aravindakumarThangaraju : thanks shua.but i need not like thatplease go through this like i need like that type of bar charts http://img200.imageshack.us/img200/1666/barcharts.png Thanks, aravindakumarThangaraju
    Shua : ok.... check out http://demo.quietlyscheming.com/ChartSampler/app.html and look at the customization -> per column colors
    aravindakumarThangaraju : 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?
    Shua : 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
    Ravi K Chowdary : @Aravinda: - please help me out the same for me also. I also need same example. Thanks

0 comments:

Post a Comment