2 Replies Latest reply on Nov 2, 2007 7:07 AM by curtkauf

    Chart from .Net Web Service

    curtkauf
      Can anyone help me I'm pretty new to flex. I am pulling data from a C#.net web service. It is a simple chart that has four vertical bars. How do I get the data to populate the chart. ArrayCollection? if so how? I think I have tried everything and I can't get it to work. I'm sure it's me and I am making it more complicated then it really is. Any help would be appreciated. Thanks!
      curtkauf
        • 2. Re: Chart from .Net Web Service
          curtkauf Level 1
          There is something simple I don't understand. The webservice is a simple select from a SQL database that brings back a small dataset that I convert into an array and dumb into xml. It has the following fields:

          product_offering
          shipment_count
          total_revenue
          total_weight

          It works fine in a data grid, but does nothing in a chart. Here is my Flex code...

          l version="1.0" encoding="utf-8"?>
          <mx:Application xmlns:mx=" http://www.adobe.com/2006/mxml"
          backgroundGradientColors="[#8000ff, #8000ff]">

          <mx:Style source="main.css"/>

          <mx:WebService id="wsReports"
          wsdl=" http://localhost:1602/CS_Webservice/Reports.asmx?wsdl"
          useProxy="false"
          fault="Alert.show(event.fault.faultString), 'Error'">


          <!-- this operation determines if the user is valid -->
          <mx:operation name="DailyReport">
          <mx:request>
          <dteShipDate>{this.dteDate.selectedDate.toDateString()}</dteShipDate>
          </mx:request>
          </mx:operation>
          </mx:WebService>


          <mx:Script>
          <![CDATA[

          import mx.controls.Alert;
          import mx.collections.ArrayCollection;
          import mx.utils.ArrayUtil;


          [Bindable]
          private var dailyRevenue:ArrayCollection;

          public function runService():void{

          this.wsReports.DailyReport.send();
          dailyRevenue = wsReports.DailyReport.lastResult;
          this.lbl.text=this.dteDate.selectedDate.toDateString();
          }

          ]]>
          </mx:Script>

          <mx:ApplicationControlBar width="100%">
          <mx:DateField width="99" id="dteDate"/>
          <mx:Button label="Run" id="btnDailyRun" click="{runService()}"/>
          <mx:Label text="Label" width="116" height="20" id="lbl"/>

          </mx:ApplicationControlBar>
          <mx:DataGrid dataProvider="{wsReports.DailyReport.lastResult}" width="100%">

          <mx:columns>
          <mx:Array>
          <mx:DataGridColumn headerText="Product" dataField="product_offering"/>
          <mx:DataGridColumn headerText="Shipments" dataField="shipment_count"/>
          <mx:DataGridColumn headerText="Revenue" dataField="total_revenue"/>
          <mx:DataGridColumn headerText="Weight" dataField="total_weight"/>

          </mx:Array>
          </mx:columns>
          </mx:DataGrid>
          <mx:ColumnChart id="dailyRevChart" width="100%" height="100%" dataProvider="{dailyRevenue}">

          <mx:series>
          <mx:ColumnSeries xField="total_revenue" yField="total_revenue" displayName="Dock Drop Distribution" />
          <mx:ColumnSeries xField="total_revenue" yField="total_revenue" displayName="Dated Release" />
          <mx:ColumnSeries xField="total_revenue" yField="total_revenue" displayName="Miscellaneous" />
          <mx:ColumnSeries xField="total_revenue" yField="total_revenue" displayName="U.S. Postal Service" />
          <mx:ColumnSeries xField="total_revenue" yField="total_revenue" displayName="Consolidation" />
          <mx:ColumnSeries xField="total_revenue" yField="total_revenue" displayName="Expedited" />
          </mx:series>

          </mx:ColumnChart>
          <mx:Legend dataProvider="{dailyRevChart}" autoLayout="false" width="100%" height="30" horizontalAlign="center" direction="horizontal"/>

          </mx:Application>

          Please give me any help you can. I know I'm missing something simple.

          Thanks!