saturngod
saturngod

Reputation: 24959

flot xaxes time mode is not correct

I am using jquery flot for showing graph. Everything is working fine but vertical line are wrong.

enter image description here

Feb 16 vertical line should be move to the left size.

I tested with number and it's working perfect. It only problem in x aixs.

 var plot = $.plot($("#placeholder"),
           [ { data: data1, label: "data1"} , {data:users, label:"users"}], {
               series: {
                   lines: { show: true },
                   points: { show: true }
               },
               xaxes: [ {mode: "time"} ],
               grid: { hoverable: true, clickable: false },
               legend: {container: $("#labeler")}
             });

Upvotes: 0

Views: 543

Answers (1)

saturngod
saturngod

Reputation: 24959

Found a problem.

$date = new DateTime($user->date);
 users.push([(<?php echo $date->getTimestamp();  ?>*1000),<?php echo $user->count ?>]);

PHP date string to timestamp * 1000 is a wrong way.

Correct one is

var date = new Date("<?php echo $user->date ?>");
users.push([date.getTime(),<?php echo $user->count ?>]);

Upvotes: 1

Related Questions