Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(dashboard): Cross filters with time shifted series #23347

Merged
merged 2 commits into from
Mar 13, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Add test
  • Loading branch information
kgabryje committed Mar 13, 2023
commit f5f6d9f49d289dd9922e8b8fc6a6065a1b3c3220
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@ export default function transformProps(
showValue,
sliceId,
timeGrainSqla,
timeCompare,
stack,
tooltipTimeFormat,
tooltipSortByMetric,
Expand All @@ -158,8 +159,8 @@ export default function transformProps(
const labelMap = Object.entries(label_map).reduce((acc, entry) => {
if (
entry[1].length > groupby.length &&
Array.isArray(formData.timeCompare) &&
formData.timeCompare.includes(entry[1][0])
Array.isArray(timeCompare) &&
timeCompare.includes(entry[1][0])
) {
entry[1].shift();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ export type EchartsTimeseriesFormData = QueryFormData & {
rowLimit: number;
seriesType: EchartsTimeseriesSeriesType;
stack: StackType;
timeCompare?: string[];
tooltipTimeFormat?: string;
truncateYAxis: boolean;
yAxisFormat?: string;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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'],
});
});
});