From 5be79caa7a64f0fa8231a1a38f2ef99f2d8bf949 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mikl=C3=B3s=20Tusz?= Date: Thu, 3 Dec 2015 17:43:28 -0500 Subject: [PATCH] Fix bug where axes (but not curves) are deleted when Plotly.deleteTraces is called --- src/plot_api/plot_api.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/plot_api/plot_api.js b/src/plot_api/plot_api.js index 4c24b172103..735a3608b7d 100644 --- a/src/plot_api/plot_api.js +++ b/src/plot_api/plot_api.js @@ -1498,8 +1498,13 @@ Plotly.deleteTraces = function deleteTraces (gd, indices) { // we want descending here so that splicing later doesn't affect indexing indices.sort().reverse(); for (i = 0; i < indices.length; i += 1) { - deletedTrace = gd.data.splice(indices[i], 1)[0]; - traces.push(deletedTrace); + if (gd.data.length > 1){ + deletedTrace = gd.data.splice(indices[i], 1)[0]; + traces.push(deletedTrace); + }else { + traces.push(gd.data[0]); + gd.data = [{ type: gd._fullData.type }]; + } } Plotly.redraw(gd);