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

scattergl: categorical data is not drawn while zooming or panning #6814

Closed
harrisonmg opened this issue Dec 8, 2023 · 9 comments · Fixed by #7018
Closed

scattergl: categorical data is not drawn while zooming or panning #6814

harrisonmg opened this issue Dec 8, 2023 · 9 comments · Fixed by #7018
Labels
bug something broken regression this used to work
Milestone

Comments

@harrisonmg
Copy link

harrisonmg commented Dec 8, 2023

example: https://codepen.io/Harrison-Gieraltowski/pen/wvNOJMp

When changing to the pan tool and panning, the points disappear until the mouse is released.

This is not the case if the X and Y values are purely numerical. Changing all of the Y values to a simple string does work, however.

scrollZoom doesn't seem to work in codepen so I can't demonstrate it.

@CallumNZ
Copy link
Contributor

CallumNZ commented Jan 9, 2024

I'm seeing the same issue. From what I can tell the bug was introduced in version 2.26.0 (it works fine in the previous version 2.25.2).

@micah-svenson
Copy link

micah-svenson commented Mar 7, 2024

I also see the same issue. Numeric data on both axes has no problem, but plotting time on one axis causes the behavior.

In addition to points disappearing on pan, I also see points disappear when using the drag to zoom feature.

I'm using Plotly.js 2.29.0

@eiriklv
Copy link
Contributor

eiriklv commented Jun 5, 2024

+1 on this. Having this issue when using time on one axis (2.33.0)

@eiriklv
Copy link
Contributor

eiriklv commented Jun 6, 2024

I guess I have to get super familiar with the internals - because it's not clear to me what changed here to break it: v2.25.2...v2.26.0

@eiriklv
Copy link
Contributor

eiriklv commented Jun 6, 2024

Found the root cause - the issue seems to be this commit: ab9d1cc

If you comment out those lines it works as expected. I'm assuming that it does not take into account some edge case related to dates.

@eiriklv
Copy link
Contributor

eiriklv commented Jun 6, 2024

@eiriklv
Copy link
Contributor

eiriklv commented Jun 6, 2024

Here is the fix:

if (sp._scene) {
  var xrng = Lib.simpleMap(xa.range, xa.r2l);
  var yrng = Lib.simpleMap(ya.range, ya.r2l);

  if (xa.limitRange) xa.limitRange();
  if (ya.limitRange) ya.limitRange();

  // date strings for the x axis needs to be converted
  // into ms, otherwise it corrupts the plot and removes
  // any scattergl traces while zooming or panning
  if (xa.type === "date") {
    xrng = xa.range.map((range) => Lib.dateTime2ms(range, xa.calendar));
  } else {
    xrng = xa.range;
  }

  yrng = ya.range;

  sp._scene.update({
    range: [xrng[0], yrng[0], xrng[1], yrng[1]],
  });
}

@eiriklv
Copy link
Contributor

eiriklv commented Jun 6, 2024

Or even simpler:

if (xa.limitRange) xa.limitRange();
if (ya.limitRange) ya.limitRange();

var xrng = Lib.simpleMap(xa.range, xa.r2l);
var yrng = Lib.simpleMap(ya.range, ya.r2l);

@CallumNZ
Copy link
Contributor

CallumNZ commented Jun 6, 2024

Thank you @eiriklv !!

@archmoj archmoj added this to the v2.34.0 milestone Jul 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug something broken regression this used to work
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants