2 Replies Latest reply on Mar 16, 2010 1:18 PM by Cr99

    daylight savings messing up charts

    Cr99 Level 1

      The recent change in the U.S. to daylight savings time has messed up my charts.  Some don't display at all and others exhibit odd behaviors.  If I put in valid dates, they appear like this:

       

      Daily_Energy-img.png

       

      But after the change, the charts look like this:

       

      tmpImg-3.png

       

      The data looks fine for both charts, but the skinny one bombs on getting the columnWidthRation correct:

       

              var columnSeries:ColumnSeries = new ColumnSeries();        

              BindingUtils.bindProperty(columnSeries, "dataProvider", ser, "pointList");

              columnSeries.columnWidthRatio = 1.1;

              columnSeries.verticalAxis = vAxis;

              columnSeries.xField="point1";

              columnSeries.yField="point2";

              seriesArray.addItem(columnSeries);

       

      I'm using a CartesianChart with a DateTimeAxis for the horizontal and a LinearAxis for the vertical.  The labelUnits on the DateTimeAxis as set to 'days'.  Then the labelUnits are days, the chart will always draw even on the daylight savings time day (but it will draw incorrectly).  However if I set the labelUnits to 'hours' then it will draw the chart correctly unless I include the daylight savings time and then, it won't draw at all.

       

      So the labelUnits='hours' is also a related issue, but for labelUnits as 'days' here's what happens:

       

      If I set the date range to 3/13 through 3/14 the columns display correctly.

      If I set the date range to 3/15 through 3/16 the columns display correctly.

      If I set the date range to 3/14 through 3/15 the columns display incorrectly.

      The 14th is when daylight savings kicked in.  Seems like a bug in flex.  I'm using flex version 3.3.  I tried 3.5a but it didn't fix the problem.
      If I just look at the red column values, here's what it looks like when it works:
      03/14/2010 12:00:00 AM RTBT_Diag:BCM25I:TotalKWH19.55895723
      03/13/2010   12:00:00 AM RTBT_Diag:BCM25I:TotalKWH19.33001962
      03/12/2010   12:00:00 AM RTBT_Diag:BCM25I:TotalKWH18.06309019
      And here's what it looks like when it doesn't:
      03/16/2010 12:00:00 AM RTBT_Diag:BCM25I:TotalKWH6.021350381
      03/15/2010   12:00:00 AM RTBT_Diag:BCM25I:TotalKWH12.43230814
      03/14/2010   12:00:00 AM RTBT_Diag:BCM25I:TotalKWH19.55895723
      03/13/2010   12:00:00 AM RTBT_Diag:BCM25I:TotalKWH19.33001962
      03/12/2010   12:00:00 AM RTBT_Diag:BCM25I:TotalKWH18.06309019
      As you can see, the values are the same for the 14th on both charts.  But one draws correctly and the other does not.
      I've also noticed that
      Is there anyway around this error?

        • 1. Re: daylight savings messing up charts
          Cr99 Level 1

          Okay, further investigations have lead only to further confusion.  I can make the chart work using static data:

           

          [Bindable]

                  public var DECKER:Array = [

                     {date:"Tue Mar 16 00:00:00 GMT-0400 2010", val:6.021350380920805},

                     {date:"Mon Mar 15 00:00:00 GMT-0400 2010", val:12.432308140005917},

                     {date:"Sun Mar 14 00:00:00 GMT-0500 2010", val:19.558957234168425} 

                  ];

           

          <mx:CartesianChart dataProvider="{DECKER}" showDataTips="true">

           

          <mx:horizontalAxis>

                          <mx:DateTimeAxis dataUnits="days"/>

                      </mx:horizontalAxis>

           

                      <mx:verticalAxis>

                          <mx:LinearAxis  />

                      </mx:verticalAxis>

           

                      <mx:series>

                          <mx:ColumnSeries columnWidthRatio="1.1" yField="val" xField="date" displayName="points"/>

                      </mx:series>

           

          </mx:CartesianChart>

           

          ///////////////////////////////////

           

          But of course this doesn't work in Actionscript.  I printed out the dates with a trace in Actionscript and got slightly different results.  The timezones are different but as you can see above, I mimicked that behavior in my sample array and it still worked in mxml.

           

          Good Dates

           

               Sun Mar 14 00:00:00 GMT-0500 2010     19.558957234168425    

               Sat Mar 13 00:00:00 GMT-0500 2010     19.330019615832715    

               Fri Mar 12 00:00:00 GMT-0500 2010     18.063090187328868    

           

          Bad Dates

           

               Mon Mar 15 00:00:00 GMT-0400 2010     12.432308140005917    

               Sun Mar 14 00:00:00 GMT-0500 2010     19.558957234168425    

               Sat Mar 13 00:00:00 GMT-0500 2010     19.330019615832715   

               Fri Mar 12 00:00:00 GMT-0500 2010     18.063090187328868   

               Tue Mar 16 00:00:00 GMT-0400 2010     6.021350380920805   

          • 2. Re: daylight savings messing up charts
            Cr99 Level 1

            Is anyone doing chart generation in actionscript?  Becasue I can get it to work in mxml.  But even when I tear out all the bells and whistles and try to do it as simple as possible, it chokes in Actionscript.  I've gone over and over this and can't see what is causing the problem:

             

             

             

            public function makeDateChart(genericChart:CartesianChart, chart:ChartObject):void {

             

                        // ChartObject is a custom object which holds display information

                        // as well as all the SeriesObjects (see below)

                        var axisList:ArrayCollection = chart.getAxisList();

                        var seriesArray:Array = new Array();

                       

                        var hAxis:DateTimeAxis = new DateTimeAxis();

             

                for (var i:int=0; i<axisList.length; i++) {

                var axis:AxisObject = axisList.getItemAt(i) as AxisObject;

                if (axis.getID() == "x Axis") {

                      hAxis.labelUnits = "days";

                     genericChart.horizontalAxis = hAxis;

                }

                else {

             

                   // Define vertical axis

                   var vAxis:LinearAxis = new LinearAxis();

                   genericChart.verticalAxis = vAxis;

             

             

                    for (var j:int=0; j<axis.getSeriesList().length; j++) {

             

                    // custom data object which holds data and display settings

                    var ser:SeriesObject = axis.getSeriesList().getItemAt(j) as SeriesObject;

             

                    var columnSeries:ColumnSeries = new ColumnSeries();   

                    // bind data...It doesn't matter if I bind 'pointList' or DECKER to this

                    // either way it doesn't work for columnSeries- it does work for the

                    // mxml object testCol (see prev post for static version of chart)

                    // pointList has a series of DataObjects in it's array:

            /*

             

            DataObject variables:

            public var point1:Object;

            public var point2:Object;

            "/

             

             

                    BindingUtils.bindProperty(columnSeries, "dataProvider", ser, "pointList");

                    BindingUtils.bindProperty(testCol, "dataProvider", ser, "pointList");

             

                    columnSeries.columnWidthRatio = 1.1;

                    columnSeries.displayName = ser.name;        

                    columnSeries.xField="point1";

                    columnSeries.yField="point2";

                    seriesArray.push(columnSeries);

             

                    }

                }

                }

               

                genericChart.series = seriesArray;

                genericChart.percentWidth = 100;

               genericChart.showDataTips = true;

             

                var hb:HBox = new HBox();

             

                hb.addChild(genericChart);

                this.addChild(hb);

            }