6 Replies Latest reply on May 27, 2009 3:16 AM by skrv

    XMLListCollection and Charts

    skrv

      Hi there is a XML list collection XML node is of following format -

       

      <abc>

           <id></id>

           <room_id></room_id>

           <center_id></center_id>

           <name></name>

           <city></city>

           <date></date>

      </abc>

       

      relationship - one center has many rooms

       

      i need to chart -

      x axis -> month and

      y axis -> total number of rooms belonging to that center

      legend is different different centers

       

      I tried the linechart with dataprovider as XLC, how to do runtime selection and calculation on XMLListCollection

       

      should i include more details

       

      Regards,

      Sawan

        • 1. Re: XMLListCollection and Charts
          _Natasha_ Level 4

          Hi,

          may be it's posible.

          What is the format for date element?

          • 2. Re: XMLListCollection and Charts
            skrv Level 1

            date is SQL date element that has date and time

             

            but the date.month gives out the number and that doesnot map collectively into x axis that is --

             

            say i have following entries -

             

            date           name          center_id          room_id

            8/9/09        abc1              1                      1

            8/9/09        abc2              1                      1

            8/9/09        abc3              3                      2

            8/9/09        abc4              3                      1

            8/9/09        abc5              2                      2

            8/10/09        abc6            2                      1

            8/10/09        abc7            1                      1

            8/9/09        abc8              1                      2

            8/9/09        abc9              2                      1

            8/9/09        abc10            2                      1

            8/10/09        abc11          3                      2

            8/9/09        abc12            3                      1

            8/10/09        abc13          3                      1

             

             

            so there are two months sep/oct so these should be there are x axis vs number of rooms on y axis w.r.t center

             

            sep center 1  number of rooms 3

            sep center 2   number of rooms 2

            sep center 3  number of rooms 2

             

            oct center 1  number of rooms 1

            oct center 2   number of rooms 1

            oct center 3  number of rooms 2

             

             

            graph is as follows

             

            tempgraph.png

             

             

             

            How can i go about this?

             

            Regards,

            Sawan

            • 3. Re: XMLListCollection and Charts
              _Natasha_ Level 4

              No, you should prepare data for chart.

              Very difficult:

              select data for only one center (series per center)

              extract month from date

              show count of nodes per month

              • 4. Re: XMLListCollection and Charts
                skrv Level 1

                Yes, issues i am facing is to manipulate XMLListCollection and play with it.

                 

                there are not many examples to manipulate the XMLListCollection [XLC] to do all these the steps as you said are -

                 

                store the XLC in some temp table

                replace all the date fields with there month

                replace all rooms belonging to a single center with center ID [information about which room is lost - we need total number]

                now while showing into the chart how to say that if the month name is same put them in same column

                 

                how can i go about this?

                 

                Regards,

                Sawan

                • 5. Re: XMLListCollection and Charts
                  _Natasha_ Level 4

                  You should create new XLC for dataProvider to chart with data like. And it will be better to save XML from original data.

                  <center id="1">

                  <item month="september" count="3"/>

                  <item month="oct" count="3"/>

                  ..

                  </center> (for each center)

                  ...

                   

                  So first you extract month.

                  for each (var d:XML in oldXML.abc.data)

                  {

                       // parse month and save only month in d

                       // also save all existing unique months

                  }

                  Also you need a list if center ids. If you have it - good. If no

                  for each (var c:XML in oldXML.abc.center_id)

                  {

                  // save unique items to list

                  }

                   

                  After loop in centers list and months

                  for each (var items:XMLList in oldXML.abc.(center_id == current_center_id))

                  {

                  // data for one center

                       for each (var inOneMonth:XMLList in items.(date == current_month))

                  {

                       // add item with month and lenth of XMLList to newDataProvider

                  }

                  }

                  1 person found this helpful
                  • 6. Re: XMLListCollection and Charts
                    skrv Level 1

                    Hmm yes, after reading through above solution and some others i figured that its difficult to work with syntax of XMLListCollection so I converted it to ArrayCollection using IViewCursor and then parsing those tables to create individual chart tables. But now i have to create table for each chart still good as i can export those tables to excel sheet as added feature

                     

                    Thanks for your help Natasha.