-
Notifications
You must be signed in to change notification settings - Fork 74
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
Shiny: ggiraph output object is huge, goes beyond its height, overlaps content below it #83
Comments
Dear Dean,
Can you show me where is that example in the documentation?
Can you run the examples located in The widget is usually sized relative to its container, here the container is a fluidPage and its relative width is 90% (see argument |
I actually found the bug while using a column, I was using a width of 8 but the graph was taking up the entire page height-wise. Only if I go as low as width=4 then it becomes usabale, but then the graph itself is too narrow. |
Note that within RStudio Viewer, the height is correct. When the app pops up into a real browser, the height is disregarded. Something else I noticed is that setting a However, changing the height also changes the width proportionally. Is it not possible to have the width and height set manually and not use the default proportion? This is useful is you need a long or tall plot |
When viewing in Rstudio pane, the container is small and we can hardly see the issue; when viewing in an HTML page, the container is much bigger and you see the graph behaving the same than in Rstudio viewer. In markdown document, that's ok; in shiny applications, there can be unexpected behaviors as you reported. The svg is generated with an R graphical device (as However, this is a workaround, not a solution. Solving that implies a refactoring of sizing policy (initial feeling is that I need to stop using htmlwidgets sizing policies). I am planning to work on that soon (I need to complete few other things on other repositories). |
I tried setting height=50px and in rstudio it actually made it tiny while
in the browser it just ignored the height entirely and it tool my entire
screen. So I'm not sure that's a correct diagnosis.
…On Dec 5, 2017 08:48, "David Gohel" ***@***.***> wrote:
When viewing in Rstudio pane, the container is small and we can hardly see
the issue; when viewing in an HTML page, the container is much bigger and
you see the graph behaving the same than in Rstudio viewer. In markdown
document, that's ok; in shiny applications, there can be unexpected
behaviors as you reported.
The svg is generated with an R graphical device (as pdf or png), hence a
width and a height must be defined first. Then htmlwidget has a sizing
policy different from these settings. Having arguments width_svg >
height_svg may help as it would create a graph with an aspect ratio
greater than 1.
However, this is a workaround, not a solution.
Solving that implies a refactoring of sizing policy (initial feeling is
that I need to stop using htmlwidgets sizing policies). I am planning to
work on that soon (I need to complete few other things on other
repositories).
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#83 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AA6IFCdpNKG2HN2WEiUYLt-FNLtOwPvHks5s9Um6gaJpZM4Q0RZC>
.
|
htmlwidget height is ignored, yes. I will try to solve that soon. |
@davidgohel do you think this will be solved within December? I love the plots and really want to keep them but I need to know if to wait or if to change to a different package for a client |
That's the plan. I am on it right now... I think shiny (standard and flexdashboard) is ok, still struggling with sizes within xaringan. Hopefully tomorrow evening, this will be on gh. |
Awesome, glad to hear!!! So happy I can continue to use this |
If you want to push to a dev branch so that it's not on master while you're still working on it, I'd be happy to test it out from a branch |
I published branch |
I just tried installing from that branch and running the same code as above. There is one improvement, the div that comes after the plot does go below the plot now. But the plot still seems to completely disregard its requested height and width, it still takes up the entire screen. Even if I add |
htmlwidget height and width are ignored in this version. For now, use a workaround like this one:
|
You're right, adding the width to a container does make it respect its width. Thanks for responding so fast and for your work! I think the height is still being ignored though, because: (a) setting only the width works, (b) setting only the height does nothing, (c) setting the height and the width together doesn't change the height. It seems to always just produce a square based on the width, and ignore the height. If I have a bar plot that needs to be wide because there are many bars but it doesn't need to be very tall, it will either be a small square which means it's hard to read the labels, or it will be a huge square if I make it wide enough. But ideally I should be able to have a bar graph that is wide and short, by setting both the width and the height. I'm hoping you have a solution for that too :) |
Have a try with the new commit. It does now respect the About the comment:
The plot is not produced by the javascript (as plotly, dygraphs, rbokeh) and when created, it does not know what are the values of width and height of the HTML container. It is created by an R graphical device and theses are corresponding to classical arguments of R devices {width, height} (i.e pdf, png, svg). You need to play with arguments
|
Ah I understand, so width and height determine the outer bounding box and width_svg and height_svg determines the proportions. I'll have to see how I work with that in a shiny app, where pixels are the working unit rather than inches. Is there a way to specify pixels per inch for the svg? And we don't need to use the outer div to specify width/height, I should only use the |
Exactly, well said.
One inch is 72 pixels or 72 px is 1 inch.
Yes, you can use argument |
Using this shiny app code (the output is taken directly from the documentation)
In the RStudio Viewer it looks fine. But in a browser (I'm using Chrome), the output gets wildly out of control, takes up way too much vertical space, outside of its allotted 500px, and overlaps content below it.
Here is a screenshot (any content below the plot gets swallowed)
This bug unfortunately makes ggiraph effectively unusable in a shiny app currently
ggiraph 0.4.1, shiny 1.0.5
The text was updated successfully, but these errors were encountered: