From ec9e9a46f2f092ce56d3ed5a8a9a3ea0214db88a Mon Sep 17 00:00:00 2001 From: "Michael S. Molina" <70410625+michael-s-molina@users.noreply.github.com> Date: Tue, 8 Aug 2023 18:13:21 -0300 Subject: [PATCH] fix: Tooltip of area chart shows undefined total (#24916) --- .../plugins/legacy-preset-chart-nvd3/src/utils.js | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/superset-frontend/plugins/legacy-preset-chart-nvd3/src/utils.js b/superset-frontend/plugins/legacy-preset-chart-nvd3/src/utils.js index 39b42525af..c3ef5a972e 100644 --- a/superset-frontend/plugins/legacy-preset-chart-nvd3/src/utils.js +++ b/superset-frontend/plugins/legacy-preset-chart-nvd3/src/utils.js @@ -191,19 +191,18 @@ export function generateAreaChartTooltipContent( 'CategoryValue% to total'; d.series.forEach(series => { const key = getFormattedKey(series.key, true); + const isTotal = series.key === 'TOTAL'; let trClass = ''; if (series.highlight) { trClass = 'superset-legacy-chart-nvd3-tr-highlight'; - } else if (series.key === 'TOTAL') { + } else if (isTotal) { trClass = 'superset-legacy-chart-nvd3-tr-total'; } tooltip += `` + - `${ - series.key === 'TOTAL' ? '' : '◼' - }` + + `${isTotal ? '' : '◼'}` + `${key}` + - `${valueFormatter(series?.point?.y)}` + + `${valueFormatter(isTotal ? total : series?.point?.y)}` + `${((100 * series.value) / total).toFixed(2)}%` + ''; });