Skip to content

Reduce tick count#57

Merged
david-mears-2 merged 10 commits intomainfrom
reduce-tick-count
Feb 4, 2026
Merged

Reduce tick count#57
david-mears-2 merged 10 commits intomainfrom
reduce-tick-count

Conversation

@david-mears-2
Copy link
Contributor

@david-mears-2 david-mears-2 commented Feb 3, 2026

(This is just a small iterative improvement rather than a total solution to the tick count issue. Total solution is captured by the following ticket: https://mrc-ide.myjetbrains.com/youtrack/issue/mrc-6854/Exclude-non-integer-exponent-tick-labels - a nice-to-have)

Skadi-chart version increments in order to make use of the bugfix on which these changes depend.

In general we seem to get a nicer selection of tick labels by using a lower tick count config than default (which is 10): fewer non-integer exponents appear.

Note that d3 seems to take the tick count argument as a guide about the number of ticks to aim for on either side of 0, so if we want a roughly consistent number of ticks between plot views, we need to set a different count property depending on whether the range crosses zero.

This PR should reduce the tick count by around 50%-70%, since d3's default tick count target is 10. Tick count config is only 'approximately' respected by d3, which means setting the count too low risks ending up with even fewer ticks than you bargained for.

This is just a small iterative improvement rather than a total solution
to the tick count issue. This should reduce the tick count by about half
on average, since d3's default tick count target is 10. Tick count config
is only 'approximately' respected by d3.
@codecov
Copy link

codecov bot commented Feb 3, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 98.29%. Comparing base (2855d9e) to head (f5fc5f2).
⚠️ Report is 11 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main      #57   +/-   ##
=======================================
  Coverage   98.28%   98.29%           
=======================================
  Files          25       25           
  Lines         583      586    +3     
  Branches      143      145    +2     
=======================================
+ Hits          573      576    +3     
  Misses         10       10           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

david-mears-2 and others added 7 commits February 3, 2026 13:52
This is because d3 treats the count property differently depending on whether
the range crosses zero (it seems to determine the number of ticks *on either side
of zero*, not the total number of ticks)
This is because d3 treats the count property differently depending on whether
the range crosses zero (it seems to determine the number of ticks *on either side
of zero*, not the total number of ticks)
@david-mears-2 david-mears-2 marked this pull request as ready for review February 3, 2026 15:41
},
"dependencies": {
"@reside-ic/skadi-chart": "^1.1.13-alpha.0",
"@reside-ic/skadi-chart": "^1.1.13-alpha.1",
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Note to self: increment this if skadi-chart has moved on, see mrc-ide/skadi-chart#87

Copy link
Contributor

@EmmaLRussell EmmaLRussell left a comment

Choose a reason for hiding this comment

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

Tick count config is only 'approximately' respected by d3

😆 I suppose approximate respect is better than nothing...

It does seem like quite baffling behaviour. This looks fine for a stopgap!

@david-mears-2
Copy link
Contributor Author

david-mears-2 commented Feb 4, 2026

Tick count config is only 'approximately' respected by d3

😆 I suppose approximate respect is better than nothing...

It does seem like quite baffling behaviour. This looks fine for a stopgap!

I kind of get it because if your scale is not predictable, you wouldn’t be able to predict the precise number of ticks you want in advance, without writing logic yourself.

@david-mears-2 david-mears-2 merged commit a2d2b1d into main Feb 4, 2026
4 checks passed
@david-mears-2 david-mears-2 deleted the reduce-tick-count branch February 4, 2026 21:20
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.

2 participants