Hi Flex Masters!!!

First of all, thank for your support!!!

One of your Adobe collegues called Swathi Solsi recommended to talk 
to you about Flex, suggesting you are a great master of this art.

I have an issue here and i think you could help me...in fact, i beg 
your help. :-)

I am evaluating how can Flex work with Complex XML Files.

Intention of the application:  To plot a LINESERIES graph Where the 
Y axis is the Price and the X axis is the Time. The idea is to see 
the evolution of the price per product.
Also in the tooltip the intention is to Show the Month, the model, 
the name, the volume and the price.

Questions:

1 - Is it needed to work with XMLListCollection when dealing with 
Complex XML mandatory?
2 - What is the problem in this MXML, because it is plotting the 
repeated values in the X and Y, and not plotting the graph itself.

Source XML File: mydata.xml
<data>
 <title>Sales Chart</title>
 <result Period="Jan-04">
  <month>2004</month>
  <product type="3G">
   <model>6120</model>
   <name>Nice</name>
   <price>1000</price>
   <volume>10000</volume>
  </product>
  <product type="Non-3G2">
   <model>1208</model>
   <name>clio</name>
   <price>100</price>
   <volume>34000</volume>
  </product>
 </result>
 <result period="Jan-05">
  <month>2005</month>
  <product type="3G">
   <model>6120</model>
   <name>Nice</name>
   <price>1200</price>
   <volume>70000</volume>
  </product>
  <product type="Non-3G2">
   <model>1208</model>
   <name>clio</name>
   <price>500</price>
   <volume>14000</volume>
  </product>
 </result>
</data>

MXML Simple Application:
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"; 
creationComplete="feedRequest.send()">

<mx:XML id="mlb" source="/data/mydata.xml"/>


  <mx:Style>
     ColumnChart  {
         gutterLeft:50;
        gutterRight:50;
        gutterBottom:50;
        paddingTop:20;

        chartSeriesStyles: PLCSeries1, PLCSeries2, PLCSeries3, 
PLCSeries4;
     }
     .PLCSeries1 {
        fill: #0000ff;
     }
     .PLCSeries2 {
        fill: #ff0000;
     }
     .PLCSeries3 {
        fill: #00ff00;
     }
     .PLCSeries4 {
        fill: #999999;
     }

  </mx:Style>
  
 <mx:HTTPService 
        id="feedRequest" 
        url="http://200.200.200.200/mydata.xml";
        useProxy="false" />

  <mx:Model id="results" source="/data/mydata.xml"/>

 <mx:Stroke id="axisStroke" 
        color="#e4e4e4" 
        weight="6"
        alpha=".75"
        caps="square"
  />


  
  <mx:Panel title="Line Chart">
     <mx:LineChart id="chart" 
dataProvider="{feedRequest.data.result.product}" showDataTips="true">

        <!-- background elements -->
        <mx:backgroundElements>
            <mx:GridLines direction="both"
                    horizontalTickAligned="true"
                    verticalTickAligned="true">
                <mx:horizontalFill>
                    <mx:SolidColor color="haloBlue" alpha="0.2" />
                </mx:horizontalFill>
                <mx:horizontalAlternateFill>
                    <mx:SolidColor color="haloSilver" alpha="0.2" />
                </mx:horizontalAlternateFill>
                <mx:verticalFill>
                    <mx:SolidColor color="haloBlue" alpha="0.2" />
                </mx:verticalFill>
                <mx:verticalAlternateFill>
                    <mx:SolidColor color="haloSilver" alpha="0.2" />
                </mx:verticalAlternateFill>
            </mx:GridLines>
        </mx:backgroundElements>


        <mx:verticalAxis>
           <mx:CategoryAxis categoryField="@price" />
        </mx:verticalAxis>
 
        <mx:horizontalAxis>
           <mx:CategoryAxis categoryField="@period"/>
        </mx:horizontalAxis>

        <mx:series>

           <mx:LineSeries yField="@price"  form="curve" 
displayName="Orange" 
dataProvider="{feedRequest.data.result.product}"/>

  <!--     <mx:LineSeries yField="apple" form="curve" 
displayName="Apple"/>
           <mx:LineSeries  yField=""  form="curve" 
displayName="Orange" 
dataProvider="{xdata.data.result.product.price}"/>
             <mx:LineSeries yField="@price" form="curve" 
displayName="Orange" 
dataProvider="feedRequest.lastResult.data.result.inperiod.product" />
           <mx:LineSeries yField="[EMAIL PROTECTED]" form="curve" 
displayName="Orange" />
           <mx:LineSeries yField="orange" form="curve" 
displayName="Orange"/>
           <mx:LineSeries yField="kiwi" form="curve" 
displayName="Kiwi"/>
           
                <mx:LineChart id="chart" 
dataProvider="{feedRequest.lastResult.data.result}" 
showDataTips="true">
           
           FUNCIONOU SEM PAU:
             <mx:LineSeries yField="@product..price" form="curve" 
displayName="Orange" />
                        <mx:CategoryAxis categoryField="months" 
dataProvider="{feedRequest.lastResult.data.result}"/>
           <mx:Array></mx:Array>
           
           -->
        </mx:series>
     </mx:LineChart>
     <mx:Legend dataProvider="{chart}"/>

  </mx:Panel>

  <!--
  <mx:Script>
  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>
     <mx:ColumnChart id="column" dataProvider="{results.income}">
        <mx:horizontalAxis>
           <mx:CategoryAxis
                dataProvider="{results.income}"
                categoryField="month"
           />
        </mx:horizontalAxis>
        <mx:series>
           <mx:ColumnSeries 
                xField="month" 
                yField="profit"
                displayName="Profit"
           />
           <mx:ColumnSeries 
                xField="month" 
                yField="expenses"
                displayName="Expenses"
           />
           <mx:ColumnSeries 
                xField="month" 
                yField="gross"
                displayName="Gross"
           />
        </mx:series>
     </mx:ColumnChart>
     <mx:Legend dataProvider="{column}" />
  </mx:Panel>
  <mx:List id="list" dataProvider="{results.result}" width="130" 
height="100%" dragEnabled="true"/>
-->

 

</mx:Application>




-- 

BR,

Rodrigo Meirelles 

Reply via email to