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,54 +180,54 @@ describe('EchartsTimeseries transformProps', () => {
...formData, ...formData,
annotationLayers: [event, interval, timeseries], annotationLayers: [event, interval, timeseries],
}, },
queriesData: [ annotationData: {
{ 'My Event': {
...queriesData[0], columns: [
annotation_data: { 'start_dttm',
'My Event': { 'end_dttm',
columns: [ 'short_descr',
'start_dttm', 'long_descr',
'end_dttm', 'json_metadata',
'short_descr', ],
'long_descr', records: [
'json_metadata', {
], start_dttm: 0,
records: [ end_dttm: 1000,
{ short_descr: '',
start_dttm: 0, long_descr: '',
end_dttm: 1000, json_metadata: null,
short_descr: '',
long_descr: '',
json_metadata: null,
},
],
}, },
'My Interval': { ],
columns: ['start', 'end', 'title'], },
records: [ 'My Interval': {
{ columns: ['start', 'end', 'title'],
start: 2000, records: [
end: 3000, {
title: 'My Title', start: 2000,
}, end: 3000,
], title: 'My Title',
}, },
'My Timeseries': [ ],
},
'My Timeseries': [
{
key: 'My Line',
values: [
{ {
key: 'My Line', x: 10000,
values: [ y: 11000,
{ },
x: 10000, {
y: 11000, x: 20000,
}, y: 21000,
{
x: 20000,
y: 21000,
},
],
}, },
], ],
}, },
],
},
queriesData: [
{
...queriesData[0],
}, },
], ],
}); });