Closed archmoj closed 4 years ago
@dy @etpinard OK. The tests are tweaked with half sizes and passed noting that we should maintain sizes identical to (the old use of) pixelRatio=2 in plotly.js
baselines. If all is good we may publish a minor and include these changes in the next plotly.js
minor.
@dy Possibly any updates on this? If you still think that this is not the right fix, please let me know. Maybe we could find another way to tweak the API on the plotly.js side? Thank you in advance.
@archmoj I did not mean to delay, sorry. Yes, I think that now pixelRatio
is handled correctly - it scales points up depending on the device or passed pixelRatio
. If we remove that support, the regl-scatter2d will render points with 1:1 pixels binding, which makes pixelRatio option useless.
If you want to fix pixelRatio
to some value, you can do that externally, that option is exactly for that.
@dy Thank you very much for the follow ups.
In fact we prefer not to pass a constant value there.
Here is another codepen comparing pixelRatio
values equal to 1 and 2 that uses current regl-line2d
& regl-scatter2d
modules. The line widths are identical but the marker sizes are not.
Yep, the problem is on the regl-line2d side. It just doesn't account for pixelRatio
. regl-scatter2d works as intended.
Thanks for your hard work @archmoj - your patch appears to make
scattergl
consistent with how markers are drawn inscatter3d
soAs this repo remains in @dy 's hands, we could perhaps make this new/consistent
pixelRatio
behaviour an opt-in e.g. by adding a boolean flag toregl-scatter2d
that we would turn on upon instantiating in plotly.js
Great idea @etpinard. Applied in https://github.com/gl-vis/regl-scatter2d/pull/20/commits/9c0933a1df175f0bb6ba39a5e71e351e67161f2d.
@dy this should be good to go as tested on plotly side as well as here without any changes to the tests. Would you mind reviewing it again? Thanks in advance.
Gentlemen, I can't understand - why passing plotly's pixelRatio
at all, if you need that constant? Just initialize regl-scatter2d with {pixelRatio: 2}
from any trace and we're good to go, it will behave the same way as the other gl components. It is also shorter than {pixelRatio: plotlyPixelRatio, constantPixelRatio: true}
.
@etpinard that's great option, but no need to pass it to regl-scatter, pass {pixelRatio: constant}
instead and that's it. Eg. here
https://github.com/plotly/plotly.js/blob/225521271f2eb7f5803713a28d8a7e0ef16ccc57/src/traces/scattergl/index.js#L116
just add an extra-line
// fix pixel ratio to accommodate other gl-components api
opts.marker.pixelRatio = 2.
Added new option
constPointSize
to help maintain marker sizes with differentpixelRatio
values.Fix for issue https://github.com/plotly/plotly.js/issues/3246. Kindly visit PR https://github.com/plotly/plotly.js/pull/3637 for more information. @dy cc: @etpinard