Skip to content

Proper parcoords axis tick scale when ticktext is unordered #1945

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 5 commits into from
Aug 16, 2017

Conversation

monfera
Copy link
Contributor

@monfera monfera commented Aug 10, 2017

Fixes #1941 whose original report is plotly/plotly.R#1096 (comment).

The problem arose due to not properly supporting unordered tick labels (ticktext), fixed with this commit, line 72.

While at it, an additional safeguard was added in line 560, for the eventuality that a falsey ticktext eg. 0 is used such that the corresponding tickvals value is non-zero.

A test change was made to exercise both the out of order ticktext and the falsey value (0). It is expected that the 0 tick label does show up; and that it shows up as zero rather than its corresponding tickvals value which is 3. Note: the purpose of tickvals is the appropriate vertical placement of the tick to give the user flexibility, for example, uneven distance between adjacent ticks.

@monfera monfera self-assigned this Aug 10, 2017
@monfera monfera added the bug something broken label Aug 10, 2017
@monfera monfera force-pushed the parcoords-unordered-ticktext branch from dc1f191 to 926e7c6 Compare August 10, 2017 11:18
@@ -557,7 +557,7 @@ module.exports = function(root, svg, styledData, layout, callbacks) {
.outerTickSize(2)
.ticks(wantedTickCount, d.tickFormat) // works for continuous scales only...
.tickValues(d.ordinal ? // and this works for ordinal scales
sdom.map(function(d, i) {return texts && texts[i] || d;}) :
sdom.map(function(d, i) {return texts && texts[i] !== undefined ? texts[i] : d;}) :
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe filter out null too?

Actually, looks like cartesian tickvals / ticktext just stringifies falsy values: https://codepen.io/etpinard/pen/aywJNK?editors=0010 - which might be considered a bug, but I'd vote for making the parcoord implementation consistent(ly buggy).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

What this does right now: if ticktext[i] is undefined, ie. the array is nonexistent or too short, then it'll use the tickvals[i] value (which can be the intention), represented as the d in the green line. If it's however defined, then it'll be used (and stringified) whether falsy or not, in line with what you describe for Cartesian. Is it OK or would you rather that a missing ticktext array or missing ticktext[i] yields an 'undefined' as the tick label?

Copy link
Contributor

Choose a reason for hiding this comment

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

Is it OK or would you rather that a missing ticktext array or missing ticktext[i] yields an 'undefined' as the tick label?

Ideally, it would be nice to make parcoords reuse some of the cartesian/axes.js routines.

Now, should we consider the current cartesian behavior a bug? I'd vote yes. I'd think only typeof strings ticktext values should be visible cc @alexcjohnson

Copy link
Contributor Author

Choose a reason for hiding this comment

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

What should be the next step? It'd be good to see the missing tick label fixed promptly and continuing the above convo here, or I could copy it in a separate issue to be discussed.

Copy link
Contributor

Choose a reason for hiding this comment

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

What should be the next step?

Enjoy your weekend. We'll revisit this Monday 🎉

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@alexcjohnson to summarise if I understand your latest comments and Étienne's comment on the top, this PR needs these:

  1. in parcoords, if ticktext[i] is either undefined or null, then we consider it unsupplied, ie. revert to just using tickvals[i] (the current PR currently checks for undefined only but I can extend)
  2. tickvals[i] should be subject to tickformat as on my above screenshot with the percentages in column 3 and 4.
  3. these things should be locked down in test so that, when we get around to axis unification, we can detect regressions
  4. I'd create an issue that refers to comments in this PR that would be the basis for considering a change in cartesian such that it also does what's described in point 1 of this list

Copy link
Collaborator

Choose a reason for hiding this comment

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

@monfera that all sounds exactly right 💯

Copy link
Contributor

Choose a reason for hiding this comment

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

in parcoords, if ticktext[i] is either undefined or null, then we consider it unsupplied, ie. revert to just using tickvals[i] (the current PR currently checks for undefined only but I can extend)

Maybe even: if ticktext[i] is either undefined or null or false [...]?

Copy link
Collaborator

Choose a reason for hiding this comment

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

I'd let false pass through (ie get stringified) - not super useful, but it would be weird to stringify true but turn false into some number. null and undefined don't have opposites in the same way.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks for the clarifications! The commit is done but I want to do some code simplification once crossfilter is tightened up. I can push where I am though.

@monfera
Copy link
Contributor Author

monfera commented Aug 15, 2017

The last commit unifies the discussed logic, please take another look at it 👍

return dd;
}
}) :
sdom.map(toText(Lib.identity), texts) :
Copy link
Collaborator

Choose a reason for hiding this comment

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

Am I missing someting or are the () not in the right place here?
sdom.map(toText(Lib.identity, texts))

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks @alexcjohnson for the catch, thought it was magic that it still worked! Turns out, the domainScale change (same PR, higher up in the code) made scale.domain() to return the desired values anyway, which got mapped with the identity function (as texts was not supplied ie. falsey).

Copy link
Collaborator

Choose a reason for hiding this comment

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

:) surprised me too, esp. since this seems to be fully tested. Thanks for figuring out what's really happening.

@alexcjohnson
Copy link
Collaborator

Looks great to me! 💃

@monfera monfera merged commit b98aac2 into master Aug 16, 2017
@monfera monfera deleted the parcoords-unordered-ticktext branch August 16, 2017 19:00
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.

missing ticktext in parcoords
3 participants