Skip to content

Add multiline support in labels #577

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

Open
rajdivergenceneuro opened this issue Jun 5, 2025 · 1 comment
Open

Add multiline support in labels #577

rajdivergenceneuro opened this issue Jun 5, 2025 · 1 comment

Comments

@rajdivergenceneuro
Copy link
Contributor

Description

Hi team 👋,

First of all, thank you for the amazing work on Victory Native and for the recent updates integrating react-native-skia. The performance improvements and visual quality enhancements are impressive!

I’ve recently updated to the latest version of victory-native which uses react-native-skia, and I noticed that the behavior of labels has changed compared to the older versions. Previously, we were able to create multi-line labels by including \n in the label text, like so:

label="Heart Rate\n(BPM)"

This would render two lines of text in the chart. However, in the new Skia-based version, the \n is not being interpreted as a line break, and the text appears on a single line with the literal \n.

This feature was extremely useful for adding contextual and formatted labels, especially in tight layouts or dual-axis charts.

Would it be possible to update the label rendering logic to support multi-line text using \n again?

Thanks again for the great work on the library and for your time and consideration!

Proposal

Links / References

@lucksp
Copy link

lucksp commented Jun 6, 2025

Example of code that patch had to be applied to work:

<CartesianChart
   xAxis={{
        formatXLabel: (value: number) => formatXAxisLabel(value),
  }}
>...</CartesianChart>

const formatXAxisLabel = (
  value: number,
) => {
  const date = new Date(value);

  return `${date.toLocaleDateString('en-US', {
        weekday: 'short',
        timeZone: 'UTC',
      })}\n${date.getUTCDate()}`; // note the new line break here
}

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

No branches or pull requests

2 participants