Skip to content

feat(ColumnChart): add alignLabels property#8534

Open
skythefire wants to merge 2 commits intoUI5:mainfrom
skythefire:feat/column-charts-add-alignLabels
Open

feat(ColumnChart): add alignLabels property#8534
skythefire wants to merge 2 commits intoUI5:mainfrom
skythefire:feat/column-charts-add-alignLabels

Conversation

@skythefire
Copy link
Copy Markdown

@skythefire skythefire commented Apr 30, 2026

Fixes: #3421

Thank you for your contribution! 👏

To get it merged faster, kindly review the checklist below:

Pull Request Checklist

@skythefire skythefire marked this pull request as ready for review April 30, 2026 08:47
@cla-assistant
Copy link
Copy Markdown

cla-assistant Bot commented Apr 30, 2026

CLA assistant check
All committers have signed the CLA.

Copy link
Copy Markdown
Contributor

@Lukas742 Lukas742 left a comment

Choose a reason for hiding this comment

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

Hi @skythefire

thanks a lot for the contribution! Please see my review below.


  • BarChart hardcodes 'insideRight' the same way. Both are independent wrappers around recharts' BarChart (no shared base). Please add alignLabels to BarChart as well (default 'insideRight').
  • BulletChart and ComposedChart also use the ChartDataLabel component. Due to the type change a typescript error is now thrown. Please adjust the types for labelPosition in these components as well. You can check if there are build errors locally by running yarn build.

/**
* Alignment of the labels of the data points. Can be one of the following: `"center"`, `"insideTop"`, `"insideTopRight"`, `"insideRight"`, `"insideBottomRight"`, `"insideBottom"`, `"insideBottomLeft"`, `"insideLeft"`, `"insideTopLeft"`
*
* @default 'center'
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The hardcoded position was 'insideTop', but the new default is 'center'. This silently changes rendering for existing users. Please change the default to 'insideTop'.

Suggested change
* @default 'center'
* @default 'insideTop'

ChartPlaceholder,
syncId,
children,
alignLabels = 'center',
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Default value change. (see comment above)

Suggested change
alignLabels = 'center',
alignLabels = 'insideTop',

*
* @default 'center'
*/
alignLabels:
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Prop should be optional.

Suggested change
alignLabels:
alignLabels?:

Comment on lines +83 to +91
| 'center'
| 'insideTop'
| 'insideTopRight'
| 'insideRight'
| 'insideBottomRight'
| 'insideBottom'
| 'insideBottomLeft'
| 'insideLeft'
| 'insideTopLeft';
Copy link
Copy Markdown
Contributor

@Lukas742 Lukas742 May 4, 2026

Choose a reason for hiding this comment

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

As this is only a pass through implementation of the recharts prop, you can reuse the type here.

import type { LabelProps } from 'recharts';
alignLabels?: LabelProps['position'];

import { ThemingParameters } from '@ui5/webcomponents-react-base/ThemingParameters';
import { createElement } from 'react';
import { Label } from 'recharts';
import type { LabelPosition } from 'recharts/types/component/Label.js';
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Avoid deep imports when possible, as they are mostly not considered stable. The import could break if the internal structure of the recharts library changes for example.

import type { LabelProps } from 'recharts';
position?: LabelProps['position'];

value={formattedLabel}
/>
);
return <Label viewBox={viewBox} {...props} fill={fill} stroke={'none'} content={undefined} value={formattedLabel} />;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This is a pre-existing issue, but since you're already in this file: the old {...(props as any)} hid the fact that config, chartType, isBigDataSet get spread onto <Label>. Now that as any is removed, could you also destructure those out?

const { config, chartType, isBigDataSet, ...labelProps } = props;
return <Label viewBox={viewBox} {...labelProps} fill={fill} stroke={'none'} content={undefined} value={formattedLabel} />;

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.

Stacked Charts: Label Alignment

2 participants