-
Notifications
You must be signed in to change notification settings - Fork 121
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): multiline labels with maxLines option #1285
Merged
nickofthyme
merged 16 commits into
elastic:master
from
nickofthyme:multiline-legend-labels
Aug 6, 2021
Merged
Changes from all commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
aff29d4
feat(legend): multiline labels
nickofthyme 477f611
fix: api changes
nickofthyme b60160f
test: update jest snapshots
nickofthyme 5b2bc29
Merge branch 'master' into multiline-legend-labels
nickofthyme bec8643
test: add vrts for new multiline option
nickofthyme 1859545
Merge remote-tracking branch 'origin' into multiline-legend-labels
nickofthyme d6fb516
Merge remote-tracking branch 'origin' into multiline-legend-labels
nickofthyme fcd45ca
Merge remote-tracking branch 'origin/multiline-legend-labels' into mu…
nickofthyme 88ebac5
fix: align to top per marcos comments
nickofthyme bdee07e
fix: labels with long words, now hyphenated
nickofthyme d8be979
refactor: use max line prop instead of multiline boolean, add vrts
nickofthyme 6800bc2
test: update snapshots
nickofthyme 5959a18
test: update vrt screenshots
nickofthyme 575b6da
fix: api changes
nickofthyme 697f73d
fix: test and linting issues
nickofthyme f796ae3
fix: attempted fix of flaky vrt
nickofthyme File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file modified
BIN
+17 Bytes
(100%)
...tions-clicks-hovers-on-legend-items-bar-chart-visually-looks-correct-1-snap.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
-9 Bytes
(100%)
...ual-tests-for-all-stories-legend-inside-chart-visually-looks-correct-1-snap.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
+15 Bytes
(100%)
...line-visual-tests-for-all-stories-legend-left-visually-looks-correct-1-snap.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
+17 Bytes
(100%)
...ine-visual-tests-for-all-stories-legend-right-visually-looks-correct-1-snap.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
+14 Bytes
(100%)
...gs-custom-series-colors-via-accessor-function-visually-looks-correct-1-snap.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
+5 Bytes
(100%)
...tylings-custom-series-colors-via-colors-array-visually-looks-correct-1-snap.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
+14 Bytes
(100%)
...gative-log-areas-shows-only-negative-values-when-hiding-positive-one-1-snap.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
-12 Bytes
(100%)
...ons-tooltips-should-render-current-tooltip-for-split-and-y-accessors-1-snap.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
+164 Bytes
(100%)
...-stories-keyboard-navigation-should-navigate-to-legend-item-with-tab-1-snap.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
-253 Bytes
(99%)
...end-stories-legend-inside-chart-should-correctly-display-bottom-left-1-snap.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
-232 Bytes
(99%)
...egend-inside-chart-should-correctly-display-bottom-left-in-dark-mode-1-snap.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+51.4 KB
...-inside-chart-should-correctly-display-bottom-left-in-multiline-mode-1-snap.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
-9 Bytes
(100%)
...nd-stories-legend-inside-chart-should-correctly-display-bottom-right-1-snap.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
-7 Bytes
(100%)
...gend-inside-chart-should-correctly-display-bottom-right-in-dark-mode-1-snap.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+51 KB
...inside-chart-should-correctly-display-bottom-right-in-multiline-mode-1-snap.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
-93 Bytes
(100%)
...legend-stories-legend-inside-chart-should-correctly-display-top-left-1-snap.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
-289 Bytes
(99%)
...s-legend-inside-chart-should-correctly-display-top-left-in-dark-mode-1-snap.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+52.6 KB
...end-inside-chart-should-correctly-display-top-left-in-multiline-mode-1-snap.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
-130 Bytes
(100%)
...egend-stories-legend-inside-chart-should-correctly-display-top-right-1-snap.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
-274 Bytes
(99%)
...-legend-inside-chart-should-correctly-display-top-right-in-dark-mode-1-snap.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+52 KB
...nd-inside-chart-should-correctly-display-top-right-in-multiline-mode-1-snap.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+51.2 KB
...-should-correctly-truncate-multiline-labels-up-to-max-lines-set-to-0-1-snap.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+38.3 KB
...-should-correctly-truncate-multiline-labels-up-to-max-lines-set-to-1-1-snap.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+51.2 KB
...-should-correctly-truncate-multiline-labels-up-to-max-lines-set-to-3-1-snap.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+41.5 KB
...ies-should-breakup-multiline-legend-labels-with-long-continous-words-1-snap.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+106 KB
...egend-stories-should-correctly-render-multiline-nested-legend-labels-1-snap.png
Oops, something went wrong.
Binary file added
BIN
+29.4 KB
...nd-stories-should-correctly-render-very-long-multiline-legend-labels-1-snap.png
Oops, something went wrong.
Binary file modified
BIN
-1 Byte
(100%)
...tooltip-placement-with-legend-should-render-tooltip-with-left-legend-1-snap.png
Oops, something went wrong.
Binary file modified
BIN
+6 Bytes
(100%)
...ooltip-placement-with-legend-should-render-tooltip-with-right-legend-1-snap.png
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -27,7 +27,7 @@ describe('Legend stories', () => { | |
}); | ||
it('should 0 legend buffer', async () => { | ||
await common.expectChartAtUrlToMatchScreenshot( | ||
'http://localhost:9001/?path=/story/legend--legend-spacing-buffer&knob-legend buffer value=0', | ||
'http://localhost:9001/?path=/story/legend--legend-spacing-buffer&knob-legend buffer value=0&knob-max legend label lines=1', | ||
); | ||
}); | ||
it('should have the same order as nested with no indent even if there are repeated labels', async () => { | ||
|
@@ -36,6 +36,24 @@ describe('Legend stories', () => { | |
); | ||
}); | ||
|
||
it('should correctly render multiline nested legend labels', async () => { | ||
await common.expectChartAtUrlToMatchScreenshot( | ||
'http://localhost:9001/?path=/story/legend--piechart&globals=backgrounds.value:!hex(fff);themes.value:Light&knob-Hide color picker=true&knob-Hide color picker_Legend=true&knob-Legend position=right&knob-Legend position_Legend=right&knob-max legend label lines=0&knob-Number of series=5&knob-Popover position=leftCenter&knob-Popover position_Legend=leftCenter&knob-Series with long name=3&knob-direction_Legend=vertical&knob-floating columns_Legend=2&knob-hAlign_Legend=right&knob-legend buffer value=80&knob-legend margins=20&knob-long label text_Legend=Non do aliqua veniam dolore ipsum eu aliquip. Culpa in duis amet non velit qui non ullamco sit adipisicing. Ut sunt Lorem mollit exercitation deserunt officia sunt ipsum eu amet.&knob-multiline Legend labels=true&knob-vAlign_Legend=bottom&knob-Partition Layout=sunburst&knob-flatLegend=&knob-showLegendExtra=&knob-legendMaxDepth=2&knob-legendStrategy=key', | ||
); | ||
}); | ||
|
||
it('should correctly render very long multiline legend labels', async () => { | ||
await common.expectChartAtUrlToMatchScreenshot( | ||
'http://localhost:9001/?path=/story/legend--legend-spacing-buffer&globals=backgrounds.value:transparent;themes.value:Light&knob-Hide color picker=true&knob-Hide color picker_Legend=true&knob-Legend position=right&knob-Legend position_Legend=right&knob-Number of series=5&knob-Partition Layout=sunburst&knob-Popover position=leftCenter&knob-Popover position_Legend=leftCenter&knob-Series with long name=3&knob-direction_Legend=vertical&knob-flatLegend=true&knob-floating columns_Legend=2&knob-hAlign_Legend=right&knob-legend buffer value=80&knob-legend margins=20&knob-legendMaxDepth=3&knob-legendStrategy=key&knob-long label text_Legend=Non do aliqua veniam dolore ipsum eu aliquip. Culpa in duis amet non velit qui non ullamco sit adipisicing. Ut sunt Lorem mollit exercitation deserunt officia sunt ipsum eu amet.&knob-max legend label lines=0&knob-showLegendExtra=true&knob-use long labels=true&knob-vAlign_Legend=bottom', | ||
); | ||
}); | ||
|
||
it('should breakup multiline legend labels with long continous words', async () => { | ||
await common.expectChartAtUrlToMatchScreenshot( | ||
'http://localhost:9001/?path=/story/legend--inside-chart&globals=backgrounds.value:transparent;themes.value:Light&knob-Inside chart_Legend=false&knob-Legend position_Legend=right&knob-max label lines_Legend=0&knob-Number of series=5&knob-Popover position_Legend=leftCenter&knob-Series with long name=3&knob-direction_Legend=vertical&knob-floating columns_Legend=2&knob-hAlign_Legend=right&knob-long label_Legend=a few separate words then averyongcontinuouswordthatneedstobebrokenup&knob-vAlign_Legend=bottom', | ||
); | ||
}); | ||
|
||
it('should render color picker on mouse click', async () => { | ||
const action = async () => { | ||
await common.clickMouseRelativeToDOMElement({ left: 0, top: 0 }, '.echLegendItem__color'); | ||
|
@@ -160,25 +178,46 @@ describe('Legend stories', () => { | |
}, | ||
); | ||
}); | ||
|
||
describe('Legend inside chart', () => { | ||
const getPositionalUrl = (p1: string, p2: string, others: string = '') => | ||
`http://localhost:9001/?path=/story/legend--inside-chart&knob-vAlign_Legend=${p1}&knob-hAlign_Legend=${p2}${others}`; | ||
Comment on lines
+183
to
+184
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. fixes knob to align with correct |
||
|
||
it.each([ | ||
[Position.Top, Position.Left], | ||
[Position.Top, Position.Right], | ||
[Position.Bottom, Position.Left], | ||
[Position.Bottom, Position.Right], | ||
])('should correctly display %s %s', async (pos1, pos2) => { | ||
await common.expectChartAtUrlToMatchScreenshot( | ||
`http://localhost:9001/?path=/story/legend--inside-chart&knob-Legend Position[0]=${pos1}&knob-Legend Position[1]=${pos2}&globals=themes.value:Light`, | ||
); | ||
])('should correctly display %s %s', async (p1, p2) => { | ||
await common.expectChartAtUrlToMatchScreenshot(getPositionalUrl(p1, p2, '&globals=themes.value:Light')); | ||
}); | ||
|
||
it.each([ | ||
[Position.Top, Position.Left], | ||
[Position.Top, Position.Right], | ||
[Position.Bottom, Position.Left], | ||
[Position.Bottom, Position.Right], | ||
])('should correctly display %s %s in dark mode', async (p1, p2) => { | ||
await common.expectChartAtUrlToMatchScreenshot(getPositionalUrl(p1, p2, '&globals=themes.value:Dark')); | ||
}); | ||
|
||
const longLabel = | ||
'Non do aliqua veniam dolore ipsum eu aliquip. Culpa in duis amet non velit qui non ullamco sit adipisicing. Ut sunt Lorem mollit exercitation deserunt officia sunt ipsum eu amet.'; | ||
|
||
it.each([ | ||
[Position.Top, Position.Left], | ||
[Position.Top, Position.Right], | ||
[Position.Bottom, Position.Left], | ||
[Position.Bottom, Position.Right], | ||
])('should correctly display %s %s in dark mode', async (pos1, pos2) => { | ||
])('should correctly display %s %s in multiline mode', async (p1, p2) => { | ||
await common.expectChartAtUrlToMatchScreenshot( | ||
getPositionalUrl(p1, p2, `&knob-max label lines_Legend=0&knob-long label_Legend=${longLabel}`), | ||
); | ||
}); | ||
|
||
it.each([0, 1, 3])('should correctly truncate multiline labels up to maxLines set to %d', async (maxLines) => { | ||
await common.expectChartAtUrlToMatchScreenshot( | ||
`http://localhost:9001/?path=/story/legend--inside-chart&knob-Legend Position[0]=${pos1}&knob-Legend Position[1]=${pos2}&globals=themes.value:Dark`, | ||
`http://localhost:9001/?path=/story/legend--inside-chart&globals=backgrounds.value:transparent;themes.value:Light&knob-Number of series=5&knob-Series with long name=3&knob-Inside chart_Legend=false&knob-floating columns_Legend=2&knob-vAlign_Legend=bottom&knob-hAlign_Legend=right&knob-direction_Legend=vertical&knob-max label lines_Legend=${maxLines}&knob-long label_Legend=${longLabel}`, | ||
); | ||
}); | ||
}); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
This story was misbehaving, need to look into more later.