-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Refactor Axes.doTicks and Axes.doTicksSingle #3254
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
Conversation
- the companion Axes methods are: drawTicks, drawGrid, drawZeroLine, drawLabels, drawTitle - axis-dependent params and functions are set as opts in drawOne - stash tickLabels selection on ax._tickLabels to use it in drawTitle w/o having to query the DOM again - some linting here and there.
... that uses Axes.drawOne, instead of Axes.doTicksSingle
... just like in the ternary case, but could potentially be used in elsewhere.
- say bye-bye to Axes.doTicks - remove a few not obsolete '-' field on ternary subplot axis objects.
- call full updateRadialAxis on radial drag and call full updateAngularAxis on angular drag. - no need to nest grid lines into extra <g> (that was an artifact from doTicksSingle. - ... more cleanup to come.
... to turn off crispEdge SVG rendering.
@etpinard this is awesome. Huge step in the right direction! Is all of this stuff sufficiently generalized that we could call most of it
Other than reading that comment I have no recollection of what's going on there... so I guess we just test what it seems to be worried about, which is dynamic title scoot. Do we have such tests? In the
Or even Anyway aside from ensuring we have tests for 5858067 I wouldn't consider any of my comments ^^ blocking, just opportunities to push this even farther, if you've got the appetite for it. |
src/plots/cartesian/axes.js
Outdated
@@ -1805,7 +1805,7 @@ axes.drawTicks = function(gd, ax, opts) { | |||
ticks.enter().append('path') | |||
.classed(cls, 1) | |||
.classed('ticks', 1) | |||
.classed('crisp', 1) | |||
.classed('crisp', !opts.noCrisp) |
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.
Yeah, that's cool! But I'm not a huge fan of negated option names - could we use:
opts.crisp !== false
?
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.
Done in 016b8e4
... so that one can call it after dynamically adding MathJax <script> on page.
- so that one can include MathJax by adding a <script> for a given test.
- Removing MathJax from the page currently leads to errors in downstream tests.
Looks like everything is ok: 6ccc457 ... by the way |
Love it. 💃 |
I gave this a go this morning. I couldn't easily decide where to put a few things (e.g. Thinking about this, it might be nice to make a distinction between "registerable" (i.e optional) component modules (e.g. |
please review this PR commit-by-commit
Axes.doTicksSingle
is currently used to compute and draw ticks, but also grid lines, tick labels, axis titles ... and a few more things. It is used by cartesian axes (viaAxes.doTicks
), colorbars, ternary axes and polar axes. Making that one single function work for all these cases turnedAxes.doTicksSingle
into hackcity 😨In brief, this PR:
Axes.doTicksSingle
intodrawTicks
,drawGrid
,drawZeroLine
anddrawLabels
Axes.drawOne
Axes.doTicks
->Axes.draw
, this one draws multiple (or all) cartesian axesAxes.drawOne
drawTitle
,calcBoundingBox
anddoAutoMargin
- which only get called by cartesian axes - fromdrawLabels
Note: commit 5858067 is potentially dangenerous. No tests are failing because of it, but ignoring this comment:
plotly.js/src/plots/cartesian/axes.js
Lines 1940 to 1943 in 3a32ac0
makes me nervous.
A few things in
axes.js
could still be ironed out to make it even more "reusable":ax._id.chaAt(0)
, this could made more general by adding a newopts
flag e.g.orientation: 'h' | 'v'
Axes.drawLabels
could be made more d3-esque, but I worrying about potential performance losses.but hopefully you'll find this PR a step in the right direction.
cc @plotly/plotly_js
TODO: