10 Replies Latest reply on Apr 29, 2010 11:21 PM by justin-clarke

    Legend control problems

    kartikjayaraman Level 1
      We are using a Legend control (data provided by a Chart). When the use clicks on an item in the legend, we need to capture this event. We are facing the current problems:

      1. The text in the Legend control needs to be underlined. We have set the textDecoration="underline" as indicated by the API but the text is not underlined.
      2. We want to show a hand cursor when the user hovers on the item. To do this we have set useHandCursor="true" mouseChildren="false" buttonMode="true"
      The problems are (a) If mouseChildren is set to false, we cannot capture the item click event. If its set to true, the hand cursor is shown on the background, not the item text.

      Please advise.
        • 1. Re: Legend control problems
          Level 7

          "kartikjayaraman" <webforumsuser@macromedia.com> wrote in message
          news:gd2mns$b48$1@forums.macromedia.com...
          > We are using a Legend control (data provided by a Chart). When the use
          > clicks
          > on an item in the legend, we need to capture this event. We are facing the
          > current problems:
          >
          > 1. The text in the Legend control needs to be underlined. We have set the
          > textDecoration="underline" as indicated by the API but the text is not
          > underlined.

          Could you post exactly what you tried?

          > 2. We want to show a hand cursor when the user hovers on the item. To do
          > this
          > we have set useHandCursor="true" mouseChildren="false" buttonMode="true"
          > The problems are (a) If mouseChildren is set to false, we cannot capture
          > the
          > item click event. If its set to true, the hand cursor is shown on the
          > background, not the item text.

          I think you'll need to subclass LegendItem to get this behavior.

          HTH;

          Amy


          • 2. Re: Legend control problems
            kartikjayaraman Level 1
            Thanks!

            Can you please give me a quick example on how I do that?

            I dont want to create Legend items as they are sourced by the chart.
            • 3. Re: Legend control problems
              Level 7

              "kartikjayaraman" <webforumsuser@macromedia.com> wrote in message
              news:gd2uqp$kbb$1@forums.macromedia.com...
              > Thanks!
              >
              > Can you please give me a quick example on how I do that?
              >
              > I dont want to create Legend items as they are sourced by the chart.

              Here's an extended LegendItem I used to make the text wrap. You'd just
              override the constructor to set the mouseChildren, etc. properties

              package com.magnoliamultimedia.views
              {
              import flash.display.DisplayObject;

              import mx.charts.LegendItem;
              import mx.core.UITextField;

              public class WrappingLegendItem extends LegendItem
              {
              public function WrappingLegendItem()
              {
              super();
              }
              override protected function createChildren():void{
              super.createChildren();
              for (var i:int=0;i<numChildren; i++){
              var child:DisplayObject=getChildAt(i);
              var txt:UITextField = child as UITextField;
              if (!(txt==null)){
              txt.wordWrap=true;
              txt.invalidateSize();
              }
              }
              }
              }
              }

              It's used like this:

              <mx:Legend dataProvider="{subjectAllAttempts}"
              direction="horizontal" horizontalAlign="center"
              labelPlacement="bottom" verticalAlign="middle"
              legendItemClass="com.magnoliamultimedia.views.WrappingLegendItem"
              />


              • 4. Re: Legend control problems
                kartikjayaraman Level 1
                Ok, I'll try that. What about the textDecoration property set to underline. It doesn't show the text as underlined. Is this a Flex API bug or am I doing something wrong?
                • 5. Re: Legend control problems
                  Level 7

                  "kartikjayaraman" <webforumsuser@macromedia.com> wrote in message
                  news:gd314s$n0b$1@forums.macromedia.com...
                  > Ok, I'll try that. What about the textDecoration property set to
                  > underline. It doesn't show the text as underlined. Is this a Flex API bug
                  > or am I doing something wrong?

                  I don't know what you're doing, so I can't speculate about whether it is
                  wrong or right.


                  • 6. Re: Legend control problems
                    kartikjayaraman Level 1
                    quote:

                    Originally posted by: Newsgroup User

                    "kartikjayaraman" <webforumsuser@macromedia.com> wrote in message
                    news:gd314s$n0b$1@forums.macromedia.com...
                    > Ok, I'll try that. What about the textDecoration property set to
                    > underline. It doesn't show the text as underlined. Is this a Flex API bug
                    > or am I doing something wrong?

                    I don't know what you're doing, so I can't speculate about whether it is
                    wrong or right.






                    All I am doing is setting textDecoration="underline" - shouldnt the items be then underlined?

                    <mx:Legend verticalGap="1" horizontalAlign="left" markerHeight="8" markerWidth="8"
                    width="780" dataProvider="{MyDataProvider}"
                    fontSize="10" id="ChartLegend" textDecoration="underline"
                    height="70" x="10" y="337"
                    useHandCursor="true" mouseChildren="false" buttonMode="true">
                    </mx:Legend>
                    • 7. Re: Legend control problems
                      Level 7

                      "kartikjayaraman" <webforumsuser@macromedia.com> wrote in message
                      news:gd33gk$pn1$1@forums.macromedia.com...
                      >
                      quote:

                      Originally posted by: Newsgroup User
                      >
                      > "kartikjayaraman" <webforumsuser@macromedia.com> wrote in message
                      > news:gd314s$n0b$1@forums.macromedia.com...
                      > > Ok, I'll try that. What about the textDecoration property set to
                      > > underline. It doesn't show the text as underlined. Is this a Flex API
                      > > bug
                      > > or am I doing something wrong?
                      >
                      > I don't know what you're doing, so I can't speculate about whether it is
                      > wrong or right.
                      >
                      >
                      >

                      >
                      >
                      > All I am doing is setting textDecoration="underline" - shouldnt the items
                      > be
                      > then underlined?
                      >
                      > <mx:Legend verticalGap="1" horizontalAlign="left" markerHeight="8"
                      > markerWidth="8"
                      > width="780" dataProvider="{MyDataProvider}"
                      > fontSize="10" id="ChartLegend" textDecoration="underline"
                      > height="70" x="10" y="337"
                      > useHandCursor="true" mouseChildren="false" buttonMode="true">
                      > </mx:Legend>


                      Try:

                      <mx:Style>
                      LegendItem {
                      textDecoration:underline;
                      }
                      </mx:Style>


                      • 8. Re: Legend control problems
                        kartikjayaraman Level 1
                        Thansk Amy, however that does not work too. I have tried almost everything and cant get the text in the Legend item to be underlined.

                        Can you please try to add a Legend Control and see if it the textDecoration="underline" works for you?
                        • 9. Re: Legend control problems
                          kartikjayaraman Level 1
                          Anyone having a similar problem with the Legend control?
                          • 10. Re: Legend control problems
                            justin-clarke Level 1

                            A few years too late, but yes I had exactly the same problem trying to get useHandCursor working across LegendItems. By specifying a custom LegendItem class which sets the appropriate values it works successfully:

                             

                            <mx:Legend

                                 legendItemClass="CustomLegendItem"

                                 ...

                            />

                             

                            package{

                              public class CustomLegendItem extends LegendItem
                              {
                               
                                public function CustomLegendItem()
                                {
                                  super();
                                  this.useHandCursor = true;
                                  this.buttonMode = true;
                                  this.mouseChildren = false;
                                }
                              }
                            }