From 9884887946390702807f054aaacba418da0714da Mon Sep 17 00:00:00 2001 From: Kim Truong <47833996+khtruong@users.noreply.github.com> Date: Mon, 1 Apr 2019 13:56:43 -0700 Subject: [PATCH] fix: exception thrown for charts without a x-axis (#36) * fix: pie chart exception * fix: incoporate krist's feedbacl --- .../src/NVD3Vis.js | 20 ++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/superset-frontend/temporary_superset_ui/superset-ui/plugins/superset-ui-plugins/packages/superset-ui-legacy-preset-chart-nvd3/src/NVD3Vis.js b/superset-frontend/temporary_superset_ui/superset-ui/plugins/superset-ui-plugins/packages/superset-ui-legacy-preset-chart-nvd3/src/NVD3Vis.js index c9b1359adc759..51c9ec6ca6289 100644 --- a/superset-frontend/temporary_superset_ui/superset-ui/plugins/superset-ui-plugins/packages/superset-ui-legacy-preset-chart-nvd3/src/NVD3Vis.js +++ b/superset-frontend/temporary_superset_ui/superset-ui/plugins/superset-ui-plugins/packages/superset-ui-legacy-preset-chart-nvd3/src/NVD3Vis.js @@ -495,15 +495,17 @@ function nvd3Vis(element, props) { if (chart.x2Axis && chart.x2Axis.tickFormat) { chart.x2Axis.tickFormat(xAxisFormatter); } - const isXAxisString = isVizTypes(['dist_bar', 'box_plot']); - if (!isXAxisString && chart.xAxis && chart.xAxis.tickFormat) { - chart.xAxis.tickFormat(xAxisFormatter); - } else { - chart.xAxis.tickFormat(d => - d.length > MAX_NO_CHARACTERS_IN_LABEL - ? `${d.substring(0, MAX_NO_CHARACTERS_IN_LABEL)}…` - : d, - ); + if (chart.xAxis && chart.xAxis.tickFormat) { + const isXAxisString = isVizTypes(['dist_bar', 'box_plot']); + if (isXAxisString) { + chart.xAxis.tickFormat(d => + d.length > MAX_NO_CHARACTERS_IN_LABEL + ? `${d.substring(0, MAX_NO_CHARACTERS_IN_LABEL)}…` + : d, + ); + } else { + chart.xAxis.tickFormat(xAxisFormatter); + } } let yAxisFormatter = getTimeOrNumberFormatter(yAxisFormat);