Skip to content

Selection changes Z-order when using scattergl #3740

Closed
@Rob-DL

Description

@Rob-DL

Backstory
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.

The problem
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’.

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

  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.

As you can see the Z-order has been swapped after using the selection tool. This is undesired behavirou.

Related forum post:
https://community.plot.ly/t/selection-changes-z-order-when-using-scattergl/21924

Metadata

Metadata

Assignees

Labels

bugsomething broken

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions