dreamRs / esquisse

RStudio add-in to make plots interactively with ggplot2
https://dreamrs.github.io/esquisse
Other
1.77k stars 229 forks source link

Dynamically render module ui from the server #101

Closed shahreyar-abeer closed 2 years ago

shahreyar-abeer commented 4 years ago

Hi guys,

I'm trying to render the esquisseUI dynamically from the server. Here is a simple version of my app that's not working.

library(shiny)
library(esquisse)

ui = fluidPage(
  uiOutput("esquisse")
  ## this works
  #esquisserUI("input") 
)

server = function(input, output){
  data = reactiveValues(data = mtcars, name = "mtcars")
  output$esquisse = renderUI({
    esquisserUI("input")
  })
  callModule(esquisserServer, id = "input", data = data)
}
shinyApp(ui, server)

The error returned is Warning: Error in if: argument is of length zero [No stack trace available]

I think the esquisseUI is not getting rendered.

Looking forward to getting a solution from you guys. Thanks in advance. Best regards, Zauad Shahreer

pvictor commented 4 years ago

Hello, Not sure that's possible, what's your use-case ?

Victor

shahreyar-abeer commented 4 years ago

I'm trying to use it in an app, where it should reload every time the user uploads a data. The data upload is done independently in the app rather than from within the esquisserUI.

pvictor commented 4 years ago

Ok, but you can update the reactiveValues passed to the server module, I don't think there's a need to regenerate the whole UI, see example in ?esquisserUI.

shahreyar-abeer commented 4 years ago

I have tried that. Let me tell what the problem is.

Suppose I upload a data set and give the plot a title. Now when I upload a different data set, the title should be blank, but instead it keeps the previous title that I had typed in the title field. Please give it a try.

pvictor commented 4 years ago

Ok thanks for the feedback, I think we should reset inputs when data change, it will solve your issue and be better. I'll look into it

pvictor commented 4 years ago

Ok, labs input (title, subtitle, axis, ...) are now reseted when data are changed. Have you spoted other problems ?

shahreyar-abeer commented 4 years ago

Okay thanks! There is another issue though, I'll talk about it later Inn Shaa Allah. I see you guys are looking for an R developer. Do I qualify to apply for the position?

dawiegriesel commented 3 years ago

I'm having the same issue with renderUI(esquisserUI("input")).

My use case is slightly different as I'm using tabsetPannel to rout traffic to parts of my app i.e. url/?tab=esquisse.

The url is called via iframe from a .Net app and due to the size of the application I'm avoiding the whole app's html to render to the client on each call. I have managed to speed up the system significantly using this approach but esquisse module is not working. Any reason why this is the case?