8 Replies Latest reply on Apr 23, 2007 12:17 PM by Arthur@aginova

    Legends Help

    Arthur@aginova
      How do i control the SHOW / HIDE property of a legend item using actionscript?
      tried applying id to the legend item, flex does not recognize!
      Any Idea?
        • 1. Re: Legends Help
          babo_ya Level 3
          Assign an id to the legend..
          <mx:Legend dataProvider="{myChart}" id="myLegend"/>

          and set the visible property to false/true?
          ???
          Works fine for me...
          • 2. Re: Legends Help
            Arthur@aginova Level 1
            <mx:Legend dataProvider="{myChart}" id="myLegend"/> this will show / hide the complete legend
            i dont wont t show / hide the complete legend! but only specific legend items.
            like if there is
            - apple
            - mango
            - banana

            i would like to control show / hide of apple , mango banana based on checkboxes..
            i tried using :
            <mx:legendItem id='apple' label='apple' visible='true' >
            <mx:legendItem id='banana' label='banana' visible='false'> which works fine
            how do i do this dynamically using action script?
            hope this explains! thanks
            • 3. Re: Legends Help
              babo_ya Level 3
              public var myLegend:LegendItem;

              public var init():void
              {
              myLegend = new LegendItem();
              myLegend.id = "myL";
              myLegend.label = "My Legend";
              this.addChild(myLegend);
              }
              public function hideLegend():void
              {
              myLegend.visible = false;
              }
              public function showLegend():void
              {
              myLegend.visibel = true;
              }
              • 4. Legends Help
                Arthur@aginova Level 1
                Thanks Babo_Ya for the help, this worked, there were some typo, this is the right one:
                public function init():void
                {
                myLegend = new LegendItem();
                myLegend.id = "myL";
                myLegend.label = "My Legend";
                myLegend.visible=false
                this.addChild(myLegend);
                }

                Sorry but, the problem arising now is that flex does not recognize "myL" i.e. the legend item id, i would be having many similar ids of this type for show & hide.

                Any Idea!
                Babo_Ya
                • 5. Re: Legends Help
                  babo_ya Level 3
                  id property never works.....
                  if you want to hide it then use the visible property... don't use the id field. What are you trying to do with id field?
                  • 6. Legends Help
                    Arthur@aginova Level 1
                    i have around 10 series being displayed on the chart, which have the checkboxes for show /hide series,
                    so similarly i would want to show / hide the legend items as well, based on the series selection. How do i easily show / hide many legend items based on the selection.
                    is there a internal property for legenditem like
                    legenditem[0].visible=false,
                    legenditem[1].visible=false so ....on
                    i tried it doesn't work !!!! Any idea
                    Hope i have explained!
                    • 7. Re: Legends Help
                      Oddsy
                      Have a look around the forum and the flexcoders mailing list. This question has been answered several times.
                      • 8. Re: Legends Help
                        Arthur@aginova Level 1
                        couldn't find links for what i want! basically show / hide of legend items based on checkboxes or line series selection