From e5467462cb73630a9b487891845ab1f01245f2a8 Mon Sep 17 00:00:00 2001 From: the-dcruz Date: Fri, 18 Nov 2016 09:43:36 -0800 Subject: [PATCH] Make nvd3 refresh smoother. (#1618) --- superset/assets/javascripts/explore/explore.jsx | 1 + superset/assets/javascripts/modules/superset.js | 3 +++ superset/assets/visualizations/nvd3_vis.js | 3 ++- 3 files changed, 6 insertions(+), 1 deletion(-) diff --git a/superset/assets/javascripts/explore/explore.jsx b/superset/assets/javascripts/explore/explore.jsx index 00ac222167db6..b539ffcb82625 100644 --- a/superset/assets/javascripts/explore/explore.jsx +++ b/superset/assets/javascripts/explore/explore.jsx @@ -73,6 +73,7 @@ function query(forceUpdate, pushState) { // update the url after prepForm() fix the field ids history.pushState({}, document.title, slice.querystring()); } + slice.container.html(''); slice.render(force); } diff --git a/superset/assets/javascripts/modules/superset.js b/superset/assets/javascripts/modules/superset.js index 6d76a1d3f3841..0eb5da6f4b9e4 100644 --- a/superset/assets/javascripts/modules/superset.js +++ b/superset/assets/javascripts/modules/superset.js @@ -177,6 +177,9 @@ const px = function () { always(data); controller.error(this); }, + clearError() { + $(selector + ' div.alert').remove(); + }, width() { return token.width(); }, diff --git a/superset/assets/visualizations/nvd3_vis.js b/superset/assets/visualizations/nvd3_vis.js index e055b500babd8..c6339236bd6ba 100644 --- a/superset/assets/visualizations/nvd3_vis.js +++ b/superset/assets/visualizations/nvd3_vis.js @@ -60,13 +60,14 @@ function nvd3Vis(slice) { const render = function () { d3.json(slice.jsonEndpoint(), function (error, payload) { - slice.container.html(''); // Check error first, otherwise payload can be null if (error) { slice.error(error.responseText, error); return; } + slice.clearError(); + // Calculates the longest label size for stretching bottom margin function calculateStretchMargins(payloadData) { let stretchMargin = 0;