Hi, I have a problem, my plot chart whose datetime axis is controlled by a slider. This slider is having 2 thumbs, one with min date and one with max date, Now if i move the thumbs so that time is reduced, plot chart will get expanded.. like first it will show years.. then comes to months...as i slide the thumbs closer. But at the min, i am getting monthly data,, ie data within 4 months..
I want this ti be reduced as much as daily. can somebody get me some ideas for this problem. I am sharing the code here <?xml version="1.0"?> <!-- Simple example to demonstrate the PlotChart control. --> <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" creationComplete="init()"> <mx:Script> <![CDATA[ import mx.controls.Alert; import mx.events.SliderEvent; import mx.collections.ArrayCollection; var minTime: Number = NaN; var maxTime: Number = NaN; var minAxisDate: Date = new Date(); var maxAxisDate: Date = new Date(); private var millisecondsPerDay:int = 1000 * 60 * 60 * 24; private var millisecondsPerWeek:int = millisecondsPerDay * 7; [Bindable] private var expensesAC:ArrayCollection = new ArrayCollection( [ { date: "2000, 1, 7", Profit: 2000, Expenses: 1500, Amount: 450 }, { date: "2000, 1, 8", Profit: 2000, Expenses: 1500, Amount: 450 }, { date: "2000, 1, 9", Profit: 2000, Expenses: 1500, Amount: 450 }, { date: "2000, 1, 10", Profit: 2000, Expenses: 1500, Amount: 450 }, { date: "2000, 1, 11", Profit: 2000, Expenses: 1500, Amount: 450 }, { date: "2000, 1, 12", Profit: 2000, Expenses: 1500, Amount: 450 }, { date: "2000, 1, 13", Profit: 2000, Expenses: 1500, Amount: 450 }, { date: "2000, 1, 14", Profit: 2000, Expenses: 1500, Amount: 450 }, { date: "2000, 1, 15", Profit: 2000, Expenses: 1500, Amount: 450 }, { date: "2000, 1, 16", Profit: 2000, Expenses: 1500, Amount: 450 }, { date: "2000, 1, 17", Profit: 2000, Expenses: 1500, Amount: 450 }, { date: "2000, 1, 18", Profit: 2000, Expenses: 1500, Amount: 450 }, { date: "2000, 1, 19", Profit: 2000, Expenses: 1500, Amount: 450 }, { date: "2000, 1, 20", Profit: 2000, Expenses: 1500, Amount: 450 }, { date: "2000, 1, 21", Profit: 2000, Expenses: 1500, Amount: 450 }, { date: "2000, 1, 22", Profit: 2000, Expenses: 1500, Amount: 450 }, { date: "2000, 1, 23", Profit: 2000, Expenses: 1500, Amount: 450 }, { date: "2000, 1, 24", Profit: 2000, Expenses: 1500, Amount: 450 }, { date: "2000, 1, 25", Profit: 2000, Expenses: 1500, Amount: 450 }, { date: "2000, 1, 26", Profit: 2000, Expenses: 1500, Amount: 450 }, { date: "2000, 1, 27", Profit: 2000, Expenses: 1500, Amount: 450 }, { date: "2001, 1, 28", Profit: 2000, Expenses: 1500, Amount: 450 }, { date: "2002, 1, 29", Profit: 2000, Expenses: 1500, Amount: 450 }, { date: "2003, 1, 30", Profit: 2000, Expenses: 1500, Amount: 450 }, { date: "2004, 1, 31", Profit: 2000, Expenses: 1500, Amount: 450 }, { date: "2005, 1, 7", Profit: 2000, Expenses: 1500, Amount: 450 }, { date: "2006, 1, 7", Profit: 2000, Expenses: 1500, Amount: 450 }, { date: "2007, 1, 7", Profit: 2000, Expenses: 1500, Amount: 450 }, { date: "2008, 1, 7", Profit: 2000, Expenses: 1500, Amount: 450 }, { date: "2009, 1, 7", Profit: 2000, Expenses: 1500, Amount: 450 }, { date: "2010, 1, 7", Profit: 2000, Expenses: 1500, Amount: 450 }, { date: "2011, 1, 7", Profit: 2000, Expenses: 1500, Amount: 450 }, { date: "2012, 1, 7", Profit: 2000, Expenses: 1500, Amount: 450 }, { date: "2013, 1, 7", Profit: 2000, Expenses: 1500, Amount: 450 }, { date: "2014, 1, 7", Profit: 2000, Expenses: 1500, Amount: 450 }, { date: "2015, 1, 7", Profit: 2000, Expenses: 1500, Amount: 450 }, { date: "2016, 1, 7", Profit: 2000, Expenses: 1500, Amount: 450 }, { date: "2017, 6, 17", Profit: 1000, Expenses: 200, Amount: 600 }, { date: "2018, 1, 7", Profit: 2000, Expenses: 1500, Amount: 450 }, { date: "2009, 8, 29", Profit: 1500, Expenses: 500, Amount: 300 } ]); 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. Subtract one from the month property. // The month property is zero-based in the Date constructor. var newDate:Date = new Date(a[0],a[1]-1,a[2]); return newDate; } public function init():void { slider1.minimum = new Date(2000, 0, 7).time; slider1.maximum = new Date(2009, 7, 29).time; slider1.setThumbValueAt(0,new Date(2000, 0, 7).time); slider1.setThumbValueAt(1,new Date(2009, 7, 29).time); slider1.addEventListener(mx.events.SliderEvent.CHANGE,onSliderDatesChange); } public function onSliderDatesChange(ev:SliderEvent):void { onSliderChange(); } var timeDiff : Number; public function onSliderChange(): void { if(slider1.values[0]!=null && slider1.values[1]!=null) { dateFieldFrom.selectedDate.time = slider1.values[0]; dateFieldFrom.selectedDate = dateFieldFrom.selectedDate; dateFieldTo.selectedDate.time = slider1.values[1]; dateFieldTo.selectedDate = dateFieldTo.selectedDate; try { minTime = dateFieldFrom.selectedDate.time; maxTime = dateFieldTo.selectedDate.time; timeDiff = maxTime - minTime; } catch (err: Error) { Alert.show(err.message); } if (timeDiff > 0) { minAxisDate.time = minTime; maxAxisDate.time = maxTime; dateTimeAxis1.minimum = minAxisDate; dateTimeAxis1.maximum = maxAxisDate; } } } ]]> </mx:Script> <mx:Panel title="PlotChart Control Example" height="100%" width="100%"> <mx:PlotChart id="plot" height="100%" width="100%" paddingLeft="5" paddingRight="5" showDataTips="true" dataProvider="{expensesAC}"> <mx:horizontalAxis> <mx:DateTimeAxis id="dateTimeAxis1" dataUnits="days" parseFunction="myParseFunction"/> </mx:horizontalAxis> <mx:series> <mx:PlotSeries xField="date" yField="Profit" displayName="Profit"/> <mx:PlotSeries xField="date" yField="Expenses" displayName="Expenses"/> <mx:PlotSeries xField="date" yField="Amount" displayName="Amount"/> </mx:series> </mx:PlotChart> <mx:Legend dataProvider="{plot}"/> <mx:ControlBar horizontalAlign="center"> <mx:HBox> <mx:HSlider liveDragging="true" id="slider1" allowTrackClick="false" thumbCount="2" showTrackHighlight="true"/> <mx:DateField id="dateFieldFrom" selectedDate="{new Date()}"/> <mx:DateField id="dateFieldTo" selectedDate="{new Date()}"/> </mx:HBox> </mx:ControlBar> </mx:Panel> </mx:Application> thanks In advance sandeep --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Flex India Community" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/flex_india?hl=en -~----------~----~----~----~------~----~------~--~---

