-
Notifications
You must be signed in to change notification settings - Fork 120
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
feat(legend): render multiple columns on float config #1159
feat(legend): render multiple columns on float config #1159
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, tested locally.
I think we should try to constrain the width to within the chart because this could get unwieldy pretty quickly. Constraining the overall width will start to truncate the longest strings to satisfy the constrain.
@@ -9,12 +9,6 @@ | |||
} | |||
} | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we change the .echLegendList
styles to include grid by default now?
.echLegendList {
display: grid;
}
&--horizontal {
.echLegendList {
grid-column-gap: $echLegendColumnGap;
grid-row-gap: $echLegendRowGap;
margin-top: $echLegendRowGap;
margin-bottom: $echLegendRowGap;
}
}
src/components/legend/style_utils.ts
Outdated
@@ -68,18 +69,22 @@ export function getLegendListStyle( | |||
return { | |||
paddingTop, | |||
paddingBottom, | |||
...(floating && { | |||
display: 'grid', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Make default, see previous comment
display: 'grid', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done in 3b1cfc4
src/components/legend/style_utils.ts
Outdated
@@ -68,18 +69,22 @@ export function getLegendListStyle( | |||
return { | |||
paddingTop, | |||
paddingBottom, | |||
...(floating && { | |||
display: 'grid', | |||
gridTemplateColumns: `repeat(${clamp(floatingColumns ?? 1, 1, totalItems)}, 1fr`, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
1fr
will cause the largest string to control the width for all columns like this....
If we use auto
instead of 1fr
then each column width will be independent. Not sure which you think is desirable but I like the independent widths.
gridTemplateColumns: `repeat(${clamp(floatingColumns ?? 1, 1, totalItems)}, 1fr`, | |
gridTemplateColumns: `repeat(${clamp(floatingColumns ?? 1, 1, totalItems)}, auto`, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed in 3b1cfc4
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM just one comment.
src/components/legend/style_utils.ts
Outdated
@@ -62,16 +62,15 @@ export function getLegendListStyle( | |||
return { | |||
paddingLeft, | |||
paddingRight, | |||
gridTemplateColumns: `repeat(auto-fill, minmax(${legendStyle.verticalWidth}px, 1fr))`, | |||
gridTemplateColumns: `repeat(auto-fill, minmax(${legendStyle.verticalWidth}px, auto))`, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think this should be auto
. The auto
with the auto-fill
acts differently than without, like below on line 73. I don't see any noticeable difference here so I think we should revert this and revisit how the horizontal legend sizes the columns is a future PR.
gridTemplateColumns: `repeat(auto-fill, minmax(${legendStyle.verticalWidth}px, auto))`, | |
gridTemplateColumns: `repeat(auto-fill, minmax(${legendStyle.verticalWidth}px, 1fr))`, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done here thanks 8facfeb
# [29.2.0](v29.1.0...v29.2.0) (2021-05-25) ### Bug Fixes * **legend:** disable handleLabelClick for one legend item ([#1134](#1134)) ([a7242af](a7242af)), closes [#1055](#1055) ### Features * **a11y:** add alt text for all chart types ([#1118](#1118)) ([9e42229](9e42229)), closes [#1107](#1107) * **legend:** specify number of columns on floating legend ([#1159](#1159)) ([c2e4652](c2e4652)), closes [#1158](#1158) * simple screenspace constraint solver ([#1141](#1141)) ([eb11480](eb11480))
🎉 This PR is included in version 29.2.0 🎉 The release is available on: Your semantic-release bot 📦🚀 |
# [29.2.0](elastic/elastic-charts@v29.1.0...v29.2.0) (2021-05-25) ### Bug Fixes * **legend:** disable handleLabelClick for one legend item ([opensearch-project#1134](elastic/elastic-charts#1134)) ([e485174](elastic/elastic-charts@e485174)), closes [opensearch-project#1055](elastic/elastic-charts#1055) ### Features * **a11y:** add alt text for all chart types ([opensearch-project#1118](elastic/elastic-charts#1118)) ([e1c7489](elastic/elastic-charts@e1c7489)), closes [opensearch-project#1107](elastic/elastic-charts#1107) * **legend:** specify number of columns on floating legend ([opensearch-project#1159](elastic/elastic-charts#1159)) ([ed3736e](elastic/elastic-charts@ed3736e)), closes [opensearch-project#1158](elastic/elastic-charts#1158) * simple screenspace constraint solver ([opensearch-project#1141](elastic/elastic-charts#1141)) ([af9dd96](elastic/elastic-charts@af9dd96))
Summary
When rendering a floating legend inside the chart (
Settings.legendPosition.floating:true
), the addedSettings.legendPosition.floatingColumns
property allows you to specify the number of columns used to distributed the legend items.Connected issues
This feature was added as part of the Kibana Timelion chart library replacement.
fix #1158
Checklist
Delete any items that are not applicable to this PR.
src/index.ts
(and stories only import from../src
except for test data & storybook)