metricq / metricq-webview

📈 A visualization of MetricQ data exploiting the advantages of the HTA db backend

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

2024 X-axis broken

tilsche opened this issue · comments

The time axis is very broken starting 1 Jan 2024. It somehow does not show any ticks at the first(?) day after the start timestamp?!

Hi Thomas,

I looked into this, setting a Breakpoint in with Firefox's JavaScript-Debugger. Apparently the
Fix#196: X-Axis-Labeling, when incrementing year, be aware of Leap Years is the culprit. I noticed, the leap year check is incomplete here in Line 207:

When we have a leap year (like 2024), the implementation adds a whole day to the first x-axis tick step - regardless of whether it's before the leap day or after.

Suggested solutions:

  • (A) wait until February 29th, 2024, then the bug will be much less noticeable.
  • (B) extend the aforementioned code line 207, with it's if condition by adding an additional check for if it's past the leap day, e.g. && (2 <= stepStart.getMonth() || (1 == stepStart.getMonth() && 29 <= stepStart.getDate()))[*]

Kind regards,
Lars

[*] Footnote: JavaScript's Date object starts counting Months with 0, while for the days during the month it starts counting at 1.

Thanks for the analysis. Do you mind creating a PR for solution (B)?

Thanks for the PR. I've deployed it and so far it looks good in production.