Skip to content

Commit

Permalink
fix(plugin-chart-echarts): [feature-parity] apply button of annotatio…
Browse files Browse the repository at this point in the history
…n 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
  • Loading branch information
stephenLYZ committed Jun 8, 2022
1 parent 8e46ae5 commit 9f02ff6
Show file tree
Hide file tree
Showing 5 changed files with 48 additions and 65 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ export const annotationLayers = [];
export const annotationsAndLayersControls: ControlPanelSectionConfig = {
label: t('Annotations and Layers'),
expanded: false,
tabOverride: 'data',
controlSetRows: [
[
{
Expand All @@ -33,6 +34,7 @@ export const annotationsAndLayersControls: ControlPanelSectionConfig = {
label: '',
default: annotationLayers,
description: t('Annotation Layers'),
renderTrigger: true,
},
},
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ import { legendSection, richTooltipSection, xAxisControl } from '../controls';

const {
area,
annotationLayers,
logAxis,
markerEnabled,
markerSize,
Expand Down Expand Up @@ -289,23 +288,7 @@ const config: ControlPanelConfig = {
createAdvancedAnalyticsSection(t('Advanced analytics Query A'), ''),
createQuerySection(t('Query B'), '_b'),
createAdvancedAnalyticsSection(t('Advanced analytics Query B'), '_b'),
{
label: t('Annotations and Layers'),
expanded: false,
controlSetRows: [
[
{
name: 'annotation_layers',
config: {
type: 'AnnotationLayerControl',
label: '',
default: annotationLayers,
description: t('Annotation Layers'),
},
},
],
],
},
sections.annotationsAndLayersControls,
sections.titleControls,
{
label: t('Chart Options'),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,9 +81,8 @@ export default function transformProps(
filterState,
datasource,
theme,
annotationData = {},
} = chartProps;
const { annotation_data: annotationData_ } = queriesData[0];
const annotationData = annotationData_ || {};
const { verboseMap = {} } = datasource;
const data1 = (queriesData[0].data || []) as TimeseriesDataRecord[];
const data2 = (queriesData[1].data || []) as TimeseriesDataRecord[];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,13 +86,12 @@ export default function transformProps(
queriesData,
datasource,
theme,
annotationData = {},
} = chartProps;
const { verboseMap = {} } = datasource;
const [queryData] = queriesData;
const { annotation_data: annotationData_, data = [] } =
queryData as TimeseriesChartDataResponseResult;
const { data = [] } = queryData as TimeseriesChartDataResponseResult;
const dataTypes = getColtypesMapping(queryData);
const annotationData = annotationData_ || {};

const {
area,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -180,54 +180,54 @@ describe('EchartsTimeseries transformProps', () => {
...formData,
annotationLayers: [event, interval, timeseries],
},
queriesData: [
{
...queriesData[0],
annotation_data: {
'My Event': {
columns: [
'start_dttm',
'end_dttm',
'short_descr',
'long_descr',
'json_metadata',
],
records: [
{
start_dttm: 0,
end_dttm: 1000,
short_descr: '',
long_descr: '',
json_metadata: null,
},
],
annotationData: {
'My Event': {
columns: [
'start_dttm',
'end_dttm',
'short_descr',
'long_descr',
'json_metadata',
],
records: [
{
start_dttm: 0,
end_dttm: 1000,
short_descr: '',
long_descr: '',
json_metadata: null,
},
'My Interval': {
columns: ['start', 'end', 'title'],
records: [
{
start: 2000,
end: 3000,
title: 'My Title',
},
],
],
},
'My Interval': {
columns: ['start', 'end', 'title'],
records: [
{
start: 2000,
end: 3000,
title: 'My Title',
},
'My Timeseries': [
],
},
'My Timeseries': [
{
key: 'My Line',
values: [
{
x: 10000,
y: 11000,
},
{
key: 'My Line',
values: [
{
x: 10000,
y: 11000,
},
{
x: 20000,
y: 21000,
},
],
x: 20000,
y: 21000,
},
],
},
],
},
queriesData: [
{
...queriesData[0],
},
],
});
Expand Down

0 comments on commit 9f02ff6

Please sign in to comment.