feat: add horizontal scroll option for chart legend#181
feat: add horizontal scroll option for chart legend#181jperals merged 2 commits intocloudscape-design:mainfrom
Conversation
| -webkit-box-orient: vertical; | ||
| } | ||
|
|
||
| .list-horizontal-scroll { |
There was a problem hiding this comment.
There are issues with the tooltip:
- It is misplaced when the labels are very long
- Very long labels are cut off
- It moves along when horizontally scrolling
scrollable-legend-horizontal-02-trimmed.mov
There was a problem hiding this comment.
I'll create a PR in the components repository to allow locking the horizontal position of the tooltip.
There was a problem hiding this comment.
Would it also be an option to prevent the tooltip trigger from scrolling by having the overflowing element be a descendant of the trigger instead?
| * When set to true, enables horizontal scrolling for legend items with long text. | ||
| * By default, long text is truncated with ellipsis. | ||
| */ | ||
| enableHorizontalScroll?: boolean; |
There was a problem hiding this comment.
Note that you'll have to update the Documenter snapshots.
You can do it by running
npx vitest run --config vite.config.unit.mjs -u src/__tests__/documenter.test.ts
| } | ||
| /> | ||
| ); | ||
| case "legendHorizontalScroll": |
There was a problem hiding this comment.
It would be useful to have actually really long series names in this dev page in order to test this. There could be an option for it, or alternative change the series names when legendHorizontalScroll is true.
481a071
Adds an
enableHorizontalScrolloption toLegendOptionsthat allows legend containers to scroll horizontally instead of truncating long text with ellipsis.Changes:
enableHorizontalScrollprop threaded throughCoreChartProps.LegendOptions→CoreLegend→ChartLegendoverflow-x: autoon the legend list andoverflow: visibleon item labels when enabledTesting