FLEX + Line Chart + Date Display

Posted on 2009-12-28
Last Modified: 2012-05-08
I am testing creating a line graph with Flex 3 - it has 4 series and everything display properly but the date on the horizontal axis display month/year - where i want it to display as mm/dd/yyyy, the tutorial i was following uses the below code.  The date format from the xml is mm/dd/yyyy but i am guessing is a string so needs to convert it to a date, but it doesnt seem to display correctly in the graph.
// Create a DateTimeAxis horizontal axis.

		            var hAxis:DateTimeAxis = new DateTimeAxis();

		            hAxis.dataUnits = "WeekDate";

		            // Set this to false to display the leftmost label.

		            hAxis.alignLabelsToUnits = false;

		            // Take the date in its current format and create a Date

		            // object from it.

		            hAxis.parseFunction = createDate;

		            myChart.horizontalAxis = hAxis;

		        public function createDate(s:String):Date {

		            // Reformat the date input to create Date objects

		            // for the axis.

		            var a:Array = s.split("/");


		            // The existing String s is in the format "MM/DD/YYYY". 

		            // To create a Date object, you pass "YYYY,MM,DD", 

		            // where MM is zero-based, to the Date() constructor.

		            var newDate:Date = new Date(a[2],a[0]-1,a[1]);

		            return newDate;


Open in new window

Question by:dkilby
    LVL 11

    Accepted Solution


    I think you will get it correct if you specify dataUnits to days.

    hAxis.dataUnits = "days";


    Author Closing Comment

    great thanks - i also had to add hAxis.labelUnits = "days';

    Featured Post

    How your wiki can always stay up-to-date

    Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
    - Increase transparency
    - Onboard new hires faster
    - Access from mobile/offline

    Join & Write a Comment

    First things first - Preparation We need all the part for this install and it's much nicer to have them all on hand when you need them so here's what's required. Download Eclipse 3.5 32 bit (I like the Classic flavour) from here. (http://www.e…
    This paper addresses the security of Sennheiser DECT Contact Center and Office (CC&O) headsets. It describes the DECT security chain comprised of “Pairing”, “Per Call Authentication” and “Encryption”, which are all part of the standard DECT protocol.
    Internet Business Fax to Email Made Easy - With eFax Corporate (, you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
    Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

    730 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    15 Experts available now in Live!

    Get 1:1 Help Now