Skip to content
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

[charts] labels on YAxis have wrong position when direction is RTL on barchart and line chart #13613

Closed
ma7899 opened this issue Jun 24, 2024 · 5 comments · Fixed by #13614
Closed
Labels
bug 🐛 Something doesn't work component: charts This is the name of the generic UI component, not the React module! l10n localization

Comments

@ma7899
Copy link

ma7899 commented Jun 24, 2024

Steps to reproduce

Steps to reproduce
Link to live example:
in the bar chart demo page.
https://mui.com/x/react-charts/bar-demo

Steps:

Set the direction of the settings to Right to Left

Current behavior

The yAxis labels cover the the legend yAxis line and they have wrong position.
but the legends are behaving correctly.
image

Expected behavior

The labels should be in the same position as they are in LTR. (just at the left of the yAxis)

Context

I am trying to create a dashboard in a website which has a language that is RTL.

Your environment

npx @mui/envinfo
OS: Windows 11 10.0.22621
Binaries:
Node: v20.13.1
npm: 10.5.2
yarn: 1.22.22
Browsers:
Chrome
npmPackages:
@emotion/react": "^11.11.4,
@emotion/styled": "^11.11.5,
@mui/material": "^5.15.20,
@mui/styled-engine-sc": "^6.0.0-alpha.18,
@mui/x-charts": "^7.7.0,
@types/react: 18.2.48
react: ^18.2.0 => 18.2.0
react-dom: ^18.2.0 => 18.2.0
typescript: 4.9.5

Search keywords: RTL, labels, x-charts, bar chart, line chart, chart,=

@ma7899 ma7899 added the status: waiting for maintainer These issues haven't been looked at yet by a maintainer label Jun 24, 2024
@ma7899
Copy link
Author

ma7899 commented Jun 24, 2024

This also happens in line chart

@michelengelen
Copy link
Member

@ma7899 thanks for raising this issue.
I'll add it to the board!

@michelengelen michelengelen added bug 🐛 Something doesn't work l10n localization component: charts This is the name of the generic UI component, not the React module! and removed status: waiting for maintainer These issues haven't been looked at yet by a maintainer labels Jun 24, 2024
@michelengelen michelengelen changed the title labels on YAxis have wrong position when direction is RTL on barchart and line chart [charts] labels on YAxis have wrong position when direction is RTL on barchart and line chart Jun 24, 2024
@alexfauquette
Copy link
Member

The reason is that <text /> components have a wrong textAnchor in RTL. I'm adding a PR to fix that

Copy link

⚠️ This issue has been closed. If you have a similar problem but not exactly the same, please open a new issue.
Now, if you have additional information related to this issue or things that could help future readers, feel free to leave a comment.

@ma7899: How did we do? Your experience with our support team matters to us. If you have a moment, please share your thoughts in this short Support Satisfaction survey.

@Amir-A-M
Copy link

Amir-A-M commented Sep 4, 2024

For those who ended up here, and are not using MUI, you can fix this RTL/LTR alignment issue by adding the following CSS:

// RTL
.apexcharts-yaxis-label {
    text-anchor: start;
}

// LTR
html[dir=ltr] .apexcharts-yaxis-label {
    text-anchor: end;
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug 🐛 Something doesn't work component: charts This is the name of the generic UI component, not the React module! l10n localization
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants