mirror of
https://github.com/apache/superset.git
synced 2026-04-18 23:55:00 +00:00
fix(line-chart): Formula Annotations on Line Charts are broken (#20687)
This commit is contained in:
@@ -25,6 +25,7 @@ import {
|
||||
AnnotationType,
|
||||
FormulaAnnotationLayer,
|
||||
TimeseriesDataRecord,
|
||||
DataRecord,
|
||||
} from '@superset-ui/core';
|
||||
import {
|
||||
evalFormula,
|
||||
@@ -160,7 +161,7 @@ describe('evalFormula', () => {
|
||||
{ __timestamp: 10 },
|
||||
];
|
||||
|
||||
expect(evalFormula(layer, data)).toEqual([
|
||||
expect(evalFormula(layer, data, '__timestamp', 'time')).toEqual([
|
||||
[0, 1],
|
||||
[10, 11],
|
||||
]);
|
||||
@@ -172,9 +173,27 @@ describe('evalFormula', () => {
|
||||
{ __timestamp: 10 },
|
||||
];
|
||||
|
||||
expect(evalFormula({ ...layer, value: 'y = x* 2 -1' }, data)).toEqual([
|
||||
expect(
|
||||
evalFormula(
|
||||
{ ...layer, value: 'y = x* 2 -1' },
|
||||
data,
|
||||
'__timestamp',
|
||||
'time',
|
||||
),
|
||||
).toEqual([
|
||||
[0, -1],
|
||||
[10, 19],
|
||||
]);
|
||||
});
|
||||
|
||||
it('Should evaluate a formula if axis type is category', () => {
|
||||
const data: DataRecord[] = [{ gender: 'boy' }, { gender: 'girl' }];
|
||||
|
||||
expect(
|
||||
evalFormula({ ...layer, value: 'y = 1000' }, data, 'gender', 'category'),
|
||||
).toEqual([
|
||||
['boy', 1000],
|
||||
['girl', 1000],
|
||||
]);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user