Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
i2dash
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
loosolab
software
i2dash
Commits
890c8657
Commit
890c8657
authored
5 years ago
by
arsenij.ustjanzew
Browse files
Options
Downloads
Patches
Plain Diff
Implemented general Method for htmlwidgets. removed Methods for single widgets.
parent
e73ce010
No related branches found
No related tags found
1 merge request
!18
Generic htm lwidget
Pipeline
#129868
canceled
5 years ago
Stage: build
Stage: check
Changes
4
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
DESCRIPTION
+2
-1
2 additions, 1 deletion
DESCRIPTION
R/vis_objects.R
+20
-47
20 additions, 47 deletions
R/vis_objects.R
inst/templates/vis_object.Rmd
+1
-1
1 addition, 1 deletion
inst/templates/vis_object.Rmd
man/add_vis_object.Rd
+8
-1
8 additions, 1 deletion
man/add_vis_object.Rd
with
31 additions
and
50 deletions
DESCRIPTION
+
2
−
1
View file @
890c8657
...
@@ -21,7 +21,8 @@ Imports:
...
@@ -21,7 +21,8 @@ Imports:
rmarkdown,
rmarkdown,
stringr,
stringr,
glue,
glue,
ymlthis
ymlthis,
switchr
Suggests:
Suggests:
highcharter,
highcharter,
plotly,
plotly,
...
...
This diff is collapsed.
Click to expand it.
R/vis_objects.R
+
20
−
47
View file @
890c8657
...
@@ -5,7 +5,7 @@
...
@@ -5,7 +5,7 @@
#' @param package The name of the R package that defines the class(object).
#' @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 page The name of the page to add the object to.
#' @param title An optional component title.
#' @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
)
sanitised_page
<-
i2dash
:::
.create_page_name
(
page
)
if
(
!
(
sanitised_page
%in%
names
(
dashboard
@
pages
)))
{
if
(
!
(
sanitised_page
%in%
names
(
dashboard
@
pages
)))
{
warning
(
sprintf
(
"i2dashboard does not contain a page named '%s'"
,
sanitised_page
))
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 =
...
@@ -17,6 +17,8 @@ add_vis_object <- function(dashboard, object, package, page = "default", title =
return
(
dashboard
)
return
(
dashboard
)
}
}
if
(
is.null
(
package
))
package
<-
"unknown package name"
# Create random component for RDS filename
# Create random component for RDS filename
component_id
<-
paste0
(
"obj_"
,
stringi
::
stri_rand_strings
(
1
,
6
))
component_id
<-
paste0
(
"obj_"
,
stringi
::
stri_rand_strings
(
1
,
6
))
...
@@ -29,7 +31,7 @@ add_vis_object <- function(dashboard, object, package, page = "default", title =
...
@@ -29,7 +31,7 @@ add_vis_object <- function(dashboard, object, package, page = "default", title =
delim
=
c
(
"<%"
,
"%>"
),
delim
=
c
(
"<%"
,
"%>"
),
title
=
title
,
title
=
title
,
package
=
package
,
package
=
package
,
class
=
clas
s
(
object
),
class
=
i
s
(
object
),
component_id
=
component_id
,
component_id
=
component_id
,
timestamp
=
timestamp
)
timestamp
=
timestamp
)
...
@@ -42,61 +44,32 @@ add_vis_object <- function(dashboard, object, package, page = "default", title =
...
@@ -42,61 +44,32 @@ 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
,
...
)
{
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"
),
definition
=
function
(
dashboard
,
component
,
page
=
"default"
,
title
=
NULL
,
...
)
{
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"
,
setMethod
(
"add_component"
,
signature
=
signature
(
dashboard
=
"i2dashboard"
,
component
=
"g
g
"
),
signature
=
signature
(
dashboard
=
"i2dashboard"
,
component
=
"g
t_tbl
"
),
definition
=
function
(
dashboard
,
component
,
page
=
"default"
,
title
=
NULL
,
...
)
{
definition
=
function
(
dashboard
,
component
,
page
=
"default"
,
title
=
NULL
,
...
)
{
add_vis_object
(
dashboard
,
component
,
"g
gplot2
"
,
page
,
title
,
...
)
})
add_vis_object
(
dashboard
,
component
,
"g
t
"
,
page
,
title
,
...
)
})
setMethod
(
"add_component"
,
setMethod
(
"add_component"
,
signature
=
signature
(
dashboard
=
"i2dashboard"
,
component
=
"
datat
able
s
"
),
signature
=
signature
(
dashboard
=
"i2dashboard"
,
component
=
"
knitr_k
able"
),
definition
=
function
(
dashboard
,
component
,
page
=
"default"
,
title
=
NULL
,
...
)
{
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"
,
setMethod
(
"add_component"
,
signature
=
signature
(
dashboard
=
"i2dashboard"
,
component
=
"
grViz
"
),
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
,
"
DiagrammeR
"
,
page
,
title
,
...
)
})
add_vis_object
(
dashboard
,
component
,
"
ComplexHeatmap
"
,
page
,
title
,
...
)
})
setMethod
(
"add_component"
,
setMethod
(
"add_component"
,
signature
=
signature
(
dashboard
=
"i2dashboard"
,
component
=
"
gt_tbl
"
),
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
,
"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
,
...
)
})
This diff is collapsed.
Click to expand it.
inst/templates/vis_object.Rmd
+
1
−
1
View file @
890c8657
...
@@ -4,7 +4,7 @@
...
@@ -4,7 +4,7 @@
```{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)
}
}
vis_<% component_id %> <- readRDS(file.path(datadir, '<% component_id %>.rds'))
vis_<% component_id %> <- readRDS(file.path(datadir, '<% component_id %>.rds'))
...
...
This diff is collapsed.
Click to expand it.
man/add_vis_object.Rd
+
8
−
1
View file @
890c8657
...
@@ -4,7 +4,14 @@
...
@@ -4,7 +4,14 @@
\alias{add_vis_object}
\alias{add_vis_object}
\title{General method to add an object as component to a page of an i2dashboard.}
\title{General method to add an object as component to a page of an i2dashboard.}
\usage{
\usage{
add_vis_object(dashboard, object, package, page = "default", title = NULL, ...)
add_vis_object(
dashboard,
object,
package = NULL,
page = "default",
title = NULL,
...
)
}
}
\arguments{
\arguments{
\item{dashboard}{The \linkS4class{i2dash::i2dashboard}.}
\item{dashboard}{The \linkS4class{i2dash::i2dashboard}.}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment