-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Add tickmode "proportional" #6827
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
base: master
Are you sure you want to change the base?
Conversation
- Create tickmode "proportional" - Map fractional tickvals to axis values w/ axis range: - Set ax.(minor?).tickvals to - Do that right before `arrayTicks()` is called - Every instance of `tickmode === "array"` gets `...|| "proportional"` This works well since tickmode "proportional" really just adds a preprocess step to tickmode "array". TODO: - Check if graph is reversed - Find where ticks are redrawn on zoom and make redraw proportional (will probably fix below) - Figure out why ticks not redrawn on double click/home - Add docs in layout
The algo has to set the tickvals property back to original value after spoofing it. This does that.
Re: 6d48a3b "Fix bug by which..." and "redrawing issue":
Issue was that replacing proportional values with actual values causes exponential |
8743766
to
00e884a
Compare
Alright that's pretty good. One more commit for whatever lint the bot picks up. I'll write tests after I get a response from devs. Questions for devs:
Tomorrow, a youtube video with results. |
This strategy currently doesn't work if both major and minor ticks are |
Plotly does some math on the ticks, sometimes comrparing major and minor values, so we have to store both in their own separate values and then restore them to their attribute at the very end so plotly has them throughout the calculating process.
These tests currently fail but this commit currently doesn't include fundamental bug fixes.
Alright, the testing is parameterized and randomized: It tests All It runs for File would obviously be renamed or put into other more relevant location. I don't understand how this concept would extend to multicategory especially since multicategory is Also, not sure how range padding is calculated but it might be convenient if the user were to know what proportion is added by padding so, eg., w/ |
Interesting PR. |
Two suggestions by Alex coming tonight:
Tomrrow: |
src/plots/cartesian/axes.js
Outdated
if(nt === 0) { | ||
// pass | ||
} else if(nt === 1) { | ||
tickVals = [0]; |
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.
tickVals = [0]; | |
tickVals = [0.5]; |
If you just want one tick I'd put it in the middle. Not that it matters much, this is horrible whatever we choose since you can't tell the scale at all.
src/plots/cartesian/axes.js
Outdated
Lib.nestedProperty(ax, 'tickvals').set(tickVals); | ||
} else { | ||
Lib.nestedProperty(ax.minor, 'tickvals').set(tickVals); |
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.
We should try to avoid altering real attribute values after the supplyDefaults
step. But you can set an underscored attribute like _tickvals
if you like, then you just need to look for that in arrayTicks
(if you're in one of the domain tickmodes). That should avoid the need to reset it later too, I'd imagine.
Also kudos on figuring out nestedProperty
- but it's overkill here since we know the attribute names, you can just do ax._tickvals = tickVals
etc - or if you feel like code golf, (major ? ax : ax.minor)._tickvals = tickVals
😎
So, I'm happy to write logic + tests for the tick-mode combination but I need it spelled out (and what do we do if they try a combo that doesn't work?- edit: I'll just take a look at how To confirm: Major Tickmode: Auto, Linear
allow:
Auto # (within major ticks)
Linear # (absolute values)
Array # (absolute values)
Major Tickmode: Array
allow:
Linear # (absolute values)
Array # (absolute values)
Major Tickmode: Sync
allow:
Sync # automatic
Major Tickmode: Full Domain
allow:
Full Domain # (within major ticks)
Domain Array # (within major ticks)
Major Tickmode: Domain Array
allow:
Domain Array # (within major ticks) |
- Use private ax._mappedTickvals instead - Remove use of Lib.nestedProperty during refactor
|
@ayjayt Would you please resolve the conflicts? |
'If *array*, the placement of the ticks is set via `tickvals`,', | ||
'which are actual values, and the tick text is `ticktext`.', | ||
'(*array* is the default value if `tickvals` is provided).', | ||
'If *full domain*, the number of ticks is set bia `nticks` but ticks', |
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.
'If *full domain*, the number of ticks is set bia `nticks` but ticks', | |
'If *full domain*, the number of ticks is set via `nticks` but ticks', |
For #6824:
The basic idea is that we create a mode called 'proportional' which is equivelent to 'array' but values are mapped from proportions before drawn.
Then again, array doesn't need to have to be recalculated on zoom, so it's not quite so simple.[0, .5, 1]
would be[left-most point, middle, right-most point]
.nb: includes my other trivial pull request about meta-charset
TODO: