Conversation
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 Report✅ All modified and coverable lines are covered by tests. 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. 🚀 New features to boost your workflow:
|
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)
| }, | ||
| "dependencies": { | ||
| "@reside-ic/skadi-chart": "^1.1.13-alpha.0", | ||
| "@reside-ic/skadi-chart": "^1.1.13-alpha.1", |
There was a problem hiding this comment.
Note to self: increment this if skadi-chart has moved on, see mrc-ide/skadi-chart#87
There was a problem hiding this comment.
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. |
(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
countargument 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.