`,
- `
- ${(node.name || NULL_STRING)
- .toString()
- .replaceAll('<', '<')
- .replaceAll('>', '>')}
-
`,
- `
- ${absolutePercentage} of total
-
`,
- ];
+ const title = (node.name || NULL_STRING)
+ .toString()
+ .replaceAll('<', '<')
+ .replaceAll('>', '>');
+ const rows = [[t('% of total'), absolutePercentage]];
if (parentNode) {
const conditionalPercentage = percentFormatter(
node.value / parentNode.value,
);
- result.push(`
-
- ${conditionalPercentage} of ${parentNode.name}
-
`);
+ rows.push([t('% of parent'), conditionalPercentage]);
}
- result.push(
- `
- ${metricLabel}: ${formattedValue}${
- colorByCategory
- ? ''
- : `, ${secondaryMetricLabel}: ${formattedSecondaryValue}`
- }
-
`,
- colorByCategory
- ? ''
- : `
${metricLabel}/${secondaryMetricLabel}: ${compareValuePercentage}
`,
- );
- result.push('
');
- return result.join('\n');
+ rows.push([metricLabel, formattedValue]);
+ if (!colorByCategory) {
+ rows.push([
+ secondaryMetricLabel || NULL_STRING,
+ formattedSecondaryValue || NULL_STRING,
+ ]);
+ rows.push([
+ `${metricLabel}/${secondaryMetricLabel}`,
+ compareValuePercentage,
+ ]);
+ }
+ return tooltipHtml(rows, title);
}
export default function transformProps(
@@ -353,7 +336,6 @@ export default function transformProps(
totalValue,
metricLabel,
secondaryMetricLabel,
- theme,
}),
},
series: [
diff --git a/superset-frontend/plugins/plugin-chart-echarts/src/Timeseries/transformProps.ts b/superset-frontend/plugins/plugin-chart-echarts/src/Timeseries/transformProps.ts
index 4ec49767e2697..d3e7673ea738d 100644
--- a/superset-frontend/plugins/plugin-chart-echarts/src/Timeseries/transformProps.ts
+++ b/superset-frontend/plugins/plugin-chart-echarts/src/Timeseries/transformProps.ts
@@ -25,6 +25,7 @@ import {
CategoricalColorNamespace,
CurrencyFormatter,
ensureIsArray,
+ tooltipHtml,
GenericDataType,
getCustomFormatter,
getMetricLabel,
@@ -38,6 +39,7 @@ import {
isTimeseriesAnnotationLayer,
t,
TimeseriesChartDataResponseResult,
+ NumberFormats,
} from '@superset-ui/core';
import {
extractExtraMetrics,
@@ -254,7 +256,9 @@ export default function transformProps(
const series: SeriesOption[] = [];
const forcePercentFormatter = Boolean(contributionMode || isAreaExpand);
- const percentFormatter = getPercentFormatter(yAxisFormat);
+ const percentFormatter = forcePercentFormatter
+ ? getPercentFormatter(yAxisFormat)
+ : getPercentFormatter(NumberFormats.PERCENT_2_POINT);
const defaultFormatter = currencyFormat?.symbol
? new CurrencyFormatter({ d3Format: yAxisFormat, currency: currencyFormat })
: getNumberFormatter(yAxisFormat);
@@ -526,36 +530,58 @@ export default function transformProps(
forecastValue.sort((a, b) => b.data[yIndex] - a.data[yIndex]);
}
- const rows: string[] = [];
const forecastValues: Record