diff --git a/packages/superset-ui-legacy-preset-chart-nvd3/src/NVD3Vis.css b/packages/superset-ui-legacy-preset-chart-nvd3/src/NVD3Vis.css index a7ab3e6bf..35612b25b 100644 --- a/packages/superset-ui-legacy-preset-chart-nvd3/src/NVD3Vis.css +++ b/packages/superset-ui-legacy-preset-chart-nvd3/src/NVD3Vis.css @@ -112,3 +112,12 @@ .superset-legacy-chart-nvd3 g.time-shift-9 path, .superset-legacy-chart-nvd3 line.time-shift-9 { stroke-dasharray: 5, 5, 1, 5; } +.superset-legacy-chart-nvd3-tr-highlight { + border-top: 1px solid; + border-bottom: 1px solid; + font-weight: bold; +} + +.superset-legacy-chart-nvd3-tr-total { + font-weight: bold; +} diff --git a/packages/superset-ui-legacy-preset-chart-nvd3/src/NVD3Vis.js b/packages/superset-ui-legacy-preset-chart-nvd3/src/NVD3Vis.js index 51c9ec6ca..82edafadc 100644 --- a/packages/superset-ui-legacy-preset-chart-nvd3/src/NVD3Vis.js +++ b/packages/superset-ui-legacy-preset-chart-nvd3/src/NVD3Vis.js @@ -41,6 +41,7 @@ import { generateMultiLineTooltipContent, generateRichLineTooltipContent, generateTimePivotTooltip, + generateAreaChartTooltipContent, getMaxLabelSize, getTimeOrNumberFormatter, hideTooltips, @@ -558,6 +559,11 @@ function nvd3Vis(element, props) { chart.interactiveLayer.tooltip.contentGenerator(d => generateRichLineTooltipContent(d, smartDateVerboseFormatter, yAxisFormatter), ); + } else { + // area chart + chart.interactiveLayer.tooltip.contentGenerator(d => + generateAreaChartTooltipContent(d, smartDateVerboseFormatter, yAxisFormatter), + ); } } diff --git a/packages/superset-ui-legacy-preset-chart-nvd3/src/utils.js b/packages/superset-ui-legacy-preset-chart-nvd3/src/utils.js index f40568fdf..a20f4d967 100644 --- a/packages/superset-ui-legacy-preset-chart-nvd3/src/utils.js +++ b/packages/superset-ui-legacy-preset-chart-nvd3/src/utils.js @@ -133,7 +133,36 @@ export function generateRichLineTooltipContent(d, timeFormatter, valueFormatter) }); tooltip += ''; - return tooltip; + return dompurify.sanitize(tooltip); +} + +export function generateAreaChartTooltipContent(d, timeFormatter, valueFormatter) { + const total = d.series[d.series.length - 1].value; + let tooltip = ''; + tooltip += + "
" + + `${timeFormatter(d.value)}` + + ' | |||
Category | Value | % to total | |
${series.key === 'TOTAL' ? '' : '◼'} | ` + + `${key} | ` + + `${valueFormatter(series.value)} | ` + + `${((100 * series.value) / total).toFixed(2)}% | ` + + '