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

better zooming behavior for errorbars, bars, and box plots #1897

Merged
merged 1 commit into from
Jul 19, 2017

Conversation

alexcjohnson
Copy link
Collaborator

fixes #1879 and a few related effects:

  • non-scaling stroke on errorbars, bar outlines, and box plots
  • include box plot points in the rescaling we do for scatter points

As far as I can tell that's everything we put on SVG cartesian axes.

Not sure if there's a useful way to test this - I was pondering making a complicated plot and testing that every <path> on it either has vector-effect: non-scaling-stroke set or matches .scatterlayer .points .point or .boxlayer .points .point but I kind of feel like that will cause more problems than it solves, and now that we know about these strategies we won't forget to use them when we make new trace types.

cc @etpinard

@@ -117,6 +118,7 @@ module.exports = function plot(traces, plotinfo, transitionOpts) {

if(isNew) {
xerror = errorbar.append('path')
.style('vector-effect', 'non-scaling-stroke')
Copy link
Contributor

Choose a reason for hiding this comment

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

Something still looks off:

peek 2017-07-19 11-15

Looks like the whiskers appear thicker during zooms.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

right - because that's about the length of the whisker, not its stroke. I couldn't think of a way to handle this at first but now that you mention it, I suppose we could have the x scale of the y errorbars (and the y scale of x error bars) get inverse-scaled the same way as we do for both x and y scales of the points... I can look into this but it may take a little more work, do you think it's worth holding up this PR or shall I tackle it separately later?

Copy link
Contributor

@etpinard etpinard Jul 19, 2017

Choose a reason for hiding this comment

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

right - because that's about the length of the whisker, not its stroke

Thanks for clarification 📚

do you think it's worth holding up this PR or shall I tackle it separately later?

Not worth holding up this PR. 👍

Opening a new issue will be just fine.

@@ -747,7 +747,7 @@ module.exports = function dragBox(gd, plotinfo, x, y, w, h, ns, ew) {
.call(Drawing.setTranslate, clipDx, clipDy)
.call(Drawing.setScale, xScaleFactor2, yScaleFactor2);

var scatterPoints = subplot.plot.select('.scatterlayer').selectAll('.points');
var scatterPoints = subplot.plot.selectAll('.scatterlayer .points, .boxlayer .points');
Copy link
Contributor

Choose a reason for hiding this comment

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

Nice touch 👌

@etpinard etpinard added status: reviewable bug something broken labels Jul 19, 2017
@etpinard
Copy link
Contributor

Not sure if there's a useful way to test this -

I can't think of one either. I'm ok leaving this thing untested.

@etpinard
Copy link
Contributor

Somewhat related:

peek 2017-07-19 11-23

should we scale back contour labels that same what we do for scatter text nodes?

@alexcjohnson
Copy link
Collaborator Author

should we scale back contour labels that same what we do for scatter text nodes?

We could consider it. The space available for the labels will not scale back though, so when you zoom out the labels will start to overlap the lines, and when you zoom in they'll get disconnected.

@@ -124,8 +124,10 @@ module.exports = function plot(gd, plotinfo, cdbar) {
// append bar path and text
var bar = d3.select(this);

bar.append('path').attr('d',
'M' + x0 + ',' + y0 + 'V' + y1 + 'H' + x1 + 'V' + y0 + 'Z');
bar.append('path')
Copy link
Contributor

Choose a reason for hiding this comment

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

Non- ⛔ comment


What about bar text labels?

peek 2017-07-19 11-39

they probably would benefit from the same tricks scatter text nodes get on scroll

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

These are also tricky - as sometimes they will scale up, sometimes they won't, and sometimes they'll move or rotate after the zoom. Also I played around with including them and the element structure isn't quite set up the same way as scatter text points so it's nontrivial to make it work. I'll add this to the list of possible future improvements.

@etpinard etpinard added this to the 1.29.0 milestone Jul 19, 2017
@alexcjohnson
Copy link
Collaborator Author

open items collected in #1899

@etpinard
Copy link
Contributor

Solid improvements 💃

@alexcjohnson alexcjohnson merged commit 1879cf9 into master Jul 19, 2017
@alexcjohnson alexcjohnson deleted the errorbars-nss branch July 19, 2017 20:21
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.

Set non-scaling-stroke effect for error bars
2 participants