feat(waterfall): add changes label series and grouping customize settings (#34847)

This commit is contained in:
SBIN2010
2025-09-17 14:24:45 +03:00
committed by GitHub
parent dced2f8564
commit 3e554674ff
5 changed files with 175 additions and 35 deletions

View File

@@ -31,6 +31,14 @@ const extractSeries = (props: WaterfallChartTransformedProps) => {
return series.map(item => item.data).map(item => item.map(i => i.value));
};
const extractSeriesName = (props: WaterfallChartTransformedProps) => {
const { echartOptions } = props;
const { series } = echartOptions as unknown as {
series: [{ name: string }];
};
return series.map(item => item.name);
};
describe('Waterfall tranformProps', () => {
const data = [
{ year: '2019', name: 'Sylvester', sum: 10 },
@@ -94,4 +102,44 @@ describe('Waterfall tranformProps', () => {
['-', '-', 13, '-', '-', 8],
]);
});
it('renaming series names, checking legend and X axis labels', () => {
const chartProps = new ChartProps({
formData: {
...formData,
increaseLabel: 'sale increase',
decreaseLabel: 'sale decrease',
totalLabel: 'sale total',
},
width: 800,
height: 600,
queriesData: [
{
data,
},
],
theme: supersetTheme,
});
const transformedProps = transformProps(
chartProps as unknown as EchartsWaterfallChartProps,
);
expect((transformedProps.echartOptions.legend as any).data).toEqual([
'sale increase',
'sale decrease',
'sale total',
]);
expect((transformedProps.echartOptions.xAxis as any).data).toEqual([
'2019',
'2020',
'sale total',
]);
expect(extractSeriesName(transformedProps)).toEqual([
'Assist',
'sale increase',
'sale decrease',
'sale total',
]);
});
});