I am working with a Flex DateTimeAxis. I have a scenario where the DateTimeAxis sometimes creates duplicate months on the Axis. The month label unit is generated based on a min/max value that is supplied to the DateTimeAxis, it is NOT generated by the series data as far as I can tell. In other words, the duplication does not exist within the data supplied to the chart, but is part of automatic label generation process that DateTimeAxis will execute when supplying a min/max value for the axis.
I have included a simplified example of this issue below. Any help is appreciated.
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml">
<mx:Script>
<![CDATA[
import mx.collections.ArrayCollection;
[Bindable]
public var stockDataAC:ArrayCollection = new ArrayCollection( [
{date: new Date(2009,4), close: 41.71},
{date: new Date(2009,5),close: 42.21},
{date: new Date(2009,6), close: 42.11},
{date: new Date(2009,7), close: 42.71},
{date: new Date(2009,9), close: 42.99}
]);
[Bindable] private var min:Date = new Date(2009,4);
[Bindable] private var max:Date = new Date(2010,3);
private function formatDate(value:Date,previousValue:Date,axis:DateTimeAxis):String {
var dateLabel:String = df.format(value);
return dateLabel;
}
]]>
</mx:Script>
<mx:DateFormatter id="df" formatString="MMM YY"/>
<mx:Panel title="DateTimeAxis Example" height="100%" width="100%">
<mx:LineChart id="mychart" height="100%" width="100%"
paddingRight="5" paddingLeft="5"
showDataTips="true" dataProvider="{stockDataAC}">
<mx:horizontalAxis>
<mx:DateTimeAxis dataUnits="months" labelUnits="months" alignLabelsToUnits="false" labelFunction="formatDate" minimum="{min}" maximum="{max}"/>
</mx:horizontalAxis>
<mx:verticalAxis>
<mx:LinearAxis baseAtZero="false" />
</mx:verticalAxis>
<mx:series>
<mx:LineSeries yField="close" xField="date" displayName="AAPL"/>
</mx:series>
</mx:LineChart>
</mx:Panel>