sunjavagroups / flot

Automatically exported from code.google.com/p/flot
MIT License
0 stars 0 forks source link

mode: "time" #608

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
$(function () {
 var data1 = [[new Date("2010/08/26"), 0], [new Date("2010/08/27"), 10], [new Date("2010/08/28"), 3], [new Date("2010/08/29"), 1], [new Date("2010/08/30"), 4] ];

    var options = {
        lines: {
            show: true,
            fill: true,
            fillColor: "rgba(247, 233, 228, 0.6)"
        },
        points: { show: true },
        xaxis: {
            mode: "time",
            minTickSize: [1, "day"],
            timeformat: "%y/%m/%d"
        },
        yaxis: {
            min: 0,
            tickSize:1,
            tickDecimals: 0
        },
        grid: {
            borderColor: "rgb(114, 114, 116)"
        },
        colors: [ "rgb(182, 90, 24)" ]
    };

    $.plot($("#placeholder1"), [{ data: data1 }], options);
});
===
Note that all points are not marked in the right places (like 10px to right). 
Someone had the same problem?

Original issue reported on code.google.com by jorge.mu...@gmail.com on 27 Sep 2011 at 6:35

Attachments:

GoogleCodeExporter commented 8 years ago
[deleted comment]
GoogleCodeExporter commented 8 years ago
try:
xaxis: {
 mode: "time",
 //minTickSize: [1, "day"],
 //timeformat: "%y/%m/%d"
},
It's because UTC time using in Flot.
And all your Date ,if time in your machine not like GMT-0, get change.
For example my time is UTC+04:00, and flot get
2010/08/26 - 4 hours and show me first point in 2010/08/25 20:00 !

If your want to fix it, replace all 'UTC' to '' (ex. getUTCSeconds to 
getSeconds) in jquery.flot.js !

Original comment by zniki...@gmail.com on 28 Sep 2011 at 12:07

GoogleCodeExporter commented 8 years ago
Thanks a lot! Perfect!

Original comment by jorge.mu...@gmail.com on 28 Sep 2011 at 12:20

GoogleCodeExporter commented 8 years ago
Thanks

Original comment by grantamaral on 2 Feb 2012 at 4:29

GoogleCodeExporter commented 8 years ago

Original comment by dnsch...@gmail.com on 30 Apr 2012 at 2:38

GoogleCodeExporter commented 8 years ago
[deleted comment]
GoogleCodeExporter commented 8 years ago
I have done exactly the same by removing the UTC string, but still the x-axis 
is not aligned with the plotted point. I have even tried the last version of 
flot with the time flot library, and still the same and using timezone: 
"browser".
This is my options array:
var options = {
                series: {
                    lines: {
                        show: true
                    },
                    points: {
                        show: true
                    }
                },
                grid: {
                    hoverable: true,
                    clickable: true
                },
                xaxis: {
                    mode: "time",
                    timeformat: "%d/%m",
                    tickSize: [1, "day"]
                },
                yaxis: {
                    min: 0
                },
                legend: {
                    show: false
                },
                selection: {
                    mode: "x"
                }

            };

and the data is a simple new Date(someDateArray[i])).getTime().
==
Is there any other work around this phenomenon?

Original comment by Alb...@gmail.com on 12 Jul 2012 at 4:33

Attachments:

GoogleCodeExporter commented 8 years ago
I fixed this by using the function Date.UTC(year,month,day,...)!!

Original comment by Alb...@gmail.com on 12 Jul 2012 at 9:16

GoogleCodeExporter commented 8 years ago
using this option

timezone:"browser"

Original comment by hamelm...@gmail.com on 21 Aug 2013 at 8:27

GoogleCodeExporter commented 8 years ago
this is very good
!

Original comment by peak...@gmail.com on 25 May 2015 at 6:25