6 Replies Latest reply on Jun 5, 2008 10:13 AM by Developer504

    Displaying data in Column Chart  from HTTPService

    Developer504
      I'm trying to display some data from an XML file in a Column Chart. My app is passing debugger but I'm not seeing any data. I created a datagrid to see if I my source etc. was ok, and I am seeing the data just fine in the Datagrid, but nothing in the Column Chart.

      Here is my chart:

      <mx:ColumnChart x="325" y="50" id="columnchart1" height="195" dataProvider="{myService2.lastResult.sector.company}">

      <mx:series>
      <mx:ColumnSeries displayName="custId" xField="custId" yField="amount"/>
      </mx:series>
      </mx:ColumnChart>

      Here is my WS

      <mx:HTTPService id="myService2" url="C:\path\data1.xml" resultFormat="e4x"/>

      (I also tried it without e4x)

      and here is the data

      <sector id="new customers">
      <company custId="VTC" amount="186.00" number=".385" custName="Variant Technology Corporation"/>
      <company custId="ABC" amount="111.00" number=".221" custName="Associated Building Corporation"/>
      <company custId="EFF" amount="122.00" number=".111" custName="Electronic Frontier Fondation"/>
      <company custId="CNT" amount="158.00" number=".577" custname="Computerised National Training"/>
      </sector>

      What am I missing?
        • 1. Re: Displaying data in Column Chart  from HTTPService
          Developer504 Level 1
          Do I need to put it into an XMLList before I can read it in the Chart?
          • 2. Re: Displaying data in Column Chart  from HTTPService
            Developer504 Level 1
            Is anyone here familiar with charting?
            • 3. Displaying data in Column Chart  from HTTPService
              VarioPegged Level 2
              Best practice would be to use a bindable variable for your data provider in the ColumnChart that gets set in a result handler the same way you've been provided examples before. Also, like you've seen and used before in your TreeMap app, an attribute within an XML element is referred to with an @. Note also the <mx:horizontalAxis> that was added to your code.

              TS
              • 4. Displaying data in Column Chart  from HTTPService
                Developer504 Level 1
                Thanks a lot VarioPegged,

                No I didn't realize that the @ was required to refer to an XML element. I've only done two flex Apps so far, the Treemap is using some borrowed code I found online (written by Josh Tynjala) and the other project I did involved directly binding XML results to a Datagrid, which did not require directly referring to any of the elements (and had no @). I thought the @ was simply part of the field names.

                I actually had already made my field bindable.

                I missed this ampersand and apparently, other significant things. Once my basic familiaritiy with Flex is a bit more solid I should be able to make a more valuable contribution to this forum. I'm sorry if I seem a little dense.

                I have tried these suggestions and I'm still not seeing any data, I'll continue to try different things and consult my Flex books.

                D
                • 5. Re: Displaying data in Column Chart  from HTTPService
                  VarioPegged Level 2
                  Not a problem. I try to help where possible, but sometimes it's most beneficial to research these problems yourself. There's so much good information in the Flex documentation.

                  To get back to your problem, make sure that when you assign the result to your dp that you specify it as something like this (because you're handling E4X XML, your result is already at sector, so don't refer to it again):

                  dp = event.result.company;

                  TS
                  • 6. Displaying data in Column Chart  from HTTPService
                    Developer504 Level 1
                    Thanks Vario! That was the last piece of the puzzle, I was referring to event.result.sector.company.

                    I see so many new people on this forum, there must be a lot of people moving into Flex. Hopefully I'll begin to be able to help with the very simple things soon, I already have once or twice.

                    Meanwhile I agree there is also a wealth of good examples online, I have been using them quite a bit. By contrast, I've bought five (expensive!) Flex books and I'm somewhat disappointed, while each is good it seems each lacks certain important features, so I really have to rely on all of them. Most disappointing is the official Flex documentation itself, because it seems very informative but it lacks an index for some strange reason.

                    D