6 Replies Latest reply on Nov 30, 2010 7:11 AM by TheGarfunkal

    Can't change dataprovider of a Pie Chart

    TheGarfunkal

      Hiya

       

      I'm sure I'm being a bit dense, but I don't seem to be able to update a dataprovider for a pie chart.  The plan is to filter the results..... but one thing at a time!

       

      Anyway

       

      I have two arraycollections:  RagPie and RagPieDrill (its not really a drill - ignore the terminology) I debugged to check and both have data in when the page loads.

       

      All I am trying to do is switch the data in the chart.  The second AC is created when the page loads and does have data.

       

      Below is my mxml;

       

      <mx:PieChart  id="pcBuildSummary"

       

      creationComplete="{PodContentBase.RagPie()}"

      dataProvider = "{PodContentBase._RagPie}"

       

      itemClick="imhittingit(event)">

      <mx:series>

      <mx:PieSeries id = "pcBuild" 

              field="Volume"

               nameField="RAG"

               explodeRadius="0.05"

               fillFunction="PieFilling">    

      </mx:PieSeries>

      </mx:series>

      </mx:PieChart>

       

      And the AS that is meant to be updating: (its in a hitData to allow me to filter the second AC later)

       

      private function imhittingit(e:ChartItemEvent):void {

      pcBuildTeamBuildSummary.dataProvider = PodContentBase._RagPieDrill;

      pcBuild = new PieSeries;

      pcBuild.field = "Volume";

      pcBuild.nameField = "Breached";

      //pcBuildTeamBuildSummary.validateNow();

      trace("field " + pcBuild.field)

      trace("name " + pcBuild.nameField)

      }

       

      Can anyone help?  Much thanks

       

      Andrew

        • 1. Re: Can't change dataprovider of a Pie Chart
          Aurelien Vannieuwenhuyze Level 1

          Hello,

           

          Can you post your code of the PodContentBase.RagPie() method ?

           

          thanks

           

          Regards

          • 2. Re: Can't change dataprovider of a Pie Chart
            MartinHviid Level 2

            Hi Andrew

             

            I have looked a bit at you example, but I can't really understand it.

            There are some objects you got to explain a bit more if I have to help.

            Like:

            PodContentBase

            PodContentBase._RagPie

            pcBuildTeamBuildSummary Vs. pcBuildSummary

             

            Cheers

            Martin

            • 3. Re: Can't change dataprovider of a Pie Chart
              Aurelien Vannieuwenhuyze Level 1

              Hello,

               

              Can you post the code of the PodContentBase.RagPie() ?

               

              Thanks

               

              Regards.

              • 4. Re: Can't change dataprovider of a Pie Chart
                TheGarfunkal Level 1

                Martin!

                 

                Ugly scenes here - you are right to want to look at

                pcBuildSummaryBuildSumary v pcBuildSummary

                 

                pcBuildSummaryBuildSumary is incorrect - i've been trying to update an incorrect/non exisitant Piechart.. for hours.

                 

                i feel 100% stupid - sorry for wasting everyones time - although i fully expect to fail on filtering the AC.

                 

                thanks guys

                 

                 

                • 5. Re: Can't change dataprovider of a Pie Chart
                  MartinHviid Level 2

                  Np, also seemed a bit strange, some times looking at code to much makes you blind.

                   

                  Please rate answer

                   

                  Cheers

                  Martin

                  • 6. Re: Can't change dataprovider of a Pie Chart
                    TheGarfunkal Level 1

                    it looks all good now  - Last issue... (pushing luck)

                     

                    When it changes dataprovider, it doesnt alter the nameField label - it labels it 'Null'  - its fine for the other AC - even when it switches back.

                     

                    I 'think' I have the nameField right, but that fact that the numeric in both AC's are the same makes me feel that its an accdient that the second  dataprovider works at all -

                     

                    Debugger for second AC

                     

                    debugger.JPG

                     

                     

                    AS.

                     

                     

                      private function imhittingit(e:ChartItemEvent):void {

                     

                     

                           var RAG:String  = e.hitData.item.RAG;

                        

                            if (RAG == "Green"){

                         PodContentBase._RagPieData = "G"}

                         else if (RAG== "Red"){

                         PodContentBase._RagPieData = "R"}

                         else if (RAG== "Amber"){

                         PodContentBase._RagPieData = "A"}

                         else {

                         PodContentBase._RagPieData = "ChangeDP"};   

                     

                    if (PodContentBase._RagPieData == "ChangeDP"){

                    pcBuildSummary.dataProvider = PodContentBase._RagPie;

                    pcBuild = new PieSeries;

                    pcBuild.field = "Volume";

                    pcBuild.nameField = "RAG";

                    PodContentBase._RagPieDrill.refresh();

                    }

                    else {

                    pcBuildSummary.dataProvider = PodContentBase._RagPieDrill;

                    pcBuild = new PieSeries;

                    pcBuild.field = "Volume";

                    pcBuild.nameField = "Breached";

                    PodContentBase._RagPieDrill.filterFunction = filterFunc;

                    PodContentBase._RagPieDrill.refresh();

                     

                      }

                      }

                     

                     

                     

                    MXML

                     

                     

                    <mx:PieChart  id="pcBuildSummary"

                     

                    creationComplete="{PodContentBase.RagPie()}"

                    dataProvider = "{PodContentBase._RagPie}"

                    itemClick="imhittingit(event)"

                    >

                    <mx:series>

                    <mx:PieSeries id = "pcBuild" 

                            field="Volume"

                             nameField="RAG"     

                    </mx:PieSeries>

                    </mx:series>

                    </mx:PieChart>

                     

                    the two queries to pull data back (just the main function - not the full code - It doesnt bring back the data)

                     

                     

                    public static function RagPie():void {

                     

                    mssqlQuery("SELECT CASE SLARag WHEN 'R' THEN 'Red' WHEN 'A' THEN 'Amber' WHEN 'G' THEN 'Green' WHEN 'RR' THEN 'Dark Red'  END as  RAG , COUNT (Slarag)  as  Volume FROM [CMI_ClientMI].[Portal].[BatchUpdate] WHERE ID in ( SELECT MAX([Id]) [Application] FROM  [CMI_ClientMI].[Portal].[BatchUpdate] group by Application )  group by SLARag ORDER BY  CASE SLARag  WHEN 'RR' THEN 1 WHEN 'R' THEN 2 WHEN 'A' THEN 3 WHEN 'G' THEN 4 END ", "RagPie");

                     

                    }

                     

                     

                    public static function RagPieDrill():void {

                     

                        mssqlQuery("SELECT Breached, SLARag,  Sum(Volume) as Volume FROM [CMI_ClientMI].[Portal].[vwRagBreach] GROUP BY  Breached, Sort, SLARag ORDER BY Sort","RagPieDrill");

                     

                      }