5 Replies Latest reply on Mar 24, 2011 8:46 AM by rtalton

    Chart Labels disappearing

    _spoboyle Level 4

      I have a Flex 4 Air application which contains a LineChart. The application allows the user to view various ranges of data. when the user changse the date range I fetch the requierd data from a sqlite database, parse the data and set the dataprovider of the LineChart.

       

      however after several attempts of changing the date some of the chart labels disappear (also the text on the labels displaying the selected date range disappear)

       

      Its always the 15th that goes first and sometimes the 30th. however the 30th may come back depending on the month selected. all dates for the selected month are present in the dataprovider.

       

      can anyone suggest what might be going on.

       

      chart_bug.png

        • 1. Re: Chart Labels disappearing
          _spoboyle Level 4

          I think I have narrowed the problems down to

           

               var daysInMonth:int = DateUtils.getDaysInMonth(_date);

               horzAxis.maximum = daysInMonth;

           

          repeatedly changing the axis maximum dynamically seems to break the LinearAxis rendering and invalidating the display list does not help

           

          Oddly it broke the vertical axis as well!

          • 2. Re: Chart Labels disappearing
            _spoboyle Level 4

            it actually happens if I set any of the below

             

                 horzAxis.maximum = 31; or

                 horzAxis.minimum = 1; or

                 horzAxis.interval = 1;

             

            and the values can be constants

            • 3. Re: Chart Labels disappearing
              _spoboyle Level 4

              Ok I have managed to produce a smallish testcase

               

              Launch the application select a date using the datefield and notice that some of the horizontal axis numbers disappear (you may need to repeat several times)

              A difference to what i posted above the number that seems to disappear here is the first one number 2.

               

              <?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="600" height="600">
                   <fx:Script>
                        <![CDATA[
                             private static function getDaysInMonth(date:Date):int
                             {
                                  var tempDate:Date = new Date(date.fullYear, date.month+1, 1);
                                  tempDate.date--;
                                  return tempDate.date;
                             }
                        ]]>
                   </fx:Script>
                   
                   <s:VGroup>
                        <mx:LineChart>
                             <mx:horizontalAxis>
                                  <mx:LinearAxis maximum="{getDaysInMonth(dateField.selectedDate)}"/>
                             </mx:horizontalAxis>
                        </mx:LineChart>
                        <mx:DateField id="dateField" selectedDate="{new Date()}"/>
                   </s:VGroup>
              </s:WindowedApplication>
              

               

              Any idea what's going on or suggestions on how I can go about debugging this?

               

              Thanks

              • 4. Re: Chart Labels disappearing
                _spoboyle Level 4

                duplicate

                • 5. Re: Chart Labels disappearing
                  rtalton Level 4

                  Welcome to charting hell!

                  I tried your example in FB3 and could not reproduce the missing "15".

                  As far as the first and last values on the x/y axis sometimes not showing up, this is normal behavior. Flex charts do a lot of layout tricks to get everything squeezed into a given space. Finding the right combination of styles and properties to make it look right for your situation takes time and is most always a compromise. You can look into the "gutter" styles, and maybe set your own label renderer to control the space used.

                   

                  Read "Improving charting component performance " in the help docs. You will probably need to get more control over the AxisRenderers of your charts. It can be a PITA, but it will save you a lot of grief trying to figure out why a chart is misbehaving.

                   

                  https://www.anaheimjobs.com/#view=4;content=;state=showContent