Skip to content

Fix relayout axis category #510

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

Merged
merged 6 commits into from
May 5, 2016
Merged

Fix relayout axis category #510

merged 6 commits into from
May 5, 2016

Conversation

etpinard
Copy link
Contributor

@etpinard etpinard commented May 4, 2016

@mdtusz @monfera (cc @chriddyp )

Relayout calls involving axis categoryorder and categoryarray were not updating the graph properly.

This PR fixes this and cleans up a few things in the axis category defaults code. I hope @monfera won't mind.

etpinard added 5 commits May 4, 2016 17:24
- trimmed down the logic
- make sure that axis.categoryarray is filled in
- use containerOut.type instead of containerIn.type
  (even though they are the same, we should always use
   the 'full' value of attributes after they get coerced)
- part one in fixing the category relayout bug
- by using the fullLayout (i.e. containerOur) specs, we ensure
  that ordered categories algo uses smartly-defaulted attributes.
- part two in fixing the category relayout bug.
- update the axis categories require a re-computation of the
  graphs calcdata.
@etpinard etpinard added bug something broken status: reviewable labels May 4, 2016
@etpinard
Copy link
Contributor Author

etpinard commented May 4, 2016

For reference, the original axis category PR was in #419.


var validCategories = layoutAttributes.categoryorder.values;
var isValidArray = (Array.isArray(arrayIn) && arrayIn.length);
Copy link
Contributor

Choose a reason for hiding this comment

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

I also like the brevity of a.length rather than a.length > 0 but assume that most places want the more explicit version :-)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Agreed. I'll change it to arrayIn.length > 0

@monfera
Copy link
Contributor

monfera commented May 4, 2016

@etpinard nice changes and very educational, most importantly I wholly missed the relayout aspect / regexp addition; wish to learn more about these in the near future. Re. spacing, I saw a=b as well as a = b at various places, I normally use the latter but saw a lot of the former, I'm of course glad to adhere to whichever style is preferred. And I totally like the detailed explanations in the commit messages, thanks!

@etpinard
Copy link
Contributor Author

etpinard commented May 5, 2016

Re. spacing, I saw a=b as well as a = b at various places

We should use a = b for now on. The space-infix-ops will be enforced soon.

most importantly I wholly missed the relayout aspect / regexp addition;

Plotly.restyle and Plotly.relayout are in dire need of a refactor.

We are currently using these ugly regex clauses to determine whether a restyle / relayout call requires:

  • to only update the styling (dostyle),
  • a plot over while keeping the same calcdata (doplot) or
  • a full plot / calc over (docalc).

@mdtusz
Copy link
Contributor

mdtusz commented May 5, 2016

Looks good to me. 💃

@monfera
Copy link
Contributor

monfera commented May 5, 2016

@etpinard this is also very useful! It would also worth copy/pasting it in a comment block. Just reading your comment on #66: initially, a glossary or a sentence/paragraph per main concept (trace, container, invasiveness of rerendering such as dostyle..docalc, etc.) as a straightforward braindump would be a great read for anyone new to the code base. It can be further edited etc. but an informal read-through soonish definitely beats a thorough, formal document a long time from now. Glad to help out on reading what you experienced folks write or maybe write a few easier ones.

@etpinard etpinard merged commit 6306e37 into master May 5, 2016
@etpinard etpinard deleted the relayout-axis-category branch May 5, 2016 16:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug something broken
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants