1 Reply Latest reply on Dec 13, 2009 11:06 AM by _Natasha_

    Driving a pie chart from xml file

    fresher4flex Level 1

      Hi , I am trying to drive a pie chart from the  xml file. My xml data is similar to the sample data here ,I tried many ways , but failed.The sample data file is day piedata.xml

       

      <NewDataSet>

      <Table>

          <SCPM>3</SCPM>

          <PM>5</PM>

         </Table>

      </NewDataSet>

      I need to show SCPM and PM  on my pie chart.I tried using httpservice.Can someone send me correct code orcode with any other method(XML collections or array collections).I really appreciate for the help.Thanks in advance
      <mx:HTTPService id="srv" url="piedata.xml" resultFormat="e4x" />
          <mx:Model id="myXML" source="/piedata.xml"/>
           <mx:PieChart id="pie"
                dataProvider="{srv.lastResult.NewDataSet}"
                showDataTips="true"
             height="254">
                <mx:series>
                    <mx:PieSeries  field="Table.item[0].@SCPM"   nameField="Table.@SCPM"
                        labelPosition="callout"            
                    />
                </mx:series>
            </mx:PieChart>

        • 1. Re: Driving a pie chart from xml file
          _Natasha_ Level 4

          Hi,
          In filed-values you can only use attributes (for XML) or properties (for objects). So you can set as a dataProvider collection of Table-elements.
          it should be like this:
          <mx:HTTPService id="srv" url="piedata.xml" resultFormat="e4x" />
              <mx:Model id="myXML" source="/piedata.xml"/>
               <mx:PieChart id="pie"
                    dataProvider="{srv.lastResult.NewDataSet.*}"
                    showDataTips="true"
                 height="254">
                    <mx:series>
                        <mx:PieSeries  field="@SCPM"   nameField="@SCPM"
                            labelPosition="callout"           
                        />
                    </mx:series>
                </mx:PieChart>