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

Responsive sizing of text elements #297

Open
z3tt opened this issue Jun 12, 2024 · 4 comments
Open

Responsive sizing of text elements #297

z3tt opened this issue Jun 12, 2024 · 4 comments

Comments

@z3tt
Copy link

z3tt commented Jun 12, 2024

Hi David,

Thanks for this wonderful package, I am enjoying it a lot!

Currently, when setting opts_sizing(rescale = TRUE), the font size in the tooltips stays the same, but the text elements of ggplot2 get smaller when decreasing the width of the chart.

I’m not sure if it’s possible, but it would be great to keep the font sizes of ggplot2 text elements consistent when the plot gets resized.

Thanks again!

@davidgohel
Copy link
Owner

hello,

sorry for the delay.

the font size in the tooltips stays the same

I am not sure how it should be done, let's keep this issue open for now

font sizes of ggplot2 text elements consistent when the plot gets resized

That point will not be possible. 'ggiraph' produce a real R graphic (R device) and fonts metrics are calculated when the plot is created by R.

@z3tt
Copy link
Author

z3tt commented Jul 12, 2024

Hey David, no problem and thanks for getting back to this.

I feared that it will not be possible to fix the font sizes, too bad.

For the tooltips, I assume that specifying the font sizes as em or rem and not as pt or px is the way to go? You are the expert here, but at least that's my usual approach outside of ggiraph.

@davidgohel
Copy link
Owner

davidgohel commented Jul 12, 2024

The size of text (and point size) is managed by R itself. But the tooltip is managed with simple CSS independently.

Using 1rem (for example), will be understood as 1rem relative to the web page, I think you'd like to have 1rem relative to:

  • the svg zoom level
  • and an initial fixed size value

Is that right? I think I'm in the process of formalizing the need by trying to formulate it :)

@z3tt
Copy link
Author

z3tt commented Jul 25, 2024

Hm, good question :) Not sure what works best here but sometimes the tooltip text just becomes too large when decreasing the plot size.

In general I think both behaviors might be helpful: tooltip text with a fixed size or relative to the "original" text size. As the text of the plot itself shrinks, I personally would expect the same to happen for the tooltip text by default.

No time to play around with it right now but I'll give it a few more trials.

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