Welcome Guest Search | Active Topics |

how to fix date format in x-axis legend ?
ssc
#1 Posted : Monday, March 26, 2012 9:25:49 PM(UTC)
Rank: Member

Groups: Registered
Joined: 2/19/2012(UTC)
Posts: 10

Thanks: 1 times
Was thanked: 0 time(s) in 0 post(s)
My jqChart has a time-based x axis. If data stretches over a number of days, dates in the x axis legend are displayed similar to the example charts in the documentation.
How can I change the date format from american MM/DD/YY to a proper format like e.g. DD/MM/YYYY ?
I have looked into the label options / string format documentation sections, but I could not find anything on how to use them....
Dragan
#2 Posted : Tuesday, March 27, 2012 1:55:10 AM(UTC)
Rank: Advanced Member

Groups: Administrators, DataVizJavaScript, jQueryChart, jQueryDV, MvcChart, Registered
Joined: 1/3/2011(UTC)
Posts: 483

Thanks: 0 times
Was thanked: 87 time(s) in 87 post(s)
Hi,

Unfortunately our documentation is uncompleted. We’re improving it currently.

You can use this code to change the formatting:


Code:
        $('#jqChart').jqChart({
            title: { text: 'DateTime Axis' },
            axes: [
                      {
                          type: 'dateTime',
                          location: 'bottom',
                          labels: { stringFormat: 'dd/mm/yyyy' },...
Best Regards,
Dragan Matek
jqChart Inc.
ssc
#3 Posted : Tuesday, March 27, 2012 5:22:29 AM(UTC)
Rank: Member

Groups: Registered
Joined: 2/19/2012(UTC)
Posts: 10

Thanks: 1 times
Was thanked: 0 time(s) in 0 post(s)
works like a charm, thanks! :-)
cprompt42
#4 Posted : Tuesday, April 3, 2012 1:18:15 AM(UTC)
Rank: Newbie

Groups: Registered
Joined: 3/31/2012(UTC)
Posts: 4

Thanks: 0 times
Was thanked: 0 time(s) in 0 post(s)
Hi,

is it possible to show some clocktimedata in the timelabel of the bottom axis? I have a timestamp like

Date {Mon Apr 02 2012 21:14:14 GMT+0200 (CEST)}

and try to format it with

Code:

labels: {
          stringFormat: 'dd-mm-yyyy h:MM:ss'
         }


but the only thing I get is something like

02-04-2012 12:00:00

what means that the chart doesn't seem to recognize the time format?

Thanks in advance,

C. Groschopf
Dragan
#5 Posted : Tuesday, April 3, 2012 1:41:13 AM(UTC)
Rank: Advanced Member

Groups: Administrators, DataVizJavaScript, jQueryChart, jQueryDV, MvcChart, Registered
Joined: 1/3/2011(UTC)
Posts: 483

Thanks: 0 times
Was thanked: 87 time(s) in 87 post(s)
Hi,

I’m not sure what exactly you want to display, but you can try these formats as well:

Code:
"HH:MM:ss"
"h:MM:ss TT Z"


Quote:
what means that the chart doesn't seem to recognize the time format?

Can you provide us a little more info about this?
Best Regards,
Dragan Matek
jqChart Inc.
cprompt42
#6 Posted : Tuesday, April 3, 2012 1:56:36 AM(UTC)
Rank: Newbie

Groups: Registered
Joined: 3/31/2012(UTC)
Posts: 4

Thanks: 0 times
Was thanked: 0 time(s) in 0 post(s)
Hi,

thanks for your very quick answer!

In the database there is e.g. some temperature data which is measured e.g. every 2 seconds. Now I want to plot something like the last 1000 values in a line-chart.
The servercode is:
Code:

        $sql="SELECT (5.625*value-52.5) as value,
            unix_timestamp(timestamp) as timestamp
            FROM rohWerte
            order by timestamp desc
            limit 0,1000";
        $result=mysql_query($sql) or die($sql."\n".mysql_error());
        $i=0;
        while($line=mysql_fetch_array($result,MYSQL_ASSOC)){
            $output[$i]['timestamp']=$line['timestamp']*1000;
            $output[$i]['value']=$line['value'];
            $i++;
        }
        print json_encode($output);

On client side, I try to do something like this:
Code:

$.getJSON("server.php",{func: "getOnlineData"},function(j){
        var background = {
            type: 'linearGradient',
            x0: 0,
            y0: 0,
            x1: 0,
            y1: 1,
            colorStops: [{ offset: 0, color: '#d2e6c9' },
                         { offset: 1, color: 'white'}]
        };
        var data = new Array();
        for(i=0;i<j.length;i++){
            data[i]=new Array(
                new Date(j[i].timestamp),
                parseInt(j[i].value)
            )
        }

        $('#jqChart').jqChart({
            title: 'jqChart - Teststation',
            legend: { title: 'Legend' },
            border: { strokeStyle: '#6ba851' },
            background: background,
            axes: [{
                    type: 'linear',
                    location: 'left'
                },
                {
                    type: 'dateTime',
                    location: 'bottom',
                    labels: {
                        stringFormat: 'dd-mm-yyyy'
                    }
                }
            ],
            series: [
                        {
                            type: 'line',
                            lineWidth: 1,
                            title: 'Random Data',
                            markers: {
                                size: 0
                            },
                            data: data
                        }
                    ]
        });
    });
    setTimeout("testchart()",10000);


I hope this is the Information you asked for?

Best Regards,

C. Groschopf
Dragan
#7 Posted : Tuesday, April 3, 2012 2:05:47 AM(UTC)
Rank: Advanced Member

Groups: Administrators, DataVizJavaScript, jQueryChart, jQueryDV, MvcChart, Registered
Joined: 1/3/2011(UTC)
Posts: 483

Thanks: 0 times
Was thanked: 87 time(s) in 87 post(s)
Ok. But what is exactly the issue with formatting the labels?

Did these help?

Code:
"HH:MM:ss"
"h:MM:ss TT Z"

Best Regards,
Dragan Matek
jqChart Inc.
cprompt42
#8 Posted : Tuesday, April 3, 2012 2:16:11 AM(UTC)
Rank: Newbie

Groups: Registered
Joined: 3/31/2012(UTC)
Posts: 4

Thanks: 0 times
Was thanked: 0 time(s) in 0 post(s)
Hi,

providing the stringFormat as

Code:

stringFormat: 'dd-mm-yyyy HH:MM:ss'


the label shown in the plot doesn't show the given clocktime. If the time is e.g. 12-03-2012 14:32:13
the label shows 12-03-2012 00:00:00 instead. The date is correct but instead of the clocktime there is something
like 00:00:00 or 01:00:00.

Best regards,

C. Groschopf
Dragan
#9 Posted : Tuesday, April 3, 2012 2:36:49 AM(UTC)
Rank: Advanced Member

Groups: Administrators, DataVizJavaScript, jQueryChart, jQueryDV, MvcChart, Registered
Joined: 1/3/2011(UTC)
Posts: 483

Thanks: 0 times
Was thanked: 87 time(s) in 87 post(s)
Can you send me a screenshot of your chart? It can be via email.
Best Regards,
Dragan Matek
jqChart Inc.
cprompt42
#10 Posted : Tuesday, April 3, 2012 4:49:01 AM(UTC)
Rank: Newbie

Groups: Registered
Joined: 3/31/2012(UTC)
Posts: 4

Thanks: 0 times
Was thanked: 0 time(s) in 0 post(s)
Hi,

seems to be my own fault: I tried with more dense data, so that I got the right format. Sorry again for inconvenience.

Best regards,

C. Groschopf
Users browsing this topic
Guest (2)
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.

FlatEarth Theme by Jaben Cargman (Tiny Gecko)
Powered by YAF 1.9.4 | YAF © 2003-2010, Yet Another Forum.NET
This page was generated in 0.158 seconds.