From 96a73b0c9e18444f95f1b8f92185978e8ddc7536 Mon Sep 17 00:00:00 2001 From: Levko Kravets Date: Tue, 5 Dec 2017 15:37:32 +0200 Subject: [PATCH] getredash/redash#2107 Fix: chart x-axis height setting --- client/app/visualizations/chart/plotly.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/client/app/visualizations/chart/plotly.js b/client/app/visualizations/chart/plotly.js index b33aff09..9ce0b0c8 100644 --- a/client/app/visualizations/chart/plotly.js +++ b/client/app/visualizations/chart/plotly.js @@ -13,6 +13,8 @@ Plotly.setPlotConfig({ modeBarButtonsToRemove: ['sendDataToCloud'], }); +const DEFAULT_BOTTOM_MARGIN = 50; + // The following colors will be used if you pick "Automatic" color. const BaseColors = { Blue: '#4572A7', @@ -225,6 +227,8 @@ const PlotlyChart = () => ({ function recalculateOptions() { + scope.layout.margin.b = parseInt(scope.options.bottomMargin, 10) || DEFAULT_BOTTOM_MARGIN; + scope.data.length = 0; scope.layout.showlegend = has(scope.options, 'legend') ? scope.options.legend.enabled : true; delete scope.layout.barmode; @@ -443,7 +447,7 @@ const PlotlyChart = () => ({ scope.layout = { margin: { - l: 50, r: 50, b: 50, t: 20, pad: 4, + l: 50, r: 50, b: DEFAULT_BOTTOM_MARGIN, t: 20, pad: 4, }, width: container.offsetWidth, height: container.offsetHeight,