0 Replies Latest reply on Jan 28, 2010 5:44 AM by martinbartosh

    Percentage values of presence each XML data in PieChart

    martinbartosh Level 1

      Hi, i have problem with Flex PieChart.

       

      I have XML loaded from php:

      <data><num>5</num>
      <row><wniosekid>1</wniosekid><rodzajwniosku>0</rodzajwniosku></row>
      <row><wniosekid>2</wniosekid><rodzajwniosku>0</rodzajwniosku></row>
      <row><wniosekid>3</wniosekid><rodzajwniosku>1</rodzajwniosku></row>
      <row><wniosekid>4</wniosekid><rodzajwniosku>1</rodzajwniosku></row>
      <row><wniosekid>5</wniosekid><rodzajwniosku>2</rodzajwniosku></row></data>

      I have MXML which i attached to this post.
      Everything looks great but is one problem.

       

      my PieChart pieces look like this: 2 x pieces of "0" (2 x 20%), 2 x pieces of "1" (2 x 20%), and one piece of "2" (1 x 20%).

      So there are 5 pieces by 20% of each.

       

      I would like to my PieChart looks like this: 1 piece of "0" (1 x 40%), 1 x piece of "1" (1 x 40%), and one piece of "2" (1 x 20%).

       

      So i am looking for function counting how often each value is present on my XML. This function also should accept "string" values in XML like this:

       

      <data><num>5</num>
      <row><wniosekid>1</wniosekid><rodzajwniosku>aaa</rodzajwniosku></row>
      <row><wniosekid>2</wniosekid><rodzajwniosku>aaa</rodzajwniosku></row>
      <row><wniosekid>3</wniosekid><rodzajwniosku>bbb</rodzajwniosku></row>
      <row><wniosekid>4</wniosekid><rodzajwniosku>bbb</rodzajwniosku></row>
      <row><wniosekid>5</wniosekid><rodzajwniosku>ccc</rodzajwniosku></row></data>

       

      Should count how often for example 'aaa', 'bbb', or 'ccc' is present on my XML.

      My skill on Flex is poor and  i am looking for solve this problem.