goat1000/SVGGraph

Shape - Rect - X 'g' value is not correct

Opened this issue · 6 comments

For a longer period of time (several weeks) in the graph, the X-axis rectangles at the 'g' prefix move (approximately) 12 hours back. On the screenshote, the same time value is displayed as a graph (thin vertical lines and red dots) displayed correctly and also as a rectangle (wider vertical lines) drawn incorrectly - shifted backwards.
Reproducibility files included.
Version 3.10

screenshot-10 3 161 111-2021 10 22-12_53_33
svggraph.php.txt
data raw.txt

Actually, the rectangles are the in right place but the bars and markers are wrong. If you switch to a line graph or scatter graph the rectangles and markers will coincide.

This is a problem with all bar graph types and datetime data. The markers are in the wrong place on the bar and line graph because they are shifted to meet up with the bars, and the bars are drawn to fit between the grid lines. Bar graphs and datetime data don't work well together at all.

I have an idea for a fix, but I need to do some testing and make sure I don't break anything else.

In this case, the X-axis time labels are incorrect. The first line is at 1 p.m. Not exactly after midnight.
If there is a shorter time period in the graph, the data overlap correctly.

This is because bar graph labels are shifted from the matching grid position to the space between the grid lines underneath the bars. This doesn't make much sense for datetime data either, so I'll see if I can change that.

Also, I have the first bar at 10:56AM, so there may be a small time zone difference there.

OK. I'll wait for the fix. Thank you.
In my graph, I use the overlay of a bar graph with a rectangle, because I need to express not only the value but also the duration. Therefore, the rectangles have different widths.

Commit cc0dd7b should fix this so that the leading edge of bars are at the axis position for the given date/time, and the axis divisions are labelled instead of the gaps in between. Non-datetime graphs should not be affected by this change.

I don't know which time zone you are in, but I updated my script's time zone to 'Europe/Belgrade' and got the first bar appearing at about 1:00PM, so hopefully it should be drawing in the right place if your time zone is set appropriately.

I'm in a different time zone, but it's okay now.