fix(plugin-chart-echarts): [feature-parity] apply button of annotation layer doesn't work as expected (#19761)

* fix(plugin-chart-echarts): [feature-parity] apply button of annotation layer does't work

* fix: lint

* fix: test
This commit is contained in:
Stephen Liu 2022-06-08 17:06:24 +08:00 committed by GitHub
parent 8e46ae5c6a
commit 9f02ff656d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 48 additions and 65 deletions

View File

@ -24,6 +24,7 @@ export const annotationLayers = [];
export const annotationsAndLayersControls: ControlPanelSectionConfig = { export const annotationsAndLayersControls: ControlPanelSectionConfig = {
label: t('Annotations and Layers'), label: t('Annotations and Layers'),
expanded: false, expanded: false,
tabOverride: 'data',
controlSetRows: [ controlSetRows: [
[ [
{ {
@ -33,6 +34,7 @@ export const annotationsAndLayersControls: ControlPanelSectionConfig = {
label: '', label: '',
default: annotationLayers, default: annotationLayers,
description: t('Annotation Layers'), description: t('Annotation Layers'),
renderTrigger: true,
}, },
}, },
], ],

View File

@ -35,7 +35,6 @@ import { legendSection, richTooltipSection, xAxisControl } from '../controls';
const { const {
area, area,
annotationLayers,
logAxis, logAxis,
markerEnabled, markerEnabled,
markerSize, markerSize,
@ -289,23 +288,7 @@ const config: ControlPanelConfig = {
createAdvancedAnalyticsSection(t('Advanced analytics Query A'), ''), createAdvancedAnalyticsSection(t('Advanced analytics Query A'), ''),
createQuerySection(t('Query B'), '_b'), createQuerySection(t('Query B'), '_b'),
createAdvancedAnalyticsSection(t('Advanced analytics Query B'), '_b'), createAdvancedAnalyticsSection(t('Advanced analytics Query B'), '_b'),
{ sections.annotationsAndLayersControls,
label: t('Annotations and Layers'),
expanded: false,
controlSetRows: [
[
{
name: 'annotation_layers',
config: {
type: 'AnnotationLayerControl',
label: '',
default: annotationLayers,
description: t('Annotation Layers'),
},
},
],
],
},
sections.titleControls, sections.titleControls,
{ {
label: t('Chart Options'), label: t('Chart Options'),

View File

@ -81,9 +81,8 @@ export default function transformProps(
filterState, filterState,
datasource, datasource,
theme, theme,
annotationData = {},
} = chartProps; } = chartProps;
const { annotation_data: annotationData_ } = queriesData[0];
const annotationData = annotationData_ || {};
const { verboseMap = {} } = datasource; const { verboseMap = {} } = datasource;
const data1 = (queriesData[0].data || []) as TimeseriesDataRecord[]; const data1 = (queriesData[0].data || []) as TimeseriesDataRecord[];
const data2 = (queriesData[1].data || []) as TimeseriesDataRecord[]; const data2 = (queriesData[1].data || []) as TimeseriesDataRecord[];

View File

@ -86,13 +86,12 @@ export default function transformProps(
queriesData, queriesData,
datasource, datasource,
theme, theme,
annotationData = {},
} = chartProps; } = chartProps;
const { verboseMap = {} } = datasource; const { verboseMap = {} } = datasource;
const [queryData] = queriesData; const [queryData] = queriesData;
const { annotation_data: annotationData_, data = [] } = const { data = [] } = queryData as TimeseriesChartDataResponseResult;
queryData as TimeseriesChartDataResponseResult;
const dataTypes = getColtypesMapping(queryData); const dataTypes = getColtypesMapping(queryData);
const annotationData = annotationData_ || {};
const { const {
area, area,

View File

@ -180,10 +180,7 @@ describe('EchartsTimeseries transformProps', () => {
...formData, ...formData,
annotationLayers: [event, interval, timeseries], annotationLayers: [event, interval, timeseries],
}, },
queriesData: [ annotationData: {
{
...queriesData[0],
annotation_data: {
'My Event': { 'My Event': {
columns: [ columns: [
'start_dttm', 'start_dttm',
@ -228,6 +225,9 @@ describe('EchartsTimeseries transformProps', () => {
}, },
], ],
}, },
queriesData: [
{
...queriesData[0],
}, },
], ],
}); });