tags:

views:

1231

answers:

3

Hi, Is there a way to change the style of Flex Chart according to the values. For example, in column chart, set green for positive value and red for negative value?

+1  A: 

To need to give your ColumnSeries a fillFunction property that is used to calulate the IFill based on the value for the given column. Something like:

<?xml version="1.0"?>
<!-- Simple example to demonstrate the ColumnChart and BarChart controls. -->
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"&gt;
    <mx:Script>
        <![CDATA[
            import mx.charts.ChartItem;
            import mx.graphics.IFill;          
            import mx.collections.ArrayCollection;

      private function fillFunction (item:ChartItem, index:Number):IFill
      {  
       if(item.item.Gold > 0)
       {
        return new SolidColor(0x00FF00);
       } else {
        return new SolidColor(0xFF0000);
       }
      }


            [Bindable]
            private var medalsAC:ArrayCollection = new ArrayCollection( [
                { Country: "USA", Gold: 35},
                { Country: "China", Gold: -5},
                { Country: "Russia", Gold: 27} ]);
        ]]>
    </mx:Script>

    <!-- Define custom colors for use as fills. -->
    <mx:SolidColor id="sc1" color="yellow" alpha=".8"/>

    <!-- Define custom Strokes for the columns. -->
    <mx:Stroke id="s1" color="yellow" weight="2"/>

    <mx:Panel title="ColumnChart and BarChart Controls Example" 
        height="100%" width="100%" layout="horizontal">
        <mx:ColumnChart id="column" 
            height="100%" 
            width="100%" 
            paddingLeft="5" 
            paddingRight="5" 
            showDataTips="true" 
            dataProvider="{medalsAC}"
        >                
            <mx:horizontalAxis>
                <mx:CategoryAxis categoryField="Country"/>
            </mx:horizontalAxis>

            <mx:series>
                <mx:ColumnSeries 
                    xField="Country" 
                    yField="Gold" 
                    displayName="Gold"
                    fill="{sc1}"
                    stroke="{s1}"
                    fillFunction="{fillFunction}"
                />
            </mx:series>
        </mx:ColumnChart>

        <mx:Legend dataProvider="{column}"/>

    </mx:Panel>
</mx:Application>
James Hay
A: 

i lik the vampire diaries so much that it has bcome an obsession of mine...now i am going crazyi need an mental hospital!!!!that is true signed her good friend bubagonush the s is sylent r3qwgECF5TWY6MENVFDNZ GBHUFNTHDUZNVCJKBViNVCKJHFEYRDSJZNCDUHFHBJZDINVFUHBNJDXICNVCIUZFBDFBNDISPRDFISgnbiURBUYFNVFDIHARBESUYFIBSUOgbFYSUfDUISghNUSBFUIDBGHUGBFDYUSHNDFDBSYUGBHUDFNGFUIDBGFDUAGBFDUAIGNFDHABGDUHNGFDHBUHGBHGBFJHBVFHGBFHBF DAHJBGGUHIFABGSUDIGBFSUIGBSDUAIBGFUDISFGVBUISAVGRUOBGRUOBGFggbvyerdsx3q`w234o75ljf5km k,n hnbb .h nbh nhb hnb x

EMILY ENDLUND
A: 

wat is an ali...well that is an alien they are really aliens but they are human form...or so u think...other than aliens discised as humans they can also turn into gerbils. u can tell an alien apart from a human because of the fuzzy hair and they crazy vibe they give u...u should call the police imediatly and tell them that u hav spotted ann alien!!good luck on ur serch!!

EMILY ENDLUND