tags:

views:

106

answers:

1
    <Projectlist>
    <Project>
    <ProjectName>Alcoswitch - ToggleSwitches
    </ProjectName>
    <ProjectStatusname>Planning</ProjectStatusname>
    </Project>
    <Project>
    <ProjectName>
    Transverse Wedge</ProjectName>
    <ProjectStatusname>Canceled</ProjectStatusname>
    </Project>
    <Project>
    <ProjectName>High Speed Pluggable I/O</ProjectName>
    <ProjectStatusname>In-Progress</ProjectStatusname>
    </Project>
    <Project>
    <ProjectName>"High Speed Pluggable I/O - Product Breakouts:</ProjectName>
    <ProjectStatusname>In-Progress</ProjectStatusname>
    </Project>
    <Project>
    <ProjectName>Circular Plastic Connector (CPC)</ProjectName>
    <ProjectStatusname>In-Progress</ProjectStatusname>
    </Project>
    </Projectlist>

This is my XML data i am recieving, how can i show this in a bar chart.

<mx:BarChart id="barChart"
             showDataTips="true" dataProvider="{ProjectStateInfo}"

             width="100%"
             height="100%">
             <mx:horizontalAxis>
                 <mx:CategoryAxis categoryField="ProjectStatusname"/>
             </mx:horizontalAxis>
        <mx:verticalAxis>
            <mx:CategoryAxis categoryField="ProjectName"/>
        </mx:verticalAxis>
        <mx:series>
            <mx:BarSeries id="barSeries" visible="true"
                    yField="ProjectName"
                    xField="ProjectStatusname"
                    displayName="ProjectStatusname"
                     />


        </mx:series>
    </mx:BarChart>

My X-Axis shows muliple values of In-Progress, but i just need one. Is it possible to represent such relationship using BarChart. Any other Flex chart is Advisable.

+1  A: 

You need to build an array (or another data structure) containing all the project status names, and use it for the horizontal axis. you need that to eliminate the duplicates.

var array:Array = ["Planning","Canceled","In-Progress"];

<mx:BarChart id="barChart"
         showDataTips="true" dataProvider="{xml.Project}"
         width="100%"
         height="100%">
         <mx:horizontalAxis>
             <mx:CategoryAxis dataProvider="{array}"/>
         </mx:horizontalAxis>
         <mx:verticalAxis>
            <mx:CategoryAxis dataProvider="{xml.Project}" categoryField="ProjectName"/>
         </mx:verticalAxis>
         <mx:series>
            <mx:BarSeries id="barSeries" visible="true"
                yField="ProjectName"
                xField="ProjectStatusname"
                displayName="ProjectStatusname"
                 />
         </mx:series>           
</mx:BarChart>
Cornel Creanga
Thanks a lot mate