npm-stat.com icon indicating copy to clipboard operation
npm-stat.com copied to clipboard

Chart tooltip is one day back

Open epoberezkin opened this issue 7 years ago • 10 comments

See https://npm-stat.com/charts.html?package=ajv or https://npm-stat.com/charts.html?package=ajv&from=2017-04-01&to=2017-04-16

Particularly on the second one you can see that the date one the axis is correct and in the tooltip (when you mouse-over the dot on the chart) it is one day back

epoberezkin avatar Apr 16 '17 10:04 epoberezkin

Yep, I know this issue. It has been introduced in PR #37, but I didn't recognize it before deploying that change and didn't feel like it's that important.

I guess it is caused by some timezone problem. Can you tell me in which timezone you tested this behavior?

pvorb avatar Apr 17 '17 18:04 pvorb

In GMT (UTC +1 now)

epoberezkin avatar Apr 17 '17 20:04 epoberezkin

looks fixed

epoberezkin avatar Feb 03 '19 11:02 epoberezkin

Are you still in UTC+1? Because I haven't changed the calculation, I think.

pvorb avatar Feb 03 '19 14:02 pvorb

Maybe it’s because it’s UTC now...

epoberezkin avatar Feb 03 '19 18:02 epoberezkin

That sounds likely.

pvorb avatar Feb 03 '19 22:02 pvorb

I am in Eastern Time, I'm seeing an issue on the default view for a package where the both the "To" field and the date in the graph is always the day before (ie if today is June 2nd, both are June 1st). IMHO it should give data for the current day even if the day is not over.

ozzyogkush avatar Jun 02 '19 22:06 ozzyogkush

Looks like the bug appears in a chart generation. The plain API stat is correct while the chart lies image image

vlzhr avatar Sep 24 '19 08:09 vlzhr

@ozzyogkush

IMHO it should give data for the current day even if the day is not over.

npm-stat.com cannot give numbers before a day is over, since NPM starts calculating the numbers on midnight UTC.

@vlzhr Yes, everything is fine in the back end, but time zones in JavaScript are awful. Highcharts uses Date objects for displaying the x-axis and 2019-09-23T00:00:00Z might be displayed as Sunday, Sep 22, 2019 (the actual time is omitted) if your offset from UTC is negative.

pvorb avatar Sep 24 '19 15:09 pvorb

looks like this is linked to the issue I just opened #83 where I noticed the timezone moving forwards has caused it to duplicate a date and going back has caused it to skip a date. This results in the graph appearing as above.

seam345 avatar Nov 15 '19 15:11 seam345