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

🐛 (grapher) show a minimum of two tick labels if possible #3239

Merged
merged 1 commit into from
Feb 29, 2024

Conversation

sophiamersmann
Copy link
Member

@sophiamersmann sophiamersmann commented Feb 23, 2024

Problem

Solution

  • Given a number of base ticks, we want to find a subset of ticks whose labels are not overlapping:
    • The original strategy figured out which tick labels to hide so that we don't end up with overlapping tick labels
    • The updated strategy does the same but retries if we end up with a single visible tick label:
      1. Hide overlapping ticks, allowing for some padding (3px) between tick labels (this is the original strategy)
      2. If we end up with a single tick label, try again but reduce the allowed padding between tick labels (1px) – note that for vertical axes, padding between tick labels is not essential
      3. If we still end up with a single tick label, then there really isn't enough space to show a second label – in such cases, try to show a "useful" tick label; in other words, if the zero tick is visually marked by a solid line, deprioritise it, such that a non-zero tick label is chosen to be displayed

Example (from the original issue)

Before After
Screenshot 2024-02-26 at 10 20 17 Screenshot 2024-02-26 at 10 20 22
Only zero ticks are shown, which makes it impossible to read the chart We don't have space for a second tick, but we choose to show a non-zero tick, which gives useful information

SVG tester

Screenshot 2024-02-26 at 10 12 10

Adds an additional grid line (makes no difference really). (The second chart in the top row is broken in another way, which is fixed in this PR)

Screenshot 2024-02-26 at 10 11 17

Displays some more tick labels (which is a good thing)

Copy link
Member Author

Current dependencies on/for this PR:

This stack of pull requests is managed by Graphite.

@sophiamersmann sophiamersmann changed the title 🐝 (grapher) show a minimum of two ticks 🐛 (grapher) show a minimum of two tick labels if possible Feb 26, 2024
@sophiamersmann sophiamersmann force-pushed the minimum-tick-count branch 2 times, most recently from 2b88db3 to 7634c86 Compare February 26, 2024 09:39
@sophiamersmann sophiamersmann marked this pull request as ready for review February 26, 2024 09:49
Copy link
Contributor

@danyx23 danyx23 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Neato!

@sophiamersmann sophiamersmann merged commit 5d6ff28 into master Feb 29, 2024
19 of 26 checks passed
@sophiamersmann sophiamersmann deleted the minimum-tick-count branch February 29, 2024 07:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Show at least 2 y-axis labels in charts with multiple panels
2 participants