1 Reply Latest reply on Jul 8, 2009 12:33 AM by Richard_Abbott

    chart problem

    benkayam
      I'm having some difficulty creating a chart i wonder if you could help me.
      my data provider is a xml file, the main issue is that i have couple of point on each time point (as you can see in the xml)
      is there a way to sort the data, get only the higher point for each time point?
      see attached xml file
      thank you

      NewDataSet>

      - <Table>

      <time>09:30:00</time>

      <rate>19340</rate>

      </Table>

      - <Table>

      <time>09:45:00</time>

      <rate>19420</rate>

      <paperVolume>7253</paperVolume>

      </Table>

      - <Table>

      <time>09:45:00</time>

      <rate>19430</rate>

      <paperVolume>7282</paperVolume>

      </Table>

      - <Table>

      <time>09:46:00</time>

      <rate>19430</rate>

      <paperVolume>7301</paperVolume>

      </Table>

      - <Table>

      <time>09:46:00</time>

      <rate>19440</rate>

      <paperVolume>7501</paperVolume>

      </Table>

      - <Table>

      <time>09:46:00</time>

      <rate>19440</rate>

      <paperVolume>7542</paperVolume>

      </Table>

      - <Table>

      <time>09:46:00</time>

      <rate>19420</rate>

      <paperVolume>7557</paperVolume>

      </Table>

      - <Table>

      <time>09:46:00</time>

      <rate>19420</rate>

      <paperVolume>7861</paperVolume>

      </Table>

      - <Table>

      <time>09:46:00</time>

      <rate>19420</rate>

      <paperVolume>7949</paperVolume>

      </Table>

      - <Table>

      <time>09:49:00</time>

      <rate>19440</rate>

      <paperVolume>8052</paperVolume>

      </Table>

        • 1. Re: chart problem
          Richard_Abbott Level 3

          benkayam,

          there are a couple of steps here.

          First, I would get your XML sorted with the highest paperVolume value first in each block. For this you need to cast the XML explicitly to XMLListCollection and then use the sort capability that this class gives you (alternatively, you may be generating the XML from somewhere that will just give you this for free - I wasn't sure from your description). Cast your results back into plain XML for convenience. This step is not crucial but simplifies the logic of step 2.

          Second, you need to create a new XML object, iterate through the XML resulting from step 1 and only append the node if you don't already have an entry at that time slot.

          If you chose to skip step 1, then your logic in step 2 should be to _either_ append the node if it is a new timeslot, _or_ update the correct one if the paperVolumecount is larger.

          The heart of the solution is the second XML object which you generate from the first. It would be nice if Flex XML objects had the equivalent of SQL select distinct but they don't. The logic of this iteration is something like

                      for (index=0; index<original_list.length(); index++)
                      {
                          item = original_list[index].toString();
                          if (unique_contents.indexOf(item)<0)
                          {
                              unique_contents.push(item);
                          } // if not found
                      } // for index

          Hope that helps,

          Richard