fix: annotation broken (#20651)

* fix: annotation broken

* fix UT

* add annotation data to mixed timeseries chart
This commit is contained in:
Yongjie Zhao
2022-07-12 06:23:57 +08:00
committed by GitHub
parent 6ee9be203a
commit 7f918a4ec0
7 changed files with 75 additions and 53 deletions

View File

@@ -17,6 +17,8 @@
* specific language governing permissions and limitations
* under the License.
*/
import { isEmpty } from 'lodash';
import {
Annotation,
AnnotationData,
@@ -30,6 +32,8 @@ import {
isTimeseriesAnnotationResult,
TimeseriesDataRecord,
} from '@superset-ui/core';
import { EchartsTimeseriesChartProps } from '../types';
import { EchartsMixedTimeseriesProps } from '../MixedTimeseries/types';
export function evalFormula(
formula: FormulaAnnotationLayer,
@@ -130,3 +134,13 @@ export function extractAnnotationLabels(
return formulaAnnotationLabels.concat(timeseriesAnnotationLabels);
}
export function getAnnotationData(
chartProps: EchartsTimeseriesChartProps | EchartsMixedTimeseriesProps,
): AnnotationData {
const data = chartProps?.queriesData[0]?.annotation_data as AnnotationData;
if (!isEmpty(data)) {
return data;
}
return {};
}