8000 Fix bug where axes (but not curves) are deleted when Plotly.deleteTra… · TaurusTiger/plotly.js@5be79ca · GitHub
[go: up one dir, main page]

Skip to content

Commit 5be79ca

Browse files
committed
Fix bug where axes (but not curves) are deleted when Plotly.deleteTraces is
called
1 parent af28316 commit 5be79ca

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

src/plot_api/plot_api.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1498,8 +1498,13 @@ Plotly.deleteTraces = function deleteTraces (gd, indices) {
14981498
// we want descending here so that splicing later doesn't affect indexing
14991499
indices.sort().reverse();
15001500
for (i = 0; i < indices.length; i += 1) {
1501-
deletedTrace = gd.data.splice(indices[i], 1)[0];
1502-
traces.push(deletedTrace);
1501+
if (gd.data.length > 1){
1502+
deletedTrace = gd.data.splice(indices[i], 1)[0];
1503+
traces.push(deletedTrace);
1504+
}else {
1505+
traces.push(gd.data[0]);
1506+
gd.data = [{ type: gd._fullData.type }];
1507+
}
15031508
}
15041509

15051510
Plotly.redraw(gd);

0 commit comments

Comments
 (0)
0