0 Replies Latest reply on Aug 8, 2010 11:29 AM by Alvaroecp

    dataToLocal problem?


      Hi everyone,


      I have a horizontal DateTimeAxis with minimum and maximum values defined as

      minimum = new Date("2005/7/7");

      maximum = new Date("2005/7/26");.


      The axis is part of a CartesianChart with width = 400. When I executes the next instructions, flex returns pointmax = (x=398, y=279.5)


                  var datemax:Date = new Date("2005/7/26");
                  const pointmax:Point = (linechart.series[0] as Series).dataToLocal(datemax.time, 0);


      I dont understand why pointmax.x is 398? I think the correct must be pointmax.x = 400 (because chart's axis and labels were set to be hidden).Additionally, if you use LineChart instead of CartesianChart the values of pointmax.x is 399 ... why??? An example of this problem (in Flasbuilder4) is below.


      Thanks in advance!




      <?xml version="1.0" encoding="utf-8"?>
      <s:Application xmlns:fx="http://ns.adobe.com/mxml/2009
               import mx.charts.chartClasses.Series;
               import mx.collections.ArrayCollection;
               import mx.controls.Alert;
               import mx.events.FlexEvent;
               [Bindable]private var expensesAC:ArrayCollection = new ArrayCollection( [
                  { Month: "2005/7/7", Profit: 2000},
                  { Month: "2005/7/11", Profit: 1000},
                  { Month: "2005/7/15", Profit: 1500},
                  { Month: "2005/7/19", Profit: 1800},
                  { Month: "2005/7/26", Profit: 2400} ]);


               protected function button1_clickHandler(event:MouseEvent):void
                  var datemin:Date = new Date("2005/7/7");
                  var datemax:Date = new Date("2005/7/26");
                  const theseries:Series = linechart.series[0] as Series;
                  const pmin:Point = theseries.dataToLocal(datemin.time, 0);
                  const pmax:Point = theseries.dataToLocal(datemax.time, 0);
                  Alert.show(pmin.toString() +" : "+ pmax.toString());


               protected function application1_applicationCompleteHandler(event:FlexEvent):void
                  (linechart.horizontalAxis as DateTimeAxis).minimum = new Date("2005/7/7");
                  (linechart.horizontalAxis as DateTimeAxis).maximum = new Date("2005/7/26");
            <s:HorizontalLayout verticalAlign="middle" horizontalAlign="center"
                                paddingLeft="0" paddingRight="0"
                                paddingTop="0" paddingBottom="0"/>
            <s:VGroup width="400" height="342" horizontalAlign="center">
                  <mx:CartesianChart id="linechart" height="280" width="400"
                                showDataTips="true" >
                        <mx:LineSeries xField="Month" yField="Profit" form="curve"
                                       dataProvider="{expensesAC}" />
                        <mx:DateTimeAxis id="haxis" displayLocalTime="true" padding="0" />
                        <mx:LinearAxis id="vaxis" />
                        <mx:AxisRenderer axis="{vaxis}"
                                         showLabels="false" showLine="false" labelGap="0"
                        <mx:AxisRenderer axis="{haxis}"
                                         showLabels="false" showLine="false" labelGap="0"/>
                  <s:Button label="Button" click="button1_clickHandler(event)"/>