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
8d39ad0f
Verified
Commit
8d39ad0f
authored
5 years ago
by
jens.preussner
Browse files
Options
Downloads
Patches
Plain Diff
Moved sidebar template; Fixed bug in vis_object
parent
1c4695be
Branches
Branches containing commit
No related tags found
No related merge requests found
Pipeline
#109677
passed
5 years ago
Stage: build
Stage: check
Changes
4
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
R/assemble.R
+1
-1
1 addition, 1 deletion
R/assemble.R
R/vis_objects.R
+28
-28
28 additions, 28 deletions
R/vis_objects.R
inst/templates/local_sidebar.Rmd
+0
-0
0 additions, 0 deletions
inst/templates/local_sidebar.Rmd
man/add_vis_object.Rd
+23
-0
23 additions, 0 deletions
man/add_vis_object.Rd
with
52 additions
and
29 deletions
R/assemble.R
+
1
−
1
View file @
8d39ad0f
...
...
@@ -80,7 +80,7 @@ setMethod("assemble", "i2dashboard", function(dashboard, pages = names(dashboard
#' @return A markdown string with the final page.
.render_page
<-
function
(
title
,
components
,
layout
=
c
(
"default"
,
"storyboard"
,
"focal_left"
,
"2x2_grid"
),
menu
=
NULL
,
sidebar
=
NULL
)
{
if
(
!
is.null
(
sidebar
))
{
sidebar
<-
knitr
::
knit_expand
(
file
=
system.file
(
"templates"
,
"sidebar
_template.Rmd
"
,
package
=
"i2dash"
),
sidebar
<-
knitr
::
knit_expand
(
file
=
system.file
(
"templates"
,
"
local_
sidebar"
,
package
=
"i2dash"
),
delim
=
c
(
"<%"
,
"%>"
),
content
=
sidebar
,
datawidth
=
250
)
}
...
...
This diff is collapsed.
Click to expand it.
R/vis_objects.R
+
28
−
28
View file @
8d39ad0f
#' General method to add an
dashboard
as component
s of
a page of an i2dashboard.
#' General method to add an
object
as component
to
a page of an i2dashboard.
#'
#' @param
report
The \linkS4class{i2dash::i2dashboard}.
#' @param
dashboard
The R visualization
dashboard
to be addedd.
#' @param package The name of the R package that defines the class(
dashboard
).
#' @param page The name of the page to add the
dashboard
to.
#' @param
dashboard
The \linkS4class{i2dash::i2dashboard}.
#' @param
object
The R visualization
object
to be addedd.
#' @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_
dashboard
<-
function
(
report
,
dashboard
,
package
,
page
=
"default"
,
title
=
NULL
,
...
){
add_vis_
object
<-
function
(
dashboard
,
object
,
package
,
page
=
"default"
,
title
=
NULL
,
...
){
sanitised_page
<-
i2dash
:::
.create_page_name
(
page
)
if
(
!
(
sanitised_page
%in%
names
(
report
@
pages
)))
{
warning
(
sprintf
(
"i2dashboard
dashboard
does not contain a page named '%s'"
,
sanitised_page
))
return
(
report
)
if
(
!
(
sanitised_page
%in%
names
(
dashboard
@
pages
)))
{
warning
(
sprintf
(
"i2dashboard does not contain a page named '%s'"
,
sanitised_page
))
return
(
dashboard
)
}
if
(
length
(
report
@
pages
[[
sanitised_page
]]
$
components
)
+
1
>
report
@
pages
[[
sanitised_page
]]
$
max_components
)
{
if
(
length
(
dashboard
@
pages
[[
sanitised_page
]]
$
components
)
+
1
>
dashboard
@
pages
[[
sanitised_page
]]
$
max_components
)
{
warning
(
sprintf
(
"Not enough space left on page '%s'"
,
sanitised_page
))
return
(
report
)
return
(
dashboard
)
}
# Create random component for RDS filename
component_id
<-
paste0
(
"obj_"
,
stringi
::
stri_rand_strings
(
1
,
6
))
# Save plot as RDS
saveRDS
(
dashboard
,
file
=
file.path
(
report
@
datadir
,
paste0
(
component_id
,
".rds"
)))
saveRDS
(
object
,
file
=
file.path
(
dashboard
@
datadir
,
paste0
(
component_id
,
".rds"
)))
# Expand template
timestamp
<-
Sys.time
()
expanded_component
<-
knitr
::
knit_expand
(
file
=
system.file
(
"templates"
,
"vis_
dashboard
.Rmd"
,
package
=
"i2dash"
),
expanded_component
<-
knitr
::
knit_expand
(
file
=
system.file
(
"templates"
,
"vis_
object
.Rmd"
,
package
=
"i2dash"
),
delim
=
c
(
"<%"
,
"%>"
),
title
=
title
,
package
=
package
,
class
=
class
(
dashboard
),
class
=
class
(
object
),
component_id
=
component_id
,
timestamp
=
timestamp
)
# Add component to page
report
@
pages
[[
sanitised_page
]]
$
components
<-
append
(
report
@
pages
[[
sanitised_page
]]
$
components
,
expanded_component
)
return
(
report
)
dashboard
@
pages
[[
sanitised_page
]]
$
components
<-
append
(
dashboard
@
pages
[[
sanitised_page
]]
$
components
,
expanded_component
)
return
(
dashboard
)
}
#
...
...
@@ -44,59 +44,59 @@ add_vis_dashboard <- function(report, dashboard, package, page = "default", titl
setMethod
(
"add_component"
,
signature
=
signature
(
dashboard
=
"i2dashboard"
,
component
=
"highchart"
),
definition
=
function
(
dashboard
,
component
,
page
=
"default"
,
title
=
NULL
,
...
)
{
add_vis_
dashboard
(
dashboard
,
component
,
"highcharter"
,
page
,
title
,
...
)
})
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_
dashboard
(
dashboard
,
component
,
"plotly"
,
page
,
title
,
...
)
})
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_
dashboard
(
dashboard
,
component
,
"leaflet"
,
page
,
title
,
...
)
})
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_
dashboard
(
dashboard
,
component
,
"dygraphs"
,
page
,
title
,
...
)
})
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_
dashboard
(
dashboard
,
component
,
"rbokeh"
,
page
,
title
,
...
)
})
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_
dashboard
(
dashboard
,
component
,
"visNetwork"
,
page
,
title
,
...
)
})
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_
dashboard
(
dashboard
,
component
,
"d3heatmap"
,
page
,
title
,
...
)
})
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
,
...
)
{
add_vis_
dashboard
(
dashboard
,
component
,
"metricsgraphics"
,
page
,
title
,
...
)
})
add_vis_
object
(
dashboard
,
component
,
"metricsgraphics"
,
page
,
title
,
...
)
})
setMethod
(
"add_component"
,
signature
=
signature
(
dashboard
=
"i2dashboard"
,
component
=
"gg"
),
definition
=
function
(
dashboard
,
component
,
page
=
"default"
,
title
=
NULL
,
...
)
{
add_vis_
dashboard
(
dashboard
,
component
,
"ggplot2"
,
page
,
title
,
...
)
})
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_
dashboard
(
dashboard
,
component
,
"DT"
,
page
,
title
,
...
)
})
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_
dashboard
(
dashboard
,
component
,
"diagrammeR"
,
page
,
title
,
...
)
})
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_
dashboard
(
dashboard
,
component
,
"gt"
,
page
,
title
,
...
)
})
add_vis_
object
(
dashboard
,
component
,
"gt"
,
page
,
title
,
...
)
})
This diff is collapsed.
Click to expand it.
inst/templates/sidebar
_template
.Rmd
→
inst/templates/
local_
sidebar.Rmd
+
0
−
0
View file @
8d39ad0f
File moved
This diff is collapsed.
Click to expand it.
man/add_vis_object.Rd
0 → 100644
+
23
−
0
View file @
8d39ad0f
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/vis_objects.R
\name{add_vis_object}
\alias{add_vis_object}
\title{General method to add an object as component to a page of an i2dashboard.}
\usage{
add_vis_object(dashboard, object, package, page = "default",
title = NULL, ...)
}
\arguments{
\item{dashboard}{The \linkS4class{i2dash::i2dashboard}.}
\item{object}{The R visualization object to be addedd.}
\item{package}{The name of the R package that defines the class(object).}
\item{page}{The name of the page to add the object to.}
\item{title}{An optional component title.}
}
\description{
General method to add an object as component to a page of an 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