Line Chart : How to specify a time X axis?

Ask a Question related to Macromedia Flex General Discussion, Design and Development.

  1. #1

    Default Line Chart : How to specify a time X axis?

    Hello,

    I want to use Line Chart to show 2 series :

    Serie 1:
    {time : "2006-05-25 12:00:01", p1 : 45}
    {time : "2006-05-25 13:00:01", p1 : 34}
    {time : "2006-05-25 13:05:01", p1 : 78}

    Serie 2:
    {time : "2006-05-25 12:10:01", p1 :80}
    {time : "2006-05-25 12:50:01", p1 : 56}
    {time : "2006-05-25 13:00:01", p1 : 88}

    The big problem is that when I show the chart, the x axis is not linear (I
    would like something like 12:00:00, 12:15:00, etc... one mark each 15 minutes
    with sample at the right place). How to do?

    Thank for help me

    FredFlex

    FredFlex Guest

  2. Similar Questions and Discussions

    1. stacked Bar chart/Line chart hybrid- Charting
      Hi all, I have a requirement to have a stacked bar graph, with a line graph on the same chart. Has anyone here done this before? Apparently there...
    2. On change of chart data linear axis title producingerror
      I have a Column chart and a Line chart shown in different sections. Each section has a next/privious link that when clicked refreshes the data and...
    3. Formatting Chart Axis
      Each Axis has a labelFunction property which takes a function as input. The provided function gets called to determine the label of axis labels. One...
    4. DRKv5 3D Line Chart line width, rendering problems
      I am using the DevNet Resource Kit Version 5 3D Charting components. The line chart component has a minimum line width parameter, but the minimum...
    5. Simple line graphs (x-y axis) from ASP script
      What is a straightforward way to generate a simple line graph from provided x-y data points in an ASP script.
  3. #2

    Default Re: Line Chart : How to specify a time X axis?

    Finally I found:

    I must use DateTimeAxis class
    FredFlex Guest

  4. #3

    Default Re: Line Chart : How to specify a time X axis?

    Data points on the DateTimeAxis support the String, Number, or Date data types.

    1] Date: If the value of the data point is an instance of a Date object, it
    already represents an absolute datetime value and needs no interpretation. It
    is possible to pass a Date object as a data value if you use the parseFunction
    property of the 2] DateTimeAxis. That function returns a Date object. For
    more information, see Using parseFunction.
    3] String: You can use any format that the Date.parse() method supports. The
    supported formats are:
    4] Day Month Date Hours:Minutes:Seconds GMT Year (for example, "Tue Feb 1
    12:00:00 GMT-0800 2005")
    5] Day Month Date Year Hours:Minutes:Seconds AM|PM (for example, "Tue Feb 1
    2005 12:00:00 AM")
    6] Day Month Date Year (for example, "Tue Feb 1 2005")
    7] Month/Day/Year (for example, "02/01/2005")
    8] Month/Year (for example, "02/01/2005")
    You can also write custom logic that takes any string and returns a date using
    the parseFunction property of the DateTimeAxis.
    9] Number: If you use a number, it is assumed to be the number of milliseconds
    since Midnight, 1/1/1970. For example, 543387600000. To get this value on an
    existing Date object, use the Date object's getTime() method.
    The following example uses a string value for the date that matches the
    MM/DD/YYYY format and specifies that the


    the example uses a string value and parseFunction:
    ------------------------------------------------------------------------
    the parseFunction property of the DateTimeAxis tag to customize the value of
    the data points. With this method, you specify a method that accepts a String
    and returns a Date object.

    The following example shows a parse function that creates a new Date object
    out of strings in the data provider that match the "YYYY, MM, DD" pattern:


    <mx:Script><![CDATA[
    [Bindable]
    public var aapl:Array = [
    {date: "2005, 8, 1", close: 42.71},
    {date: "2005, 8, 2", close: 42.99},
    {date: "2005, 8, 3", close: 44}
    ];

    public function myParseFunction(s:String):Date {
    // Get an array of Strings from the comma-separated String passed in.
    var a:Array = s.split(",");
    trace("y: " + a[0]);
    trace("m: " + a[1]);
    trace("d: " + a[2]);
    // Create the new Date object.
    var newDate:Date = new Date(a[0],a[1],a[2]);
    return newDate;
    }
    ]]></mx:Script>
    <mx:LineChart id="mychart" dataProvider="{aapla}" showDataTips="true">
    <mx:horizontalAxis>
    <mx:DateTimeAxis dataUnits="days" parseFunction="myParseFunction"/>
    </mx:horizontalAxis>
    <mx:series>
    <mx:Array>
    <mx:LineSeries yField="close" xField="date" displayName="AAPL"/>
    </mx:Array>
    </mx:series>
    </mx:LineChart>







    poonamsheth Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139