fix: Tooltip of area chart shows undefined total (#24916)

This commit is contained in:
Michael S. Molina 2023-08-08 18:13:21 -03:00 committed by GitHub
parent 81bf2f01e2
commit ec9e9a46f2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 4 additions and 5 deletions

View File

@ -191,19 +191,18 @@ export function generateAreaChartTooltipContent(
'<tr class="tooltip-header"><td></td><td>Category</td><td>Value</td><td>% to total</td></tr>';
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 +=
`<tr class="${trClass}" style="border-color: ${series.color}">` +
`<td style="color: ${series.color}">${
series.key === 'TOTAL' ? '' : '&#9724;'
}</td>` +
`<td style="color: ${series.color}">${isTotal ? '' : '&#9724;'}</td>` +
`<td>${key}</td>` +
`<td>${valueFormatter(series?.point?.y)}</td>` +
`<td>${valueFormatter(isTotal ? total : series?.point?.y)}</td>` +
`<td>${((100 * series.value) / total).toFixed(2)}%</td>` +
'</tr>';
});