diff --git a/DESCRIPTION b/DESCRIPTION index 4a3672959a6a334ccddc90403962444e634e0ef9..f638530385f9bae926c19a84178566a95468b3c0 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -21,9 +21,9 @@ Imports: rmarkdown, stringr, glue, - ymlthis, - switchr + ymlthis Suggests: + switchr, highcharter, plotly, crosstalk, diff --git a/R/vis_objects.R b/R/vis_objects.R index 5cc39170a02e14cdec254e43a32f273f6f35d686..3f2c2449f7c0ecf6c30ddf19a6e8522e8a71b2e1 100644 --- a/R/vis_objects.R +++ b/R/vis_objects.R @@ -64,14 +64,20 @@ setMethod("add_component", setMethod("add_component", signature = signature(dashboard = "i2dashboard", component = "ANY"), definition = function(dashboard, component, page = "default", title = NULL, ...) { - if(!inherits(component, "htmlwidget")) { - warning("The object has to inherit from the class 'htmlwidget'.") - return(dashboard) - } - package <- packageSlot(component) - if(is.null(package)) { - warning("The package name of this HTML widget could not be determined. The component was not added to the dashboard.") - return(dashboard) + + # HTMLWIDGETS + if(inherits(component, "htmlwidget")) { + package <- packageSlot(component) + + if(is.null(package)) { + warning("No component added, since the package name of the HTML widget could not be determined.") + return(dashboard) + } + + return(add_vis_object(dashboard, component, package, page, title, ...)) } - add_vis_object(dashboard, component, package, page, title, ...) + + # OTHER + warning("The component did not inherit from any of the currently supported classes ('htmlwidget').") + return(dashboard) })