Skip to content
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

✨ use 'nice' axis ticks for linear scales / TAS-795 #4404

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

sophiamersmann
Copy link
Member

@sophiamersmann sophiamersmann commented Jan 8, 2025

Resolves #3978

See 3790bad 😅

Relying on d3's nice implementation sometimes leads to suboptimal results because d3 adds grid lines too eagerly (some examples below). That's why I ended up writing a custom 'nice' function for Grapher. It only adds an additional grid line if any data value exceeds the highest grid line by more than 25%.

Examples of d3.nice where grid lines are placed to eagerly

If any data value is just above a grid line, then showing an additional grid line 'squishes' the rest of the chart.

Screenshot 2025-01-09 at 11 55 45 Screenshot 2025-01-09 at 11 56 29

@owidbot
Copy link
Contributor

owidbot commented Jan 8, 2025

Quick links (staging server):

Site Dev Site Preview Admin Wizard Docs

Login: ssh owid@staging-site-nice-axis-ticks

SVG tester:

Number of differences (default views): 774 (9d24b2) ❌
Number of differences (all views): 398 (0b4cae) ❌

Edited: 2025-01-13 10:06:21 UTC
Execution time: 1.35 seconds

@sophiamersmann sophiamersmann force-pushed the nice-axis-ticks branch 2 times, most recently from 5dc4d1c to 0a553e6 Compare January 8, 2025 13:47
@sophiamersmann sophiamersmann changed the title ✨ (line) use 'nice' axis ticks ✨ use 'nice' axis ticks for linear scales Jan 8, 2025
@sophiamersmann sophiamersmann added the staging-viz Let SVG tester fail silently in CI label Jan 8, 2025
@sophiamersmann sophiamersmann force-pushed the nice-axis-ticks branch 5 times, most recently from 3d2b603 to d6d2059 Compare January 10, 2025 14:03
@sophiamersmann sophiamersmann changed the title ✨ use 'nice' axis ticks for linear scales ✨ use 'nice' axis ticks for linear scales / TAS-795 Jan 10, 2025
Copy link

@sophiamersmann sophiamersmann force-pushed the nice-axis-ticks branch 5 times, most recently from 65ed9a4 to 1c67721 Compare January 13, 2025 09:50
🚧 remember nice ticks
fine-tune
@sophiamersmann sophiamersmann force-pushed the nice-axis-ticks branch 2 times, most recently from 2bd61fc to be61693 Compare January 13, 2025 14:47
@sophiamersmann sophiamersmann marked this pull request as ready for review January 13, 2025 15:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
staging-viz Let SVG tester fail silently in CI
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Horizontal grid lines: adding these more frequently
2 participants