jquery - Flot Chart Tooltip Error - Tooltip Date is One Day Behind X-Axis Date -


i haven't been able understand why tooltip date off single day. believe x-axis correct, , i've been playing around it, killing me.

how can fix this?

i'm passing in json url endpoint variable jsondataurl. here example datapoint: [{date: "2013-01-01", value: 50}]

and cssselector placeholder.

here's code:

  $.getjson(jsondataurl, function(res) {    var data = [];     $.each(res, function(i, entry){       data.push( [new date(entry["date"]), entry["value"]] );     });      var opts = { yaxis: { min: 0},                  xaxis: { mode: "time", timeformat: "%m-%d"},                   series: { lines: { show: true }, points: { show: true } },                   grid: {hoverable: true, clickable: true}     };      $.plot($(cssselector), [data], opts);      $(cssselector).bind("plotclick", function(event, pos, item) {         if (item) {              var x = parseint(item.datapoint[0]),                 y = item.datapoint[1];             var date = (new date(x));             var day = date.getdate();             var month = date.getmonth() + 1;             var formatteddate = month + "-" + day;              $("#tooltip").remove();             var label = "date: " + formatteddate + "<br/> count: " + y;             showtooltip(item.pagex, item.pagey, label);         }     });   }); 

i hope ok, answer own question. i'm happy discovered silly mistake! i'm using ruby on rails gather data , pass flot chart via json url. since server records data @ utc midnight, passing in data tooltip @ local timezone knocking out of sync.

so, changed date.getdate() , date.getmonth() date.getutcdate() , date.getutcmonth().


Comments

Popular posts from this blog

monitor web browser programmatically in Android? -

Shrink a YouTube video to responsive width -

wpf - PdfWriter.GetInstance throws System.NullReferenceException -