Skip to content
Snippets Groups Projects

Generic htm lwidget

Merged arsenij.ustjanzew requested to merge genericHTMLwidget into master
4 files
+ 31
50
Compare changes
  • Side-by-side
  • Inline
Files
4
+ 20
47
@@ -5,7 +5,7 @@
#' @param package The name of the R package that defines the class(object).
#' @param page The name of the page to add the object to.
#' @param title An optional component title.
add_vis_object <- function(dashboard, object, package, page = "default", title = NULL, ...){
add_vis_object <- function(dashboard, object, package = NULL, page = "default", title = NULL, ...){
sanitised_page <- i2dash:::.create_page_name(page)
if (!(sanitised_page %in% names(dashboard@pages))) {
warning(sprintf("i2dashboard does not contain a page named '%s'", sanitised_page))
@@ -17,6 +17,8 @@ add_vis_object <- function(dashboard, object, package, page = "default", title =
return(dashboard)
}
if(is.null(package)) package <- "unknown package name"
# Create random component for RDS filename
component_id <- paste0("obj_", stringi::stri_rand_strings(1, 6))
@@ -29,7 +31,7 @@ add_vis_object <- function(dashboard, object, package, page = "default", title =
delim = c("<%", "%>"),
title = title,
package = package,
class = class(object),
class = is(object),
component_id = component_id,
timestamp = timestamp)
@@ -42,61 +44,32 @@ add_vis_object <- function(dashboard, object, package, page = "default", title =
# Methods to add common visualization objects
#
setMethod("add_component",
signature = signature(dashboard = "i2dashboard", component = "highchart"),
definition = function(dashboard, component, page = "default", title = NULL, ...) {
add_vis_object(dashboard, component, "highcharter", page, title, ...) })
setMethod("add_component",
signature = signature(dashboard = "i2dashboard", component = "plotly"),
definition = function(dashboard, component, page = "default", title = NULL, ...) {
add_vis_object(dashboard, component, "plotly", page, title, ...) })
setMethod("add_component",
signature = signature(dashboard = "i2dashboard", component = "leaflet"),
definition = function(dashboard, component, page = "default", title = NULL, ...) {
add_vis_object(dashboard, component, "leaflet", page, title, ...) })
setMethod("add_component",
signature = signature(dashboard = "i2dashboard", component = "dygraphs"),
definition = function(dashboard, component, page = "default", title = NULL, ...) {
add_vis_object(dashboard, component, "dygraphs", page, title, ...) })
setMethod("add_component",
signature = signature(dashboard = "i2dashboard", component = "rbokeh"),
definition = function(dashboard, component, page = "default", title = NULL, ...) {
add_vis_object(dashboard, component, "rbokeh", page, title, ...) })
setMethod("add_component",
signature = signature(dashboard = "i2dashboard", component = "visNetwork"),
definition = function(dashboard, component, page = "default", title = NULL, ...) {
add_vis_object(dashboard, component, "visNetwork", page, title, ...) })
setMethod("add_component",
signature = signature(dashboard = "i2dashboard", component = "d3heatmap"),
definition = function(dashboard, component, page = "default", title = NULL, ...) {
add_vis_object(dashboard, component, "d3heatmap", page, title, ...) })
setMethod("add_component",
signature = signature(dashboard = "i2dashboard", component = "metricsgraphics"),
signature = signature(dashboard = "i2dashboard", component = "gg"),
definition = function(dashboard, component, page = "default", title = NULL, ...) {
add_vis_object(dashboard, component, "metricsgraphics", page, title, ...) })
add_vis_object(dashboard, component, "ggplot2", page, title, ...) })
setMethod("add_component",
signature = signature(dashboard = "i2dashboard", component = "gg"),
signature = signature(dashboard = "i2dashboard", component = "gt_tbl"),
definition = function(dashboard, component, page = "default", title = NULL, ...) {
add_vis_object(dashboard, component, "ggplot2", page, title, ...) })
add_vis_object(dashboard, component,"gt", page, title, ...) })
setMethod("add_component",
signature = signature(dashboard = "i2dashboard", component = "datatables"),
signature = signature(dashboard = "i2dashboard", component = "knitr_kable"),
definition = function(dashboard, component, page = "default", title = NULL, ...) {
add_vis_object(dashboard, component, "DT", page, title, ...) })
add_vis_object(dashboard, component, "kableExtra", page, title, ...) })
setMethod("add_component",
signature = signature(dashboard = "i2dashboard", component = "grViz"),
signature = signature(dashboard = "i2dashboard", component = "Heatmap"),
definition = function(dashboard, component, page = "default", title = NULL, ...) {
add_vis_object(dashboard, component, "DiagrammeR", page, title, ...) })
add_vis_object(dashboard, component, "ComplexHeatmap", page, title, ...) })
setMethod("add_component",
signature = signature(dashboard = "i2dashboard", component = "gt_tbl"),
signature = signature(dashboard = "i2dashboard", component = "ANY"),
definition = function(dashboard, component, page = "default", title = NULL, ...) {
add_vis_object(dashboard, component, "gt", page, title, ...) })
if(!inherits(component, "htmlwidget")) {
warning("The object has to inherit from the class 'htmlwidget'.")
return(dashboard)
}
package <- packageSlot(component)
add_vis_object(dashboard, component, package, page, title, ...)
})
Loading