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] Pie and donuts should have a size ratio setting #120101

Merged
merged 27 commits into from
Dec 20, 2021

Conversation

DianaDerevyankina
Copy link
Contributor

@DianaDerevyankina DianaDerevyankina commented Dec 1, 2021

Closes #65538

Summary

Added a setting for classic Pie and Lens Donut visualizations that allow to configure the donut thickness. Previous ratio is now "Small" and selected by default.

donut size setting demo lens

donut size setting demo classic

setting is hidden for visualization:visualize:legacyPieChartsLibrary
image

Checklist

Delete any items that are not applicable to this PR.

For maintainers

@DianaDerevyankina DianaDerevyankina self-assigned this Dec 1, 2021
# Conflicts:
#	x-pack/plugins/lens/public/pie_visualization/constants.ts
#	x-pack/plugins/lens/public/pie_visualization/partition_charts_meta.ts
#	x-pack/plugins/lens/public/pie_visualization/to_expression.ts
#	x-pack/plugins/lens/public/pie_visualization/toolbar.tsx
@DianaDerevyankina DianaDerevyankina added Feature:Lens release_note:enhancement Team:Visualizations Visualization editors, elastic-charts and infrastructure backport:skip This commit does not require backporting v8.1.0 labels Dec 2, 2021
({ value }) => value === stateParams.donutInnerAreaSize
)?.id || 'donutInnerAreaSizeOption-medium'
}
onChange={(sizeId) => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

plz move into useCallback

idSelected={
donutInnerAreaSizeOptions.find(
({ value }) => value === stateParams.donutInnerAreaSize
)?.id || 'donutInnerAreaSizeOption-medium'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: with ? we normally use ?? instead of ||

@@ -37,6 +38,11 @@ interface PartitionChartMeta {
value: SharedPieLayerState['numberDisplay'];
inputDisplay: string;
}>;
donutInnerAreaSizeOptions: Array<{
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

metadata should keep a generic data. let's exclude everything with a special chart name

@@ -37,6 +38,11 @@ interface PartitionChartMeta {
value: SharedPieLayerState['numberDisplay'];
inputDisplay: string;
}>;
innerAreaSizeOptions: Array<{
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we make it optional?

@@ -82,6 +82,7 @@ export function PieComponent(
legendPosition,
nestedLegend,
percentDecimals,
donutInnerAreaSize,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't understand why you use donutInnerAreaSize name instead of generic emptySizeRatio?

@DianaDerevyankina DianaDerevyankina marked this pull request as ready for review December 7, 2021 13:29
@DianaDerevyankina DianaDerevyankina requested a review from a team as a code owner December 7, 2021 13:29
@elasticmachine
Copy link
Contributor

Pinging @elastic/kibana-vis-editors @elastic/kibana-vis-editors-external (Team:VisEditors)

# Conflicts:
#	x-pack/plugins/lens/public/pie_visualization/to_expression.ts
#	x-pack/plugins/lens/public/pie_visualization/toolbar.tsx
Copy link
Contributor

@stratoula stratoula left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@dziyanadzeraviankina this looks great. Let's add some unit tests as the options appear under specific condtions.

@ghudgins @MichaelMarcialis can you also take a look and let us know if the selected ratios seem fine?

@@ -116,6 +129,22 @@ const PieOptions = (props: PieOptionsProps) => {
value={stateParams.isDonut}
setValue={setValue}
/>
{props.showElasticChartsOptions && stateParams.isDonut && (
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you cover this functionality in the pie.test? I have other cases there, let's test that it is hidden when vislib is on or if it is a pie.
Also can we also add a test for lens to test that the visual options menu is only visible when we have a donut partition chart and not a pie or treemap etc

@MichaelMarcialis
Copy link
Contributor

@ghudgins @MichaelMarcialis can you also take a look and let us know if the selected ratios seem fine?

To my eyes, the ratio for the size differences between small-to-medium and medium-to-large appear to be quite large. For example, moving from small-top-medium appears as a small increase in the donut hole size, whereas going from medium-to-large appears as a very large increase in donut hole size. Would it be possible to distribute these sizes more evenly? Or is there a specific reason for this? CCing @gvnmagni in case he has additional thoughts.

Also, as a small side thought, would Donut hole size be a better label for this field, instead of Inner area size?

@ghudgins
Copy link
Contributor

agreed at the options feeling a bit off. The large looks good but small & medium look both pretty small. I think the reasoning for this was to provide more space for the interior label but it's hard to imagine anyone who edits this setting changing to small (from medium) since they're so similar.

@stratoula
Copy link
Contributor

@MichaelMarcialis @ghudgins I agree with your point. If we give only two options? (Large which will give the same ratio as vislib pie) and Normal (which will be what we have so far?) We can change the naming of course but maybe the small hole doesn't make any difference.

@gvnmagni
Copy link

gvnmagni commented Dec 14, 2021

Thank you @MichaelMarcialis for tagging me! I'm not aware of any specific rule about this ratio (a part avoiding holes too big or too small), I'd say that we should follow our common sense. I'd distribute these 3 ratio in order to have the distance between them consistent

@monfera any thought about this? Any rule/practice that I'm not aware of?

@flash1293
Copy link
Contributor

@gvnmagni

I'd distribute these 3 ratio in order to have the distance between them consistent

Consistent in terms of radius or area of the hole? I think the later would make more sense here.

Copy link
Contributor

@alexwizp alexwizp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

code lgtm

@gvnmagni
Copy link

@gvnmagni

I'd distribute these 3 ratio in order to have the distance between them consistent

Consistent in terms of radius or area of the hole? I think the later would make more sense here.

Agree! Even if in this case we are not encoding data with the area I'd say that we should always consider the area when dealing with these kind of chart. Thank you for mentioning this, I gave it for granted :)

@flash1293
Copy link
Contributor

@elasticmachine merge upstream

Copy link
Contributor

@flash1293 flash1293 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So I don't have a strong opinion, but what about 0.3, 0.54 and 0.7 (defaulting to 0.3)?
Screenshot 2021-12-16 at 17 21 32
Screenshot 2021-12-16 at 17 26 30
Screenshot 2021-12-16 at 17 21 45

This will make the change in area consistent giving the user options without changing our current default donut.

  • 0.3 has an area of 0.28274333882
  • 0.54 has an area of 0.91608841778
  • 0.7 has an area of 1.53938040026

Otherwise this PR looks good to me (agree with Stratoulas comments), we can also merge it without a final answer to the question on the hole ratios as it's easy to change afterwards

Copy link
Contributor

@flash1293 flash1293 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@DianaDerevyankina
Copy link
Contributor Author

@elasticmachine merge upstream

@kibana-ci
Copy link
Collaborator

💚 Build Succeeded

Metrics [docs]

Module Count

Fewer modules leads to a faster build time

id before after diff
visTypePie 47 48 +1

Public APIs missing comments

Total count of every public API that lacks a comment. Target amount is 0. Run node scripts/build_api_docs --plugin [yourplugin] --stats comments for more detailed information.

id before after diff
lens 245 246 +1

Async chunks

Total size of all lazy-loaded chunks that will be downloaded as the user navigates the app

id before after diff
lens 1018.9KB 1020.4KB +1.5KB
visTypePie 50.4KB 51.5KB +1.1KB
total +2.6KB

Page load bundle

Size of the bundles that are downloaded on every page load. Target size is below 100kb

id before after diff
lens 40.9KB 41.0KB +42.0B
visTypePie 14.0KB 14.4KB +407.0B
total +449.0B
Unknown metric groups

API count

id before after diff
lens 262 263 +1

History

To update your PR or re-run it, just comment with:
@elasticmachine merge upstream

cc @dziyanadzeraviankina

@DianaDerevyankina DianaDerevyankina merged commit 2d2d702 into elastic:main Dec 20, 2021
mibragimov pushed a commit to mibragimov/kibana that referenced this pull request Dec 22, 2021
* [WIP][Lens] Waffle visualization type

Closes:  elastic#107059

* add showExtraLegend for waffle

* add tests

* resolved 1 and 5

* resolved 6

* add sortPredicate for waffle chart type

* [Lens] Pie and donuts should have a size ratio setting

* Add a missed condition

* Fix changing size for smallSlices

* Add donut inner area size setting to pie visualization and update it for lens

* Update test and rename some constants

* Rename the setting

* Move handler to a separate useCallback function

* Update size ratios and add condition for legacy charts

* Fix merge conflict issue

* Change constants order

* Add a couple of tests to check if the setting is displayed

* Update ratio sizes

Co-authored-by: Alexey Antonov <[email protected]>
Co-authored-by: Kibana Machine <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport:skip This commit does not require backporting Feature:Lens release_note:enhancement Team:Visualizations Visualization editors, elastic-charts and infrastructure v8.1.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Lens] Pie and donuts should have a size ratio setting
10 participants