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

[Lens] Enable treemap in suggestions #169095

Merged
merged 7 commits into from
Jan 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -239,12 +239,7 @@ export function suggestions({
],
},
previewIcon: PartitionChartsMeta.treemap.icon,
// hide treemap suggestions from bottom bar, but keep them for chart switcher
hide:
table.changeType === 'reduced' ||
!state ||
hasIntervalScale(groups) ||
(state && state.shape === PieChartTypes.TREEMAP),
hide: table.changeType === 'reduced' || hasIntervalScale(groups),
});
}

Expand Down Expand Up @@ -292,11 +287,7 @@ export function suggestions({
],
},
previewIcon: PartitionChartsMeta.mosaic.icon,
hide:
groups.length !== 2 ||
table.changeType === 'reduced' ||
hasIntervalScale(groups) ||
(state && state.shape === 'mosaic'),
hide: groups.length !== 2 || table.changeType === 'reduced' || hasIntervalScale(groups),
});
}

Expand Down Expand Up @@ -341,11 +332,7 @@ export function suggestions({
],
},
previewIcon: PartitionChartsMeta.waffle.icon,
hide:
groups.length !== 1 ||
table.changeType === 'reduced' ||
hasIntervalScale(groups) ||
(state && state.shape === 'waffle'),
hide: groups.length !== 1 || table.changeType === 'reduced' || hasIntervalScale(groups),
});
}

Expand All @@ -359,7 +346,12 @@ export function suggestions({
.sort((a, b) => b.score - a.score)
.map((suggestion) => ({
...suggestion,
hide: shouldHideSuggestion || incompleteConfiguration || suggestion.hide,
hide:
// avoid to suggest the same shape if already used
(state && state.shape === suggestion.state.shape) ||
shouldHideSuggestion ||
incompleteConfiguration ||
suggestion.hide,
incomplete: incompleteConfiguration,
}));
}
6 changes: 3 additions & 3 deletions x-pack/test/functional/apps/lens/group1/smokescreen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
expect(data?.axes?.y?.[1].gridlines.length).to.eql(0);
});

it('should transition from a multi-layer stacked bar to donut chart using suggestions', async () => {
it('should transition from a multi-layer stacked bar to treemap chart using suggestions', async () => {
await PageObjects.visualize.navigateToNewVisualization();
await PageObjects.visualize.clickVisType('lens');
await PageObjects.lens.goToTimeRange();
Expand Down Expand Up @@ -313,10 +313,10 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
});

await PageObjects.lens.save('twolayerchart');
await testSubjects.click('lnsSuggestion-donut > lnsSuggestion');
await testSubjects.click('lnsSuggestion-treemap > lnsSuggestion');

expect(await PageObjects.lens.getLayerCount()).to.eql(1);
expect(await PageObjects.lens.getDimensionTriggerText('lnsPie_sliceByDimensionPanel')).to.eql(
expect(await PageObjects.lens.getDimensionTriggerText('lnsPie_groupByDimensionPanel')).to.eql(
'Top 5 values of geo.dest'
);
expect(await PageObjects.lens.getDimensionTriggerText('lnsPie_sizeByDimensionPanel')).to.eql(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
expect(data?.axes?.y?.[1].gridlines.length).to.eql(0);
});

it('should transition from a multi-layer stacked bar to donut chart using suggestions', async () => {
it('should transition from a multi-layer stacked bar to treemap chart using suggestions', async () => {
await PageObjects.visualize.navigateToNewVisualization();
await PageObjects.visualize.clickVisType('lens');
await PageObjects.lens.goToTimeRange();
Expand Down Expand Up @@ -313,10 +313,10 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
});

await PageObjects.lens.save('twolayerchart');
await testSubjects.click('lnsSuggestion-donut > lnsSuggestion');
await testSubjects.click('lnsSuggestion-treemap > lnsSuggestion');

expect(await PageObjects.lens.getLayerCount()).to.eql(1);
expect(await PageObjects.lens.getDimensionTriggerText('lnsPie_sliceByDimensionPanel')).to.eql(
expect(await PageObjects.lens.getDimensionTriggerText('lnsPie_groupByDimensionPanel')).to.eql(
'Top 5 values of geo.dest'
);
expect(await PageObjects.lens.getDimensionTriggerText('lnsPie_sizeByDimensionPanel')).to.eql(
Expand Down