hafen / trelliscopejs

TrelliscopeJS R Package
https://hafen.github.io/trelliscopejs
Other
263 stars 36 forks source link

no content when self_contained = TRUE, as_plotly = TRUE #35

Closed dennet closed 6 years ago

dennet commented 7 years ago
library(trelliscopejs)
library(ggplot2)
library(plotly)
library(gapminder)

# this works 
qplot(year, lifeExp, data = gapminder) +
    xlim(1948, 2011) + ylim(10, 95) + theme_bw() +
    facet_trelliscope(~ country + continent,
                      nrow = 2, ncol = 6, width = 300, self_contained = FALSE, as_plotly = TRUE)

# this works 
qplot(year, lifeExp, data = gapminder) +
    xlim(1948, 2011) + ylim(10, 95) + theme_bw() +
    facet_trelliscope(~ country + continent,
                      nrow = 2, ncol = 6, width = 300, self_contained = TRUE, as_plotly = FALSE)

# this doestn't work (no charts inside the panels)
qplot(year, lifeExp, data = gapminder) +
    xlim(1948, 2011) + ylim(10, 95) + theme_bw() +
    facet_trelliscope(~ country + continent,
                      nrow = 2, ncol = 6, width = 300, self_contained = TRUE, as_plotly = TRUE)
hafen commented 7 years ago

Interesting. Thanks for the report. I am looking into this.

vikram-rawat commented 6 years ago

I couldn't find a way to insert plotly commands in Trelliscope. Example

qplot(year, lifeExp, data = gapminder) +
    xlim(1948, 2011) + ylim(10, 95) + theme_bw() +
    facet_trelliscope(~ country + continent, nrow = 2, ncol = 7,
                      width = 300,as_plotly = TRUE
                      ) 

I actually want to remove the Barmode of plotly interface. with like

p %>% config(displayModeBar = F)

Here P is the actuall plot_ly Plot. How can I do it. Please let me know...

hafen commented 6 years ago

Good question. This was not possible to specify through the facet_trelliscope() interface (although you have complete freedom to specify whatever plot you would like if you use the trelliscope() interface). I added a new parameter plotly_cfg to facet_trelliscope() that will allow you to provide a named list of config settings you would usually send to config(). So if you install the latest version, then you can do the following:

library(trelliscopejs)
library(plotly)
library(gapminder)
qplot(year, lifeExp, data = gapminder) +
  xlim(1948, 2011) + ylim(10, 95) + theme_bw() +
  facet_trelliscope(~ country + continent, nrow = 2, ncol = 7,
    width = 300, as_plotly = TRUE,
    plotly_cfg = list(displayModeBar = FALSE))