Reputation: 2249
I've got flot data where the points on the xaxis aren't aligned with the lines.
specifically, take a look at this photo:
this is the raw data that I'm using:
[0] : [1327305600000,1989],
[1] : [1327392000000,3222.33333333333],
[2] : [1327564800000,1481.5],
[3] : [1327651200000,2061],
[4] : [1327910400000,1434],
[5] : [1327996800000,1504.75],
[6] : [1328083200000,1422.4]
and this is the javascript that I'm passing to flot:
$.plot($("#something"), [datapoints], {
series: {
lines: { show: true , shadowSize:0},
points: { show: true }
},
xaxis: {
mode: "time",
timeformat: "%m/%d/%y",
reserveSpace: true
},
clickable: true,
hoverable: true,
legend: {
show: true
}
});
specifically, look at the second point. The timestamp for it is 1327392000000, and you can see from the following code that this should be aligned with the 1/24/2012 x-axis point, but it's not.
var d = new Date(1327392000000); => Tue Jan 24 00:00:00 PST 2012
If there's any way I can workaround this, I'd love to hear it.
Thanks!
Upvotes: 3
Views: 1665
Reputation: 2207
I solved this problem by passing date in the format YYYY-MM-DD to this statement:
new Date(dateInYYYY_MM_DD).getTime();
Upvotes: 0