Skip to content

scattergl reversed lines bug #2904

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
someusersomeuser opened this issue Aug 15, 2018 · 3 comments · Fixed by #3078
Closed

scattergl reversed lines bug #2904

someusersomeuser opened this issue Aug 15, 2018 · 3 comments · Fixed by #3078
Assignees
Labels
bug something broken

Comments

@someusersomeuser
Copy link

https://codepen.io/anon/pen/EpJObQ
for scattergl
if autorange: 'reversed'
with mode: 'lines+markers' works fine, but with mode: 'lines' - one incorrect horisontal line (hints display correctly on free space)

@etpinard
Copy link
Contributor

Thanks for the report!

@archmoj
Copy link
Contributor

archmoj commented Sep 28, 2018

As well as { autorange:'reversed' }, I observed that the issue also exists using
{ ranges:[a, b] } when a > b.

@archmoj
Copy link
Contributor

archmoj commented Oct 1, 2018

The bug is actually related to the modification of scale parameter within the vertex-shader of regl-line2d library: node_modules/regl-line2d/miter-vert.glsl
For any reversed axis the scale value was replaced by positive epsilon: 1e-6 by the max function. This resulted in display of an almost horizontal/vertical line (depending on which axis was reversed).

The users may also wait for additional tests to be completed and possibly a new release of the mentioned library.

In the meantime using the following function inside the vertex-shader file could help fix the issues e.g. reversed bounds in 2D space.

float repaireScale( float a ) {
	float b = a;
	if (abs(b) < MIN_DIFF) {
		if (b < 0.0) b = -MIN_DIFF;
		else b = MIN_DIFF;
	}
	return b;
}

void main() {
	vec2 aCoord = aCoord, bCoord = bCoord, prevCoord = prevCoord, nextCoord = nextCoord;

	vec2 newScale = scale; 
	newScale.x = repaireScale(newScale.x);
	newScale.y = repaireScale(newScale.y);
  
	vec2 scaleRatio = newScale * viewport.zw;
  
  ...

}

archmoj added a commit that referenced this issue Oct 24, 2018
Upgrade regl-line2d module to fix scattergl bug when using reversed bounds with only line type, issue #2904
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 a pull request may close this issue.

3 participants