PDA

View Full Version : Pie Chart Color from XML


nxfxcom
12-04-2009, 05:21 PM
Hello,

i am working on a Dashboard Application, the legend would in be in JSP/HTML and the Chart itself in flex, now my questions is how can i define the slice color from XML ?

Thank you

nxfxcom
12-04-2009, 06:52 PM
Below is my current code

<?xml version="1.0"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" creationComplete="srv.send()" backgroundGradientAlphas="[1.0, 1.0]" backgroundGradientColors="[#FFFFFF, #FFFFFF]" borderColor="#FFFFFF">
<mx:Script><![CDATA[
import mx.collections.ListCollectionView;
import mx.utils.ArrayUtil;


]]>
</mx:Script>

<mx:HTTPService id="srv" url="../xml/sourcesPie.xml" resultFormat="e4x" />

<mx:XMLListCollection id="myAC" source="{srv.lastResult.entry}" />


<mx:Panel styleName="opaquePanel"
width="100%"
height="100%" title="Sources" horizontalAlign="left">
<mx:HBox width="100%" height="100%">



<mx:PieChart id="myChart" dataProvider="{myAC}" showDataTips="false" width="100%" height="100%">
<mx:series>
<mx:PieSeries field="views" fontSize="13" labelPosition="insideWithCallout" displayName="views" name="views" nameField="source" />
</mx:series>
</mx:PieChart>



<mx:Legend dataProvider="{myChart}"
direction="horizontal"
horizontalGap="100"
width="20%" />




<mx:DataGrid dataProvider="{myAC}">
<mx:columns>
<mx:DataGridColumn headerText="Source" dataField="source"/>
<mx:DataGridColumn headerText="Views" dataField="views"/>
<mx:DataGridColumn headerText="%" dataField="perc"/>
</mx:columns>
</mx:DataGrid>




</mx:HBox>

</mx:Panel>



</mx:Application>




And then my xml, i want the pie charts to get the right color as defined in XML

<entries>
<entry>
<source>Monster</source>
<views>68</views>
<perc>54</perc>
<color>#123412</color>
</entry>
<entry>
<source>LocalHires</source>
<views>1232</views>
<perc>3</perc>
<color>#123412</color>
</entry>
<entry>
<source>Yahoo</source>
<views>54</views>
<perc>45</perc>
<color>#123412</color>
</entry>
<entry>
<source>Craigslist</source>
<views>3195</views>
<perc>22</perc>
<color>#123412</color>
</entry>
<entry>
<source>Google</source>
<views>1228</views>
<perc>18</perc>
<color>#123412</color>
</entry>
</entries>