Skip to content

Plotly.deleteTraces leads to bad trace uid sequence #2836

Closed
@etpinard

Description

@etpinard

Consider

Plotly.newPlot('graph', [{
  y: [1, 2, 1]
}, {
  y: [2, 1, 2]
}, {
  y: [3, 2, 3]
}])
.then(gd => {
  console.log(gd._fullData.map(t => t.uid))
  // => ['0', '1', '2']
  return gd
})
.then(gd => {
  return Plotly.deleteTraces(gd, [0])
})
.then(gd => {
  console.log(gd._fullData.map(t => t.uid))
  // (currently) => ['0', '1']
  // (in 1.38.x) => ['1', '2']
})

In a codepen: https://codepen.io/etpinard/pen/KBmVYB?editors=1010

This is probably due to #2681 and probably leads to bugs (not yet reported) when deleting traces in subplots that track traces using uids e.g. gl3d:

for(i = 0; i < sceneData.length; ++i) {
data = sceneData[i];
if(data.visible !== true) {
continue;
}
trace = this.traces[data.uid];
if(trace) {
if(trace.data.type === data.type) {
trace.update(data);
} else {
trace.dispose();
trace = data._module.plot(this, data);
this.traces[data.uid] = trace;
}
} else {
trace = data._module.plot(this, data);
this.traces[data.uid] = trace;
}
trace.name = data.name;
}

cc @alexcjohnson

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugsomething brokenregressionthis used to work

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions