Skip to content

Conversation

@Pixselve
Copy link
Contributor

Description

This PR adds support for horizontal alignment of chart legends when positioned at the bottom. The new horizontalAlignment property allows legends to be aligned to the start or center of the chart container.

Key changes:
• Added horizontalAlignment property to CoreChartProps.LegendOptions (supports "start" and "center")
• Updated legend component to apply alignment styles for bottom-positioned legends
• Added demo pages for dual-axis charts and pie charts

How has this been tested?

• Manually tested the new horizontalAlignment property with bottom-positioned legends in the demo pages (core-line-chart, dual-axis-chart, and pie chart demos)
• Verified that alignment only applies when legend position is "bottom"
• Tested that the alignment control is properly disabled when legend is hidden or positioned on the side
• Verified backward compatibility by ensuring the property is optional

To test:

  1. Run the demo pages at pages/03-core/core-line-chart.page.tsx, pages/03-core/dual-axis-chart.page.tsx, and pages/03-core/pie.page.tsx
  2. Toggle the "Legend Horizontal Align" setting between "Start" and "Center"
  3. Verify the legend alignment changes accordingly when position is "bottom"
  4. Confirm the alignment control is disabled when legend position is "side"
2025-10-28_13-53-20.mp4
Review checklist

The following items are to be evaluated by the author(s) and the reviewer(s).

Correctness

• [x] Changes include appropriate documentation updates.
• [x] Changes are backward-compatible if not indicated, see CONTRIBUTING.md.
• [x] Changes do not include unsupported browser features, see CONTRIBUTING.md.
• [x] Changes were manually tested for accessibility, see accessibility guidelines.

Security

• [x] If the code handles URLs: all URLs are validated through the checkSafeUrl function. (N/A - no URL handling)

Testing

• [x] Changes are covered with new/existing unit tests?
• [x] Changes are covered with new/existing integration tests?

@Pixselve Pixselve force-pushed the main branch 2 times, most recently from 2729809 to 7a3e853 Compare October 30, 2025 16:18
@Pixselve
Copy link
Contributor Author

Pixselve commented Nov 3, 2025

Got tangled with my branches. Sorry about the latest push (that I reverted)

I see the build is failing (due to credentials not being fetched). Should I do something about it?

@pan-kot
Copy link
Member

pan-kot commented Nov 12, 2025

Due to the current wrapping behaviour, centering the legend can feel broken when it is sufficiently large. Do we expect this to be only relevant for small legends?

Screen.Recording.2025-11-12.at.10.46.46.mov

@Pixselve
Copy link
Contributor Author

Due to the current wrapping behaviour, centering the legend can feel broken when it is sufficiently large. Do we expect this to be only relevant for small legends?

Screen.Recording.2025-11-12.at.10.46.46.mov

Indeed. Fixed it in the next revision.

image

@pan-kot pan-kot added this pull request to the merge queue Nov 13, 2025
Merged via the queue into cloudscape-design:main with commit 5a52162 Nov 13, 2025
42 of 44 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants