Just a general note to anyone reading this, remember that months in
ActionScript dates are 0-indexed.
new Date(2007,2,25) is actually March 25th, not February as you would expect.
Here is my parseDate function which converts date strings from "YYYY-MM-DD"
format into a Date object.
public function parseDate(s:String):Date
{
if (!s) return null;
var a:Array = s.split('-');
return new Date(parseInt(a[0]),parseInt(a[1])-1,parseInt(a[2]));
}
Hope that helps someone along the way.
Cheers,
Adam
----- Original Message -----
From: Mark
To: [email protected]
Sent: Sunday, February 25, 2007 10:37 PM
Subject: [flexcoders] Re: broken: stacked AreaChart when using horizontal
DateTimeAxis
I was having the same problem and found from the help files I needed
to make sure my dates were coming in as dates, so there's a
parseFunction I needed to add, like this:
<mx:horizontalAxis>
<mx:DateTimeAxis labelUnits="months" dataUnits="days"
displayLocalTime="true" parseFunction="myParseFunction" />
</mx:horizontalAxis>
//function
public function myParseFunction(s:String):Date {
// Get an array of Strings from the comma-separated String passed in.
var a:Array = s.split(",");
// Create the new Date object.
var newDate:Date = new Date(a[0],a[1],a[2]);
return newDate;
}
Hope it helps