trelliscopejs icon indicating copy to clipboard operation
trelliscopejs copied to clipboard

Creating panels with various widgets, sometimes not all of them render

Open struckma opened this issue 1 year ago • 5 comments

Dear Ryan, dear Barret, dear developers of trelliscopejs,

great package, your trelliscopejs, thank you for the great idea. I've played around with it a bit, and I found

https://github.com/hafen/trelliscopejs/blob/e0805c98db6b9af913e49fa264b4ebb943e430c0/R/trelliscope.R#L198

where you exemplarily choose the first panel to define the html dependencies for a trelliscope page. However, if I use other widgets on the other panels, they won't show up, because they are missing their dependencies.

As a work-around, I could add a first dummy panel with all possible widgets on it, then everything works. I would try to fix the problem soundly by including all dependencies instead of only those for the first panel's widget, if you are interested -- I have already some prototyping work-around, but I would prefer to provide a sound fix.

Thank you,

Stephan

Code to reproduce using (trelliscopejs 0.2.6 with R version 4.3.2 (2023-10-31)):

library(tibble)
library(plotly)
library(dygraphs)
library(trelliscopejs)
library(htmltools)

tib <- tibble(.rows = 3)
tib <- tibble::add_column(tib, group = as.character(1:3))
tib <- tibble::add_column(tib,
                          result =
                            map_plot(1:3, function(i) {
                                if (i %in% c(1, 3)) {
                                  dyRangeSelector(
                                    dygraph(nhtemp, main = "New Haven Temperatures"),
                                    dateWindow = c("1920-01-01", "1960-01-01"))
                                } else {
                                  plotly::plot_ly()
                                }
                            })
)

trelliscope(tib, name = "wont render the plotly")

tib <- tibble(.rows = 3)
tib <- tibble::add_column(tib, group = as.character(1:3))
tib <- tibble::add_column(tib,
                          result =
                            map_plot(1:3, function(i) {
                              if (i %in% c(2)) {
                                dyRangeSelector(
                                  dygraph(nhtemp, main = "New Haven Temperatures"),
                                  dateWindow = c("1920-01-01", "1960-01-01"))
                              } else {
                                plotly::plot_ly()
                              }
                            })
)

trelliscope(tib, name = "wont render the dygraph")

tib <- tibble(.rows = 3)
tib <- tibble::add_column(tib, group = as.character(1:3))
tib <- tibble::add_column(tib,
                          result =
                            map_plot(1:3, function(i) {
                              dygraph(nhtemp, main = "New Haven Temperatures")
                            })
)


trelliscope(tib, name = "renders as expected")

tib <- tibble(.rows = 3)
tib <- tibble::add_column(tib, group = as.character(1:3))
tib <- tibble::add_column(tib,
                          result =
                            map_plot(1:3, function(i) {
                              plotly::plot_ly()
                            })
)

trelliscope(tib, name = "renders as expected")


tib <- tibble(.rows = 3)
tib <- tibble::add_column(tib, group = as.character(1:3))
tib <- tibble::add_column(tib,
                          result =
                            map_plot(1:3, function(i) {
                              if (i %in% c(1, 3)) {
                                dygraph(nhtemp, main = "New Haven Temperatures")
                              } else {
                                plotly::plot_ly()
                              }
                            })
)

struckma avatar Jan 23 '24 14:01 struckma