4 Replies Latest reply on Aug 12, 2011 5:31 AM by Flex4Education

    Flex Piechart labelfield isn't display if there is just 1 value

    Flex4Education

      Hi @ all 

       

      I have some Piechart where the label should be displayed inside. But if there is only 1 value in this Pie the Label isn't displayed.
      Is there a solution for that?

       

      F4E

        • 1. Re: Flex Piechart labelfield isn't display if there is just 1 value
          Pooja Kuber Level 2

          Could you please post a code snippet here?

           

          Thanks and Regards,

          ...................................................................... ................................................

          Pooja Kuber | pkuber@infocepts.com |http://www.infocepts.com

          ...................................................................... .................................................

          • 2. Re: Flex Piechart labelfield isn't display if there is just 1 value
            Flex4Education Level 1

            of course:

            I've this piechart->

             

             

             

            <?xml version="1.0" encoding="utf-8"?>
            <mx:PieChart xmlns:mx="http://www.adobe.com/2006/mxml"
            dataProvider="{chartContent}"
            showDataTips="true"
            doubleClickEnabled="true" doubleClick="piechart1_doubleClickHandler(event)">

             

            <mx:series>

            <mx:PieSeries id="ps1"
            field="count"
            labelField="count" labelPosition="inside"
            nameField="description"
            explodeRadius="0.1" fills="{[c3,c4,c5,c2,c1]}"/>
            </mx:series>
            </mx:PieChart>

             

            and if chartContent looks looks like that ->

            chartContent.addItem({

            description: "blabla",

            count: 1

            )}

             

            The label isn't displayed. But if i have the same chart with more values like this:

             

            chartContent.addItem({

            description: "blabla",

            count: 1

            )}

             

            chartContent.addItem({

            description: "blabla2",

            count: 3

            )}

             

            It works fine. There is just no Label if there is just one Item in the dataprovider

            • 3. Re: Flex Piechart labelfield isn't display if there is just 1 value
              Pooja Kuber Level 2

              Hi,

               

              The LablePosition=" inside"  property – Draw labels inside the chart, centered  approximately seven tenths of the way along each wedge. Any label that must be drawn too small, as defined by the insideLabelSizeLimit property, is hidden from view.

               

              In this case when there is only one item in the dataprovider, the size of the lable is getting too small and thus it is being hidden from the view.

               

              Solution for this issue is use  LablePosition=" insideWithCallout" which will call out the lable when there is only one value in dataprovider else will show the lables inside the wedges.

               

              Sample code:

              <?xml version="1.0" encoding="utf-8"?>
              <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
                              creationComplete="init()">
                  <mx:Script>
                      <![CDATA[
                          import mx.collections.ArrayCollection;
                          [Bindable]
                          public var chartContent:ArrayCollection=new ArrayCollection();

                          public function init():void
                          {
                              chartContent.addItem({description: "blabla", count: 6213212});
                            
                          /*     chartContent.addItem({
                              description: "blabla2",
                              count: 3124214
                              });  */
                          }

                      ]]>
                  </mx:Script>
                  <mx:PieChart dataProvider="{chartContent}"
                               showDataTips="true"
                               doubleClickEnabled="true">



                      <mx:series>

                          <mx:PieSeries id="ps1"
                                        field="count"
                                        labelPosition="insideWithCallout"
                                        nameField="description"
                                        explodeRadius="0.1"/>
                      </mx:series>
                  </mx:PieChart>

              </mx:Application>

               

              Thanks and Regards,

               

              ...................................................................... ................................................

               

              Pooja Kuber | pkuber@infocepts.com |http://www.infocepts.com

               

              ...................................................................... .................................................

              • 4. Re: Flex Piechart labelfield isn't display if there is just 1 value
                Flex4Education Level 1

                Thank you a lot!

                 

                It doesn't look very good with the callout, but you've answered all my questions!

                Great Answer

                 

                Thx F4E