davidgohel / ggiraph

make 'ggplot' graphics interactive

Home Page:https://davidgohel.github.io/ggiraph

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Responsive sizing of text elements

z3tt opened this issue · comments

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!

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.

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.

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 :)

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.