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

plotly charts not always (re)scaling with browser size #341

Open
mattapel opened this issue Apr 6, 2023 · 3 comments
Open

plotly charts not always (re)scaling with browser size #341

mattapel opened this issue Apr 6, 2023 · 3 comments
Labels
bug Something isn't working

Comments

@mattapel
Copy link

mattapel commented Apr 6, 2023

Such a great package! Thanks a lot for this.

I have an issue that does not seem to occur for any obviuous reason: plotly charts inside boxes SOMETIMES won't (re)scale according to the size of the browser window (using chrome). Instead they are rendered in size according to some preset standards.

I have tried to tweak it with setting plotlyOutput in UI to width and height = "100%", but it won't ensure this issue from occuring. It seems to me, more complicated layouts are more prone to this. Somewhere I read, it could be related to bootstrap. Or am I getting something wrong?

Like this example:

    bs4TabItem(
      tabName = 'panel',
      fluidRow(
               bs4Card(width=12, title='blabla', solidHeader=TRUE, status='gray', collapsible=FALSE,
                       fluidRow(
                         column(width=6,
                          tags$img(src='bla.png', width='100%', height='100%')
                              ),
                         column(width=6,
                          plotlyOutput(outputId='bla', width='100%', height='100%')
                 )
          )
        ) #close card
    ))
@DivadNojnarg
Copy link
Member

Hi,

thanks for the feedback. This is a known issue which happens for many htmlwidgets (including plotly). See #262, #254, ...

Some work has been done in the {bslib} package to overcome this issue: https://rstudio.github.io/bslib/articles/cards.html#responsive-sizing. When I have some time, I'll check what they did in the code and why it's not working all the time in bs4Dash (my guess would be a timing issue with animations).

@mattapel
Copy link
Author

Hi
thank you for your quick reply. I thought that maximizing to full screen issue is systematic, because it never worked when I tried (some months ago). Whereas the sizing within a box usually works, just not always.

Would be really great if this could be resolved. It's the first time and sort of a test baloon we use R/Shiny, thus having most of the development done outside the IT department...
Kind regards!

@swsoyee
Copy link

swsoyee commented Aug 3, 2023

Hi, @DivadNojnarg ,
Have you considered adding an event handler at the maximize button so that we could observer it if maximize is clicked and using resize() function provided by htmlwidgets libraries.

observeEvent(input$maximize_clicked, {
    someHtmlWidgets(inputId) |> resize()
  })

@DivadNojnarg DivadNojnarg added the bug Something isn't working label Oct 23, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants