11 Replies Latest reply on Sep 9, 2010 8:17 AM by Cheree Singal

    Flex Charting: Removing Duplicate Categories

    shawnyale
      In line with my previous post regarding charts, I have a data set that I need to group into categories. When I create my chart, Im getting duplicate labels on the axis for the category. I need to only have one group for each category.

      So for example:
      {name:"Red', value:1, other:"Happy"},
      {name:"Red', value:1, other:"Sad"},
      {name:"Red', value:1, other:"Glad"},
      {name:"Blue', value:1, other:"Happy"},
      {name:"Blue', value:1, other:"Sad"},
      {name:"Blue', value:1, other:"Glad"}

      I want a group on my chart for all of the Red items, and one for all of the blue items but what Im getting back is 3 red labels and 3 blue labels.

      Can flex charts not combine these into a single label item?

      Thanks
        • 1. Re: Flex Charting: Removing Duplicate Categories
          Level 7

          "shawn.yale" <syale@triad.rr.com> wrote in message
          news:gh11cj$ht9$1@forums.macromedia.com...
          > In line with my previous post regarding charts, I have a data set that I
          > need
          > to group into categories. When I create my chart, Im getting duplicate
          > labels
          > on the axis for the category. I need to only have one group for each
          > category.
          >
          > So for example:
          > {name:"Red', value:1, other:"Happy"},
          > {name:"Red', value:1, other:"Sad"},
          > {name:"Red', value:1, other:"Glad"},
          > {name:"Blue', value:1, other:"Happy"},
          > {name:"Blue', value:1, other:"Sad"},
          > {name:"Blue', value:1, other:"Glad"}
          >
          > I want a group on my chart for all of the Red items, and one for all of
          > the
          > blue items but what Im getting back is 3 red labels and 3 blue labels.
          >
          > Can flex charts not combine these into a single label item?

          Look at GroupingCollections and assign one group to each series.

          HTH;

          Amy


          • 2. Re: Flex Charting: Removing Duplicate Categories
            shawnyale Level 1
            do grouping collections work with column charts?
            i havent been able to get them to work.
            :(
            • 3. Re: Flex Charting: Removing Duplicate Categories
              shawnyale Level 1
              do grouping collections work with column charts?
              i havent been able to get them to work.
              :(
              • 4. Re: Flex Charting: Removing Duplicate Categories
                shawnyale Level 1
                do grouping collections work with column charts?
                i havent been able to get them to work.
                :(
                • 5. Re: Flex Charting: Removing Duplicate Categories
                  shawnyale Level 1
                  Can someone post an example of how to use grouping collections in the manner Ive described?

                  ill owe you a beer.
                  • 6. Re: Flex Charting: Removing Duplicate Categories
                    Level 7

                    "shawn.yale" <syale@triad.rr.com> wrote in message
                    news:gh13je$kid$1@forums.macromedia.com...
                    > do grouping collections work with column charts?
                    > i havent been able to get them to work.
                    > :(

                    I would think that setting the series dataprovider to something like this:
                    yourGroupingCollection.getRoot().getItemAt(someIndex).children

                    should work.

                    What have you tried?


                    • 7. Re: Flex Charting: Removing Duplicate Categories
                      shawnyale Level 1
                      Ive tried both the grouping collection and the column set and neither seems to be working correctly.

                      I try to pull from my xml collection like this:

                      [Bindable]
                      private var xml2:XML=
                      <root>
                      <AnnualItem processLabel="Red">
                      <item interval="Y2005" score="4.5"/>
                      <item interval="Y2006" score="3.5"/>
                      <item interval="Y2007" score="1.5"/>
                      </AnnualItem>
                      <AnnualItem processLabel="Green">
                      <item interval="Y2005" score="2.5"/>
                      <item interval="Y2006" score="4.5"/>
                      <item interval="Y2007" score="4.5"/>
                      </AnnualItem>
                      <AnnualItem processLabel="Yellow">
                      <item interval="Y2005" score="1.5"/>
                      <item interval="Y2006" score="2.5"/>
                      <item interval="Y2007" score="4.5"/>
                      </AnnualItem>
                      </root>;


                      <mx:ColumnChart x="10" y="48" id="columnchart1" columnWidthRatio=".4" showDataTips="true">

                      mx:GroupingCollection source="{xml2.AnnualItem}" id="gcl" childrenField="item">

                      <mx:Grouping>
                      <mx:GroupingField name="processLabel"/>
                      </mx:Grouping>
                      </mx:GroupingCollection>

                      <mx:horizontalAxis>
                      <mx:CategoryAxis dataProvider="{gcl}" categoryField="processLabel"/>
                      </mx:horizontalAxis>

                      <mx:series>
                      <mx:ColumnSeries dataProvider="{gcl}" yField="score" xField="interval"/>
                      </mx:series>

                      I want to group my items in order by category.

                      So on my axis I want one "Red" category with 3 different column bars. Each column bar should represent 1 of the item values from the xml.

                      then I want one "Green" category with the correct values.

                      and then one "Yellow" category.

                      As an aside:
                      Whenever I do get something to work, the chart renders all of the column bars the same height.

                      When I try the above, I get an error stating that the groupingCollection does not have a value of "score."

                      there has got to be an easy way to display this data. At least I would think.

                      Thank you for looking at this.
                      • 8. Re: Flex Charting: Removing Duplicate Categories
                        Level 7

                        "shawn.yale" <syale@triad.rr.com> wrote in message
                        news:gh19qf$s3h$1@forums.macromedia.com...
                        > Ive tried both the grouping collection and the column set and neither
                        > seems to
                        > be working correctly.
                        >
                        > I try to pull from my xml collection like this:
                        >
                        > [Bindable]
                        > private var xml2:XML=
                        > <root>
                        > <AnnualItem processLabel="Red">
                        > <item interval="Y2005" score="4.5"/>
                        > <item interval="Y2006" score="3.5"/>
                        > <item interval="Y2007" score="1.5"/>
                        > </AnnualItem>
                        > <AnnualItem processLabel="Green">
                        > <item interval="Y2005" score="2.5"/>
                        > <item interval="Y2006" score="4.5"/>
                        > <item interval="Y2007" score="4.5"/>
                        > </AnnualItem>
                        > <AnnualItem processLabel="Yellow">
                        > <item interval="Y2005" score="1.5"/>
                        > <item interval="Y2006" score="2.5"/>
                        > <item interval="Y2007" score="4.5"/>
                        > </AnnualItem>
                        > </root>;

                        You don't need a GroupingCollection with this dataSet, as it is already
                        grouped. Just assign each series's dataProvider to a different AnnualItem.

                        HTH;

                        Amy


                        • 9. Flex Charting: Removing Duplicate Categories
                          shawnyale Level 1
                          Thank you for all your help Amy!
                          I set this xml up to make the grouping easier.
                          My actual xml isnt grouped like this.
                          Its more like

                          <interval="2007" processLabel="Red" score=1.5/>
                          <interval="2007" processLabel="Green" score=4.5/>
                          <interval="2007" processLabel="Yellow" score=1.5/>
                          <interval="2006" processLabel="Red" score=0.5/>
                          <interval="2006" processLabel="Green" score=1.5/>
                          <interval="2006" processLabel="Yellow" score=3.5/>
                          <interval="2005" processLabel="Red" score=2.5/>
                          <interval="2005" processLabel="Green" score=2.5/>
                          <interval="2005" processLabel="Yellow" score=1.5/>



                          Unfortunately, its still not working. When I trace through my groupingCollection (even in actionscript) I don't see any changes to my data. These are the only values in my groupingcollection:

                          dsGroupColl = mx.collections.GroupingCollection (@76b5761)
                          childrenField = "children"
                          grouping = mx.collections.Grouping (@7b09cb9)
                          compareFunction = null
                          fields = Array (@7b0e389)
                          [0] = mx.collections.GroupingField (@7b0e351)
                          caseInsensitive = false
                          compareFunction = null
                          descending = false
                          groupingFunction = null
                          groupingObjectFunction = null
                          name = "processLabel"
                          numeric = false
                          summaries = null
                          length = 1
                          groupingObjectFunction = null
                          label = "GroupLabel"
                          optimizeSummaries = false
                          source = mx.collections.ArrayCollection (@78ead81)
                          summaries = null

                          There is nothing in there indicating that the list has even been grouped. I opened the source and even that remains in the original non-grouped order.

                          There doesn't appear to be anything indicating any form of change.

                          When I bind off of the groupingCollection, as in
                          <mx:ColumnChart dataProvider="{groupColl}">
                          <mx:series>
                          <mx:ColumnSeries yField="score" xField="interval"/>
                          </mx:series>
                          </mx:ColumnChart.

                          I get an error stating that 'score is not a property on groupingCollection."

                          I guess the only thing Im going to be able to do is to create a stack of arrays and break apart my datasource which will be awful in the way of performance.

                          I dont know what else to do here. I need each of the three years values to display separately in each of the three groups.

                          I will be more than happy to show you my full code if you think it will help. The main problem is that in reality, I will not know how many groups nor how many years will arrive for each group and I was hoping to make this process dynamic.
                          • 10. Re: Flex Charting: Removing Duplicate Categories
                            Level 7

                            "shawn.yale" <syale@triad.rr.com> wrote in message
                            news:gh1f9c$54r$1@forums.macromedia.com...
                            > Thank you for all your help Amy!
                            > I set this xml up to make the grouping easier.
                            > My actual xml isnt grouped like this.
                            > Its more like
                            >
                            > <interval:2007, processLabel:"Red", score:1.5/>
                            > <interval:2007, processLabel:"Green", score:4.5/>
                            > <interval:2007,processLabel:"Green", score:3.5/>
                            > <interval:2007,processLabel:"Yellow", score:3.5/>
                            > <interval:2006, processLabel:"Red", score:4.5/>
                            >
                            >
                            > Unfortunately, its still not working. When I trace through my
                            > groupingCollection (even in actionscript) I don't see any changes to my
                            > data.
                            > These are the only values in my groupingcollection:
                            >
                            > dsGroupColl = mx.collections.GroupingCollection (@76b5761)
                            > childrenField = "children"
                            > grouping = mx.collections.Grouping (@7b09cb9)
                            > compareFunction = null
                            > fields = Array (@7b0e389)
                            > [0] = mx.collections.GroupingField (@7b0e351)
                            > caseInsensitive = false
                            > compareFunction = null
                            > descending = false
                            > groupingFunction = null
                            > groupingObjectFunction = null
                            > name = "processLabel"
                            > numeric = false
                            > summaries = null
                            > length = 1
                            > groupingObjectFunction = null
                            > label = "GroupLabel"
                            > optimizeSummaries = false
                            > source = mx.collections.ArrayCollection (@78ead81)
                            > summaries = null
                            >
                            > There is nothing in there indicating that the list has even been grouped.
                            > I
                            > opened the source and even that remains in the original non-grouped order.
                            >
                            > There doesn't appear to be anything indicating any form of change.
                            >
                            > When I bind off of the groupingCollection, as in
                            > <mx:ColumnChart dataProvider="{groupColl}">
                            > <mx:series>
                            > <mx:ColumnSeries yField="score"/>
                            > </mx:series>
                            > </mx:ColumnChart.
                            >
                            > I get an error stating that 'score is not a property on
                            > groupingCollection."
                            >
                            > I guess the only thing Im going to be able to do is to create a stack of
                            > arrays and break apart my datasource which will be awful in the way of
                            > performance.
                            >
                            > I dont know what else to do here. I need each of the three years values
                            > to
                            > display separately in each of the three groups.

                            Set the dataprovider on the SERIES, which is what I've been telling you all
                            along. And set it to the ITEM in the GroupingCollection that corresponds to
                            the grouping that you want shown. I don't have time to make you an example,
                            so you're going to have to accept a point in the right direction, read the
                            docs, and put it together for yourself.


                            • 11. Re: Flex Charting: Removing Duplicate Categories
                              Cheree Singal Level 1

                              Hi Shawn

                              Were you able to get it working? I have the same problem. Any help would be really appreciated.

                               

                              Thanks

                              Cheree