Skip to content

Commit

Permalink
[Lens] Enable treemap in suggestions (elastic#169095)
Browse files Browse the repository at this point in the history
## Summary

Enable treemaps in suggestions outside the partition chart realm.


### Checklist

- [x] [Unit or functional
tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)
were updated or added to match the most common scenarios

---------

Co-authored-by: Stratoula Kalafateli <efstratia.kalafateli@elastic.co>
  • Loading branch information
2 people authored and delanni committed Jan 11, 2024
1 parent 526d816 commit ca160aa
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 23 deletions.
26 changes: 9 additions & 17 deletions x-pack/plugins/lens/public/visualizations/partition/suggestions.ts
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

0 comments on commit ca160aa

Please sign in to comment.