5 Replies Latest reply on Oct 19, 2010 3:52 PM by Devtron

    Chart Legend: Worked in Beta, No longer working in Prod

    egmendez

      Hi everybody,

       

      The legend attached to the LineChart is no longer displaying the proper color. That is, the line, in the linechart is red (as requested) but the "legend" is black. It is supposed to be a red square and the word "Jobs" but I get a black square (as it is not picking the fact that it should be red).

       

      <s:SolidColorStroke id="s3" color="red" />

      ...

      <mx:Legend dataProvider="{myChart}" />

      ....

      <mx:LineChart id="myChart"

        x="10" y="40" width="600" height="400"

        dataProvider="{platformsData}"

        showDataTips="true" >

      ....

      <mx:series>

      <mx:LineSeries yField="id" displayName="Jobs" lineStroke="{s3}"/>

      </mx:series>

      </mx:LineChart>

      This worked in Beta but no longer works in Production. Is this a bug or I need to make coding changes to accommodate to new Production ways of dealing with this?
      Regards,
      egm

        • 1. Re: Chart Legend: Worked in Beta, No longer working in Prod
          Ansury Level 3

          Seems like a bug to me.  If you remove lineStroke="{s3}", the chart legend loads fine.

           

          Might have something to do with fill color perhaps?

           

          In any case, the fills documentation says:

          "If you specify the fills property and you want to have a Legend  control, you must manually create a Legend control and add LegendItems to it."

           

          Perhaps the entry for lineStroke should say the same.

           

          In the mean time you could use the defaults, or a custom Legend, like this (place into an AIR 2 project if you try running it):

           

           

          <?xml version="1.0" encoding="utf-8"?>
          <s:WindowedApplication xmlns:fx="http://ns.adobe.com/mxml/2009" 
                                      xmlns:s="library://ns.adobe.com/flex/spark" 
                                      xmlns:mx="library://ns.adobe.com/flex/mx" width="1059" height="722">
               
               <fx:Script>
                    <![CDATA[
                         import mx.events.FlexEvent;
                         [Bindable]
                         public var platformsData:Array = [{id:1, jobs:'Test1'},{id:4, jobs:'Test2'},{id:6, jobs:'Test3'},{id:9, jobs:'Test4'}];
                    ]]>
               </fx:Script>
               
               <fx:Declarations>
                    <s:SolidColorStroke id="s3" color="0xFF0000" weight="2" alpha=".8"/>
               </fx:Declarations>
               
               <mx:Legend>
                    <mx:LegendItem label="Jobs" fontWeight="bold">
                         <mx:fill>
                              <mx:SolidColor color="0xFF0000"/>
                         </mx:fill>
                         <mx:stroke>
                              <mx:SolidColorStroke color="0xFF0000" weight="2"/>
                         </mx:stroke>
                    </mx:LegendItem>
               </mx:Legend>
               
               <mx:LineChart id="myChart" x="53" y="124" width="600" height="400" dataProvider="{platformsData}" showDataTips="true">
                    <mx:series>
                         <mx:LineSeries yField="id" displayName="Jobs" lineStroke="{s3}"/>
                    </mx:series>
               </mx:LineChart>
               
          </s:WindowedApplication>
          
          1 person found this helpful
          • 2. Re: Chart Legend: Worked in Beta, No longer working in Prod
            egmendez Level 1

            Thanks a lot for your help!!!!

             

            I'll use this as a workaround. As you indicate, this must be a bug unless I'm missing a new way to do this in FB4.

            Your code works (I'll be using it again as a workaround) but, as you know, it treats the legend and its corresponding

            chart as separate entities. Before I simply needed to associate a Legend to its chart 'dataProvider' and Flex figured

            everything out (i.e. names, colors, etc.). I need to spell everything out now.

             

            It would be nice to get a confirmation on whether or not this is a bug or something to be accomplished differently from

            FB4 onwards.

             

            Thanks one more time!!!!

             

            Regards,

             

            egm

            • 3. Re: Chart Legend: Worked in Beta, No longer working in Prod
              slim0001

              Try using mx.graphics.Stroke instead of mx.graphics.SolidColorStroke.

              You may get deprecation warning but it renders legend color correctly in my case.

              -K

              • 4. Re: Chart Legend: Worked in Beta, No longer working in Prod
                egmendez Level 1

                You're correct. That did the trick. I'll stick to the deprecated call while the new one gets fixed.

                Thanks a lot!!!!!

                • 5. Re: Chart Legend: Worked in Beta, No longer working in Prod
                  Devtron Level 3

                  When will this be fixed? How do I know it has been fixed or addressed?

                   

                  I too would like to get rid of the MANY deprecation warnings I get in design mode. Any ideas?