Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
  • loosolab/software/i2dash
1 result
Show changes
Commits on Source (7)
...@@ -23,8 +23,10 @@ Imports: ...@@ -23,8 +23,10 @@ Imports:
glue, glue,
ymlthis ymlthis
Suggests: Suggests:
switchr,
highcharter, highcharter,
plotly, plotly,
crosstalk,
gt, gt,
ggplot2, ggplot2,
DT, DT,
......
...@@ -24,7 +24,7 @@ setMethod("assemble", "i2dashboard", function(dashboard, pages = names(dashboard ...@@ -24,7 +24,7 @@ setMethod("assemble", "i2dashboard", function(dashboard, pages = names(dashboard
ymlthis::yml(date = F) %>% ymlthis::yml(date = F) %>%
ymlthis::yml_title(dashboard@title) %>% ymlthis::yml_title(dashboard@title) %>%
ymlthis::yml_author(dashboard@author) %>% ymlthis::yml_author(dashboard@author) %>%
ymlthis::yml_output(flexdashboard::flex_dashboard(theme = dashboard@theme)) %>% ymlthis::yml_output(flexdashboard::flex_dashboard(theme = !!dashboard@theme)) %>%
{if(dashboard@interactive) ymlthis::yml_runtime(., runtime = "shiny") else .} %>% {if(dashboard@interactive) ymlthis::yml_runtime(., runtime = "shiny") else .} %>%
ymlthis::use_rmarkdown(path = tmp_document, include_body = FALSE, quiet = TRUE, open_doc = FALSE) ymlthis::use_rmarkdown(path = tmp_document, include_body = FALSE, quiet = TRUE, open_doc = FALSE)
......
...@@ -59,7 +59,7 @@ setMethod("add_component", ...@@ -59,7 +59,7 @@ setMethod("add_component",
}) })
setMethod("add_component", signature(dashboard = "i2dashboard", component = "function"), setMethod("add_component", signature(dashboard = "i2dashboard", component = "function"),
function(dashboard, component, page = "default", title = NULL, ...) { function(dashboard, component, page = "default", ...) {
# validate "page" input # validate "page" input
name <- .create_page_name(page) name <- .create_page_name(page)
if (!(name %in% names(dashboard@pages))) { if (!(name %in% names(dashboard@pages))) {
......
...@@ -29,7 +29,7 @@ add_vis_object <- function(dashboard, object, package, page = "default", title = ...@@ -29,7 +29,7 @@ add_vis_object <- function(dashboard, object, package, page = "default", title =
delim = c("<%", "%>"), delim = c("<%", "%>"),
title = title, title = title,
package = package, package = package,
class = class(object), class = is(object),
component_id = component_id, component_id = component_id,
timestamp = timestamp) timestamp = timestamp)
...@@ -42,61 +42,42 @@ add_vis_object <- function(dashboard, object, package, page = "default", title = ...@@ -42,61 +42,42 @@ add_vis_object <- function(dashboard, object, package, page = "default", title =
# Methods to add common visualization objects # Methods to add common visualization objects
# #
setMethod("add_component", setMethod("add_component",
signature = signature(dashboard = "i2dashboard", component = "highchart"), signature = signature(dashboard = "i2dashboard", component = "gg"),
definition = function(dashboard, component, page = "default", title = NULL, ...) { definition = function(dashboard, component, page = "default", title = NULL, ...) {
add_vis_object(dashboard, component, "highcharter", page, title, ...) }) add_vis_object(dashboard, component, "ggplot2", page, title, ...) })
setMethod("add_component", setMethod("add_component",
signature = signature(dashboard = "i2dashboard", component = "plotly"), signature = signature(dashboard = "i2dashboard", component = "gt_tbl"),
definition = function(dashboard, component, page = "default", title = NULL, ...) { definition = function(dashboard, component, page = "default", title = NULL, ...) {
add_vis_object(dashboard, component, "plotly", page, title, ...) }) add_vis_object(dashboard, component,"gt", page, title, ...) })
setMethod("add_component", setMethod("add_component",
signature = signature(dashboard = "i2dashboard", component = "leaflet"), signature = signature(dashboard = "i2dashboard", component = "knitr_kable"),
definition = function(dashboard, component, page = "default", title = NULL, ...) { definition = function(dashboard, component, page = "default", title = NULL, ...) {
add_vis_object(dashboard, component, "leaflet", page, title, ...) }) add_vis_object(dashboard, component, "kableExtra", page, title, ...) })
setMethod("add_component", setMethod("add_component",
signature = signature(dashboard = "i2dashboard", component = "dygraphs"), signature = signature(dashboard = "i2dashboard", component = "Heatmap"),
definition = function(dashboard, component, page = "default", title = NULL, ...) { definition = function(dashboard, component, page = "default", title = NULL, ...) {
add_vis_object(dashboard, component, "dygraphs", page, title, ...) }) add_vis_object(dashboard, component, "ComplexHeatmap", page, title, ...) })
setMethod("add_component", setMethod("add_component",
signature = signature(dashboard = "i2dashboard", component = "rbokeh"), signature = signature(dashboard = "i2dashboard", component = "ANY"),
definition = function(dashboard, component, page = "default", title = NULL, ...) { definition = function(dashboard, component, page = "default", title = NULL, ...) {
add_vis_object(dashboard, component, "rbokeh", page, title, ...) })
setMethod("add_component", # HTMLWIDGETS
signature = signature(dashboard = "i2dashboard", component = "visNetwork"), if(inherits(component, "htmlwidget")) {
definition = function(dashboard, component, page = "default", title = NULL, ...) { package <- packageSlot(component)
add_vis_object(dashboard, component, "visNetwork", page, title, ...) })
setMethod("add_component", if(is.null(package)) {
signature = signature(dashboard = "i2dashboard", component = "d3heatmap"), warning("No component added, since the package name of the HTML widget could not be determined.")
definition = function(dashboard, component, page = "default", title = NULL, ...) { return(dashboard)
add_vis_object(dashboard, component, "d3heatmap", page, title, ...) }) }
setMethod("add_component", return(add_vis_object(dashboard, component, package, page, title, ...))
signature = signature(dashboard = "i2dashboard", component = "metricsgraphics"), }
definition = function(dashboard, component, page = "default", title = NULL, ...) {
add_vis_object(dashboard, component, "metricsgraphics", page, title, ...) })
setMethod("add_component", # OTHER
signature = signature(dashboard = "i2dashboard", component = "gg"), warning("The component did not inherit from any of the currently supported classes ('htmlwidget').")
definition = function(dashboard, component, page = "default", title = NULL, ...) { return(dashboard)
add_vis_object(dashboard, component, "ggplot2", page, title, ...) }) })
setMethod("add_component",
signature = signature(dashboard = "i2dashboard", component = "datatables"),
definition = function(dashboard, component, page = "default", title = NULL, ...) {
add_vis_object(dashboard, component, "DT", page, title, ...) })
setMethod("add_component",
signature = signature(dashboard = "i2dashboard", component = "grViz"),
definition = function(dashboard, component, page = "default", title = NULL, ...) {
add_vis_object(dashboard, component, "DiagrammeR", page, title, ...) })
setMethod("add_component",
signature = signature(dashboard = "i2dashboard", component = "gt_tbl"),
definition = function(dashboard, component, page = "default", title = NULL, ...) {
add_vis_object(dashboard, component, "gt", page, title, ...) })
...@@ -4,10 +4,23 @@ ...@@ -4,10 +4,23 @@
```{r} ```{r}
if (!requireNamespace("<% package %>", quietly = TRUE)) { if (!requireNamespace("<% package %>", quietly = TRUE)) {
stop('The package <% package %> is needed to embed objects of class <% class %>.', call. = FALSE) stop('The package "<% package %>" is needed to embed objects of class "<% class %>".', call. = FALSE)
} }
readRDS(file.path(datadir, '<% component_id %>.rds')) vis_<% component_id %> <- readRDS(file.path(datadir, '<% component_id %>.rds'))
# workaround for plotly dependencies issue (https://github.com/ropensci/plotly/issues/1044)
#
fix_dependency <- function(dependency){
if(dependency$name == "jquery") dependency$src$file <- file.path(system.file(package ="crosstalk"), "lib/jquery")
if(dependency$name == "crosstalk") dependency$src$file <- file.path(system.file(package ="crosstalk"), "www")
return(dependency)
}
if ("<% package %>" == "plotly"){
vis_<% component_id %>$dependencies <- lapply(vis_<% component_id %>$dependencies, fix_dependency)
}
vis_<% component_id %>
``` ```