-
-
Notifications
You must be signed in to change notification settings - Fork 229
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Ensure x-axis in stacked bar charts is linear #2086
Conversation
Cool, this is working well already!
I think we should do one of these two. The ugly hack could just be that we disable this behaviour for charts with daily data. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's quite a lot of comments! Sorry, totally didn't want to roast your code; there's just a bunch of edge cases in here that don't work well, and a bunch of perf improvements for the common case.
packages/@ourworldindata/grapher/src/stackedCharts/StackedUtils.ts
Outdated
Show resolved
Hide resolved
Thanks for the review!
Makes sense! Let's do that for the moment then :) |
404b453
to
848df7a
Compare
fixes #1865
Problem
If observations are unevenly spaced, stacked bar charts end up with a non-linear x-axis.
Solution
To enforce uniform spacing along the axis, this PR implements Marcel's suggestion that involves computed the greatest common divisor. In Marcel's words, the gist of it is:
Weirdnesses
The SVG tester comes back with one problematic chart:
Problem: This chart shows monthly data but since we currently have no native way to represent monthly data, this data is treated as daily data where only the 15th of every month is assigned a data point. Working with daily measurements becomes a problem here because slightly different deltas (number of days between measurements, i.e. 28, 30 or 31 days) lead to a small greatest common divisor (=1), and this leads in turn to many fake data point added (one for every day!).
Possible Solutions: This would be solved by making monthly data a first-class citizen as suggested in this issue. Going forward, we could either: