mirror of
https://github.com/apache/superset.git
synced 2024-09-12 08:39:45 -04:00
fix(dashboard): Cross filters with time shifted series (#23347)
This commit is contained in:
parent
a591130e0b
commit
78ee60e227
@ -107,8 +107,9 @@ export default function transformProps(
|
|||||||
} = chartProps;
|
} = chartProps;
|
||||||
const { verboseMap = {} } = datasource;
|
const { verboseMap = {} } = datasource;
|
||||||
const [queryData] = queriesData;
|
const [queryData] = queriesData;
|
||||||
const { data = [], label_map: labelMap } =
|
const { data = [], label_map = {} } =
|
||||||
queryData as TimeseriesChartDataResponseResult;
|
queryData as TimeseriesChartDataResponseResult;
|
||||||
|
|
||||||
const dataTypes = getColtypesMapping(queryData);
|
const dataTypes = getColtypesMapping(queryData);
|
||||||
const annotationData = getAnnotationData(chartProps);
|
const annotationData = getAnnotationData(chartProps);
|
||||||
|
|
||||||
@ -136,6 +137,7 @@ export default function transformProps(
|
|||||||
showValue,
|
showValue,
|
||||||
sliceId,
|
sliceId,
|
||||||
timeGrainSqla,
|
timeGrainSqla,
|
||||||
|
timeCompare,
|
||||||
stack,
|
stack,
|
||||||
tooltipTimeFormat,
|
tooltipTimeFormat,
|
||||||
tooltipSortByMetric,
|
tooltipSortByMetric,
|
||||||
@ -154,6 +156,17 @@ export default function transformProps(
|
|||||||
}: EchartsTimeseriesFormData = { ...DEFAULT_FORM_DATA, ...formData };
|
}: EchartsTimeseriesFormData = { ...DEFAULT_FORM_DATA, ...formData };
|
||||||
const refs: Refs = {};
|
const refs: Refs = {};
|
||||||
|
|
||||||
|
const labelMap = Object.entries(label_map).reduce((acc, entry) => {
|
||||||
|
if (
|
||||||
|
entry[1].length > groupby.length &&
|
||||||
|
Array.isArray(timeCompare) &&
|
||||||
|
timeCompare.includes(entry[1][0])
|
||||||
|
) {
|
||||||
|
entry[1].shift();
|
||||||
|
}
|
||||||
|
return { ...acc, [entry[0]]: entry[1] };
|
||||||
|
}, {});
|
||||||
|
|
||||||
const colorScale = CategoricalColorNamespace.getScale(colorScheme as string);
|
const colorScale = CategoricalColorNamespace.getScale(colorScheme as string);
|
||||||
const rebasedData = rebaseForecastDatum(data, verboseMap);
|
const rebasedData = rebaseForecastDatum(data, verboseMap);
|
||||||
let xAxisLabel = getXAxisLabel(chartProps.rawFormData) as string;
|
let xAxisLabel = getXAxisLabel(chartProps.rawFormData) as string;
|
||||||
|
@ -71,6 +71,7 @@ export type EchartsTimeseriesFormData = QueryFormData & {
|
|||||||
rowLimit: number;
|
rowLimit: number;
|
||||||
seriesType: EchartsTimeseriesSeriesType;
|
seriesType: EchartsTimeseriesSeriesType;
|
||||||
stack: StackType;
|
stack: StackType;
|
||||||
|
timeCompare?: string[];
|
||||||
tooltipTimeFormat?: string;
|
tooltipTimeFormat?: string;
|
||||||
truncateYAxis: boolean;
|
truncateYAxis: boolean;
|
||||||
yAxisFormat?: string;
|
yAxisFormat?: string;
|
||||||
|
@ -497,4 +497,35 @@ describe('Does transformProps transform series correctly', () => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('should remove time shift labels from label_map', () => {
|
||||||
|
const updatedChartPropsConfig = {
|
||||||
|
...chartPropsConfig,
|
||||||
|
formData: {
|
||||||
|
...formData,
|
||||||
|
timeCompare: ['1 year ago'],
|
||||||
|
},
|
||||||
|
queriesData: [
|
||||||
|
{
|
||||||
|
...queriesData[0],
|
||||||
|
label_map: {
|
||||||
|
'1 year ago, foo1, bar1': ['1 year ago', 'foo1', 'bar1'],
|
||||||
|
'1 year ago, foo2, bar2': ['1 year ago', 'foo2', 'bar2'],
|
||||||
|
'foo1, bar1': ['foo1', 'bar1'],
|
||||||
|
'foo2, bar2': ['foo2', 'bar2'],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
],
|
||||||
|
};
|
||||||
|
const chartProps = new ChartProps(updatedChartPropsConfig);
|
||||||
|
const transformedProps = transformProps(
|
||||||
|
chartProps as EchartsTimeseriesChartProps,
|
||||||
|
);
|
||||||
|
expect(transformedProps.labelMap).toEqual({
|
||||||
|
'1 year ago, foo1, bar1': ['foo1', 'bar1'],
|
||||||
|
'1 year ago, foo2, bar2': ['foo2', 'bar2'],
|
||||||
|
'foo1, bar1': ['foo1', 'bar1'],
|
||||||
|
'foo2, bar2': ['foo2', 'bar2'],
|
||||||
|
});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user