Selection changes Z-order when using scattergl

Hi,

I’m building an application where I use plotly.js to visualize a lot of data points, up to 10k. So, for performance reasons I’m using scattergl type plots. The application has a feature that performs linear fitting on data selected by the user using the box-select or lasso-select tools. The resulting trend line is then plotted on top of the data.

Now the problem is this: When a user selects, and then de-selects points (by double-click) after the trend has been plotted, the Z-order of the traces is somehow changed. This causes the trend line to appear behind the data resulting in poor visibility. The problem does not occur when using type: ‘scatter’ instead of ‘scattergl’.

The behaviour can be reproduced with the steps below and the following codepen:
https://codepen.io/Convo/pen/GLZYdw

  1. Notice that the trend-line is plotted on top of the data
  2. Use the box-select tool to select a few points
  3. Double-click anywhere on the plot to clear the selection
  4. Notice that the trend line is now plotted below the data.

Is there a way or workaround to make sure that the trend line is always plotted on top of the data? Is this behavior intended, or should I file a bug report?

Thanks for reporting.

Would you mind opening an issue https://github.com/plotly/plotly.js/issues/new in our bug tracker?

Thanks again!

Thanks for the reply.

I opened a new issue:

1 Like