Skip to content

Non scaling stroke on zoom. #760

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

Closed
mdtusz opened this issue Jul 21, 2016 · 7 comments
Closed

Non scaling stroke on zoom. #760

mdtusz opened this issue Jul 21, 2016 · 7 comments

Comments

@mdtusz
Copy link
Contributor

mdtusz commented Jul 21, 2016

This only applies when using zoomScroll, but we should add vector-effect="non-scaling-stroke" to scatter lines so they don't embiggen and enshrinken too too much.

E.g. when scrolling on @rreusser 's example here

@rreusser
Copy link
Contributor

rreusser commented Jul 21, 2016

Correct me if I'm wrong, is it's not (reasonably) possible to apply that to markers, is it? Just paths? Or you can use actual markers but then they all have to be the same etc. so that for plotly this can really only be used on paths?

@mdtusz
Copy link
Contributor Author

mdtusz commented Jul 21, 2016

As far as I know, it only works on paths. We could counteract marker size changes easily enough as well though - just need to set r = radius/scale if I'm not mistaken.

@rreusser
Copy link
Contributor

rreusser commented Jul 21, 2016

SVG elements get redrawn all the time, so not sure there's a meaningful performance overhead to scaling points if the transform is just computed to a string once and applied a bunch—thought it's a bit ugly.

Added vector-effect: non-scaling-stroke; in the browser and appears to work fine, though obviously disappears as soon as you pause and it's redrawn. It's not immediately apparent to me that this would cause other problems since it's only present until it's redrawn—which only really happens on scroll zoom and soon-to-be transitions, unless I'm mistaken.

@rreusser
Copy link
Contributor

@mdtusz
Copy link
Contributor Author

mdtusz commented Jul 21, 2016

I think that would do it - I was testing in scatter/plot.js, but drawing may have a nicer deeper effect.

@rreusser
Copy link
Contributor

rreusser commented Jul 21, 2016

Pardon the hacky informality, but deployed a quick PoC with it added on that line here: https://rreusser.github.io/plotly-expression-transform/

that is,

drawing.lineGroupStyle = function(s, lw, lc, ld) {
    s.style('fill', 'none')
    .style('vector-effect', 'non-scaling-stroke')
    .each(function(d) {

A grep shows it's used in the following places:

src/components/colorbar/draw.js
390:                    .call(Drawing.lineGroupStyle,

src/components/drawing/index.js
83:drawing.lineGroupStyle = function(s, lw, lc, ld) {

src/components/legend/style.js
75:    line.call(Drawing.lineGroupStyle);

src/traces/contour/style.js
39:                .call(Drawing.lineGroupStyle,

src/traces/scatter/style.js
34:        .call(Drawing.lineGroupStyle);

src/traces/scattergeo/plot.js
231:    // GeoJSON calc data is incompatible with Drawing.lineGroupStyle

@rreusser
Copy link
Contributor

rreusser commented Jul 21, 2016

None of the other uses include transforms on the parent, I think, so I think it's relatively innocuous based on current usage. (Too bad point scaling can't be handled in parallel though.)

Although maybe it is better to scope it to scatter (and contour?) traces though… If it's not used elsewhere then it's not really necessary to set it elsewhere, even if it has no effect.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants