mirror of
https://github.com/apache/superset.git
synced 2026-04-18 23:55:00 +00:00
feat: show total in waterfall chart (#35876)
This commit is contained in:
@@ -129,6 +129,18 @@ const config: ControlPanelConfig = {
|
||||
{t('Series total setting')}
|
||||
</ControlSubSectionHeader>,
|
||||
],
|
||||
[
|
||||
{
|
||||
name: 'show_total',
|
||||
config: {
|
||||
type: 'CheckboxControl',
|
||||
label: t('Show total'),
|
||||
renderTrigger: true,
|
||||
default: true,
|
||||
description: t('Display cumulative total at end'),
|
||||
},
|
||||
},
|
||||
],
|
||||
[
|
||||
{
|
||||
name: 'total_color',
|
||||
|
||||
@@ -94,12 +94,14 @@ function transformer({
|
||||
metric,
|
||||
breakdown,
|
||||
totalMark,
|
||||
showTotal,
|
||||
}: {
|
||||
data: DataRecord[];
|
||||
xAxis: string;
|
||||
metric: string;
|
||||
breakdown?: string;
|
||||
totalMark: string;
|
||||
showTotal: boolean;
|
||||
}) {
|
||||
// Group by series (temporary map)
|
||||
const groupedData = data.reduce((acc, cur) => {
|
||||
@@ -121,11 +123,13 @@ function transformer({
|
||||
0,
|
||||
);
|
||||
// Push total per period to the end of period values array
|
||||
tempValue.push({
|
||||
[xAxis]: key,
|
||||
[breakdown]: totalMark,
|
||||
[metric]: sum,
|
||||
});
|
||||
if (showTotal) {
|
||||
tempValue.push({
|
||||
[xAxis]: key,
|
||||
[breakdown]: totalMark,
|
||||
[metric]: sum,
|
||||
});
|
||||
}
|
||||
transformedData.push(...tempValue);
|
||||
});
|
||||
} else {
|
||||
@@ -141,10 +145,12 @@ function transformer({
|
||||
});
|
||||
total += sum;
|
||||
});
|
||||
transformedData.push({
|
||||
[xAxis]: totalMark,
|
||||
[metric]: total,
|
||||
});
|
||||
if (showTotal) {
|
||||
transformedData.push({
|
||||
[xAxis]: totalMark,
|
||||
[metric]: total,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
return transformedData;
|
||||
@@ -183,6 +189,7 @@ export default function transformProps(
|
||||
xAxisLabel,
|
||||
yAxisFormat,
|
||||
showValue,
|
||||
showTotal,
|
||||
totalLabel,
|
||||
increaseLabel,
|
||||
decreaseLabel,
|
||||
@@ -220,6 +227,7 @@ export default function transformProps(
|
||||
xAxis: xAxisName,
|
||||
metric: metricLabel,
|
||||
totalMark,
|
||||
showTotal,
|
||||
});
|
||||
|
||||
const assistData: ISeriesData[] = [];
|
||||
|
||||
@@ -60,6 +60,7 @@ export type EchartsWaterfallFormData = QueryFormData &
|
||||
increaseLabel?: string;
|
||||
decreaseLabel?: string;
|
||||
totalLabel?: string;
|
||||
showTotal: boolean;
|
||||
};
|
||||
|
||||
export const DEFAULT_FORM_DATA: Partial<EchartsWaterfallFormData> = {
|
||||
|
||||
Reference in New Issue
Block a user