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

Is RTL layout supported for Victory charts? #2843

Open
2 tasks done
BhargaviAnnadevara opened this issue Mar 29, 2024 · 4 comments
Open
2 tasks done

Is RTL layout supported for Victory charts? #2843

BhargaviAnnadevara opened this issue Mar 29, 2024 · 4 comments
Labels
Issue: Accepted The submitted issue has been confirmed by the Victory core team Type: Enhancement ✏️ An enhancement or feature proposal that will be addressed after the next release

Comments

@BhargaviAnnadevara
Copy link

BhargaviAnnadevara commented Mar 29, 2024

Is there an existing issue for this?

  • I have searched the existing issues

Code of Conduct

  • I agree to follow this project's Code of Conduct

Question

I've seen some issues opened and closed in this GitHub repo discussing RTL features for different victory charts and components, but without any concrete conclusion. I want to know whether victory/victory-native libraries support rendering charts in right-to-left layout out of the box, without having to perform any customizations to handle them on the implementation front. Please clarify.

@BhargaviAnnadevara BhargaviAnnadevara added the Type: Question ❔ Asking a question or asking for help label Mar 29, 2024
@BhargaviAnnadevara
Copy link
Author

BhargaviAnnadevara commented Mar 29, 2024

@carbonrobot
Copy link
Contributor

Hi @bhargaviannadevara-msft there is currently no official RTL support in either library. We would be happy for any community contributions to make that work.

@carbonrobot carbonrobot added Type: Enhancement ✏️ An enhancement or feature proposal that will be addressed after the next release Issue: Accepted The submitted issue has been confirmed by the Victory core team and removed Type: Question ❔ Asking a question or asking for help labels Apr 1, 2024
@BhargaviAnnadevara
Copy link
Author

BhargaviAnnadevara commented Apr 3, 2024

@carbonrobot Until the required support is added, can you please suggest workarounds that may help?

For example, I found that using the orientation and invertAxis props help with customizing the layout when rendering in RTL mode, but flipping legend has been tricky, and I haven't had much luck with altering any of its default props or applying CSS styles (flexDirection/transform). Even if it worked, I might be able to only reverse the order of the legend labels, but not its symbols. Any thoughts?

Also, noticed that switching to Arabic changes the axis tick values accordingly, but not the legend text. Why is that?

@carbonrobot
Copy link
Contributor

There is no current workaround for RTL. In order to correctly position text in an SVG element, we must first measure the size of the text. This is done by using character widths that are presized in a file since SVG does not offer a way to measure itself until after rendering. Since these widths must be predetermined, they need to be hardcoded into the source code, so the only fonts that are supported are the ones inside that file.

Ideally, now that canvas has more universal support, we could rewrite our code to render to a hidden canvas element and measure the text there before rendering. This could potentially alleviate the need to store precomputed fonts and allow us to support any font with LTR and RTL.

At this time, I don't have anyone on the core team with capacity to tackle this change, however.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Issue: Accepted The submitted issue has been confirmed by the Victory core team Type: Enhancement ✏️ An enhancement or feature proposal that will be addressed after the next release
Projects
None yet
Development

No branches or pull requests

2 participants