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

Handle 'missing' matching axes #4529

Merged
merged 11 commits into from Jan 31, 2020
Merged

Conversation

etpinard
Copy link
Contributor

fixes #4501 - attempts to supersede @archmoj 's #4506 by implementing "solution 1" as presented in #4501 (comment)


Examples:

Pinging @alexcjohnson @nicolaskruchten who may want to try these examples.


For the reviewers, commit 33078b0 adds a way to track (in fullLayout._axisMatchGroups) and coerce the 'missing' axes which are referenced via the matches attributes but that do not have traces on them (i.e. are not coerced into fullLayout otherwise). Commit df1c59f makes the downstream logic work: as far as I could tell we only needed to skip missing axes during Axes.drawOne and during the _axisMatchGroups autorange sync operation.

archmoj and others added 4 commits January 29, 2020 14:35
- keep list of valid but missing `matches` value
- coerce the missing axes in fullLayout
- include the missing axes in the list of valid `matches` values
- add a few comments about the variables used in the cartesian
  supplyLayoutDefaults routine.
- add jasmine supplyDefaults tests!
- do not consider 'missing' axes during autorange sync-up operation
- do not attempt to update missing axes on drag and
  other relayout calls that reference missing axes
@nicolaskruchten
Copy link
Member

Just to confirm: this does or could work with other attributes than range like categoryarray and alignmentgroup and so on?

@alexcjohnson
Copy link
Contributor

Looks great! My only code comment is it may be possible to 🌴 the missing & real axis coercion code a bit, but OTOH that could make it less readable... so definitely non-⛔️

Just to confirm: this does or could work with other attributes than range like categoryarray and alignmentgroup and so on?

It certainly looks like that should work, it does a fairly complete coercion of attributes on these missing axes, making no explicit mention of range in the process. But yeah, may be nice to include tests of these other attributes.

@etpinard
Copy link
Contributor Author

this does or could work with other attributes than range like categoryarray and alignmentgroup and so on?

Does anyone have a px example ready that uses categoryarray and alignmentgroup?

@etpinard
Copy link
Contributor Author

etpinard commented Jan 30, 2020

My only code comment is it may be possible to the missing & real axis coercion code a bit, but OTOH that could make it less readable... so definitely non-

Yeah, I paid special attention to making this new code as readable as it can be. The cartesian supplyLayoutDefaults logic is already pretty complex.

... we'll see what @archmoj thinks about it.

@nicolaskruchten
Copy link
Member

Here's a PX-output case with alignmentgroup set: https://codepen.io/nicolaskruchten/pen/ExaOMRr?editable=true

@nicolaskruchten
Copy link
Member

If you set categoryarray on the x axis there, we would like it to propagate.

@etpinard
Copy link
Contributor Author

Thanks for the example @nicolaskruchten

Things appear to work ok with categoryarray set in the missing x axis: https://codepen.io/etpinard/pen/QWwXKPd

but one must set xaxis.type: 'category' first, because as the x axis doesn't have any traces associated with it, we get the default xaxis.type: 'linear'. Recall that matching axes of different type values is forbidden.

I suspect that setting type: 'category' isn't ideal in the PX context, so let me try to find a way to propagate the axis type through to the 'missing' axes.

@etpinard
Copy link
Contributor Author

etpinard commented Jan 30, 2020

Things appear to work ok with categoryarray set in the missing x axis:

Actually, the x categories are reversed, we should show Male then Female in this case with xaxis.categoryarray: ['Male', 'Female'].

On it.

@nicolaskruchten
Copy link
Member

Hmm well today PX sets categoryorder/categoryarray a little oddly and I can't remember why: it sets it on every x axis in the bottom row and every y axis in the left column. That seems like a leftover from the pre-matches days. PX could just set it on all axes though if that makes things easier. Arguably setting it on the bottom-most row is enough, as there will always be at least one valid x axis in the bottom-most row for PX plots.

@nicolaskruchten
Copy link
Member

(and ditto one valid y-axis in the left-most column)

but that's a very PX-specific property.

- this does not fix any bugs as the downstream fixedrange check use
  !fixedrange, but it's probably a good idea to get this into
  fullLayout to avoid potential bugs down the road.
- now they correctly omit subplot 'xy' and axes 'x' and 'y'
  from the initial fullLayout
... so that their references are valid during
    handleConstraintDefaults
... so that if ever a `categoryarray` is set in a
    missing axis, it gets correctly linked with the other
    axes in the match group.

    ++ add image mock!
@etpinard
Copy link
Contributor Author

Axis type propagation and categoryarray behaviour on missing axes is now fixed:

https://codepen.io/etpinard/pen/MWYMpGm

@archmoj this PR is ready for another round of review.

@archmoj
Copy link
Contributor

archmoj commented Jan 31, 2020

@etpinard thanks very much for this great PR.

💃 💃 💃
💃 💃 💃
💃 💃

@etpinard etpinard merged commit 6cf8b64 into master Jan 31, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Axis matching limitation
4 participants