feat(bar_chart): Stacked Bar chart with Time comparison in separated stacks (#27589)

This commit is contained in:
Antonio Rivero
2024-03-22 08:24:38 +01:00
committed by GitHub
parent ec6bfcbaa0
commit 8a715cc1b5
4 changed files with 74 additions and 4 deletions

View File

@@ -40,6 +40,7 @@ import {
sanitizeHtml,
sortAndFilterSeries,
sortRows,
getTimeCompareStackId,
} from '../../src/utils/series';
import {
EchartsTimeseriesSeriesType,
@@ -1041,3 +1042,33 @@ test('getMinAndMaxFromBounds returns automatic lower bound when truncating', ()
scale: true,
});
});
describe('getTimeCompareStackId', () => {
it('returns the defaultId when timeCompare is empty', () => {
const result = getTimeCompareStackId('default', []);
expect(result).toEqual('default');
});
it('returns the defaultId when no value in timeCompare is included in name', () => {
const result = getTimeCompareStackId(
'default',
['compare1', 'compare2'],
'test__name',
);
expect(result).toEqual('default');
});
it('returns the first value in timeCompare that is included in name', () => {
const result = getTimeCompareStackId(
'default',
['compare1', 'compare2'],
'test__compare1',
);
expect(result).toEqual('compare1');
});
it('handles name being a number', () => {
const result = getTimeCompareStackId('default', ['123', '456'], 123);
expect(result).toEqual('123');
});
});