Skip to content
Snippets Groups Projects
Commit 610a3960 authored by jens.preussner's avatar jens.preussner :ghost:
Browse files

See merge request !7

parents 1e3eaac0 080ebba5
No related branches found
No related tags found
1 merge request!7small fixes
Pipeline #119669 passed
......@@ -10,7 +10,7 @@ Description: Easily build dashboards from individual components in HTML and Shin
License: MIT
Encoding: UTF-8
LazyData: true
RoxygenNote: 6.1.1
RoxygenNote: 7.0.0
Imports:
magrittr,
knitr,
......
#' Method to assemble a dashboard to a Rmd file.
#'
#' @param dashboard A \linkS4class{i2dash::i2dashboard}.
#' @param pages A string or vector with the names of pages, which should be assembled to a report.
#' @param pages A string or vector with the names of pages, which should be assembled to a dashboard.
#' @param file The output filename (recommend that the suffix should be '.Rmd'). This file will be saved in the working directory.
#' @param exclude A string or vector with the names of pages, which should be excluded from report assembly.
#' @param render A logical indicating whether the assembled report should immediately be rendered with \code{rmarkdown::render} or run with \code{rmarkdown::run}.
#' @param exclude A string or vector with the names of pages, which should be excluded from dashboard assembly.
#' @param render A logical indicating whether the assembled dashboard should immediately be rendered with \code{rmarkdown::render} or run with \code{rmarkdown::run}.
#' @param ... Additional arguments passed on to \code{rmarkdown::render}.
#'
#' @rdname i2dashboard-methods
......
......@@ -14,7 +14,7 @@
#'
#' @param dashboard A \linkS4class{i2dash::i2dashboard}.
#' @param page The name of the page to add the component to.
#' @param component The name of a function of a path to a file.
#' @param component The name of a function or a path to a file.
#' @param copy Whether or not to copy images to \code{dashboard@datadir}.
#' @param ... Additional parameters passed to the components render function.
#'
......@@ -83,7 +83,7 @@ setMethod("add_component",
embed_var <- function(x, ...) {
f = tempfile(fileext = '.csv')
write.csv(x, f)
xfun::embed_file(f, text = 'Download full data as .csv', ...)
xfun::embed_file(f, text = 'Download data', ...)
}
#' Method to embed content from a text file in a component/sidebar
......
......@@ -5,11 +5,13 @@
#' @slot interactive If a shiny-based report should be created
#' @slot theme The theme of the dashboard
#' @slot datadir Path to the directory, where report data is stored.
#' @slot file Filename of the resulting report Rmd file.
#' @slot file The output filename (recommend that the suffix should be '.Rmd').
#' @slot pages A list of dashboard pages
#' @slot sidebar Content of the global sidebar
#' @slot colormaps A named list with color mappings.
#'
#' @return An i2dashboard object.
#'
#' @name idashboard-class
#' @rdname idashboard-class
#' @exportClass i2dashboard
......@@ -43,7 +45,7 @@ setMethod("initialize", "i2dashboard", function(.Object, ...) {
.Object <- callNextMethod()
# Create nice filename from title
if(!is.null(.Object@title)) {
if(length(.Object@file) == 0 & length(.Object@title) > 0) {
.Object@title %>% tolower %>% gsub(pattern = " ", replacement = "-") %>% gsub(pattern = '[^a-zA-Z0-9-]', replacement = '') %>% paste0(".Rmd") -> .Object@file
}
......
......@@ -11,6 +11,6 @@ options(knitr.duplicate.label = "allow")
datadir <- "<% datadir %>"
# Set up color mappings
colormap <- <% if(!is.null(colormap)) sprintf('readRDS(file.path(datadir, "%s"))', colormap) else sprintf("list()") %>
colormaps <- <% if(!is.null(colormap)) sprintf('readRDS(file.path(datadir, "%s"))', colormap) else sprintf("list()") %>
```
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/components.R
\docType{methods}
\name{add_component,i2dashboard,character-method}
\alias{add_component,i2dashboard,character-method}
\title{Method to add a component to a page of an i2dashboard.}
\usage{
\S4method{add_component}{i2dashboard,character}(dashboard, component,
page = "default", copy = FALSE, ...)
\S4method{add_component}{i2dashboard,character}(dashboard, component, page = "default", copy = FALSE, ...)
}
\arguments{
\item{dashboard}{A \linkS4class{i2dash::i2dashboard}.}
\item{component}{The name of a function of a path to a file.}
\item{component}{The name of a function or a path to a file.}
\item{page}{The name of the page to add the component to.}
......
......@@ -4,8 +4,7 @@
\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, ...)
add_vis_object(dashboard, object, package, page = "default", title = NULL, ...)
}
\arguments{
\item{dashboard}{The \linkS4class{i2dash::i2dashboard}.}
......
......@@ -4,8 +4,13 @@
\alias{.render_page}
\title{Method for rendering a page with a given layout and components}
\usage{
.render_page(title, components, layout = c("default", "storyboard",
"focal_left", "2x2_grid"), menu = NULL, sidebar = NULL)
.render_page(
title,
components,
layout = c("default", "storyboard", "focal_left", "2x2_grid"),
menu = NULL,
sidebar = NULL
)
}
\arguments{
\item{title}{The page title.}
......
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/get_set.R
\docType{methods}
\name{i2dashboard-class}
\alias{i2dashboard-class}
\title{Get/set the interactivity of the i2dashboard.}
......
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/assemble.R, R/colormap.R, R/pages.R,
% R/sidebar.R
\docType{methods}
\name{assemble,i2dashboard-method}
\alias{assemble,i2dashboard-method}
\alias{add_colormap,i2dashboard-method}
......@@ -10,38 +9,56 @@
\alias{add_to_sidebar,i2dashboard-method}
\title{Method to assemble a dashboard to a Rmd file.}
\usage{
\S4method{assemble}{i2dashboard}(dashboard,
pages = names(dashboard@pages), file = dashboard@file,
exclude = NULL, render = FALSE, ...)
\S4method{assemble}{i2dashboard}(
dashboard,
pages = names(dashboard@pages),
file = dashboard@file,
exclude = NULL,
render = FALSE,
...
)
\S4method{add_colormap}{i2dashboard}(dashboard, map, name)
\S4method{add_page}{i2dashboard}(dashboard, page, title,
layout = "default", menu = NULL, sidebar = NULL, ...)
\S4method{add_page}{i2dashboard}(
dashboard,
page,
title,
layout = "default",
menu = NULL,
sidebar = NULL,
...
)
\S4method{remove_page}{i2dashboard}(dashboard, page)
\S4method{add_to_sidebar}{i2dashboard}(dashboard, content,
page = "default", global = FALSE, copy = FALSE, ...)
\S4method{add_to_sidebar}{i2dashboard}(
dashboard,
content,
page = "default",
global = FALSE,
copy = FALSE,
...
)
}
\arguments{
\item{dashboard}{A \linkS4class{i2dash::i2dashboard}.}
\item{pages}{A string or vector with the names of pages, which should be assembled to a report.}
\item{pages}{A string or vector with the names of pages, which should be assembled to a dashboard.}
\item{file}{The output filename (recommend that the suffix should be '.Rmd'). This file will be saved in the working directory.}
\item{exclude}{A string or vector with the names of pages, which should be excluded from report assembly.}
\item{exclude}{A string or vector with the names of pages, which should be excluded from dashboard assembly.}
\item{render}{A logical indicating whether the assembled report should immediately be rendered with \code{rmarkdown::render} or run with \code{rmarkdown::run}.}
\item{render}{A logical indicating whether the assembled dashboard should immediately be rendered with \code{rmarkdown::render} or run with \code{rmarkdown::run}.}
\item{...}{Additional arguments passed on to \code{rmarkdown::render}.}
\item{...}{Additional parameters passed to the components render function.}
\item{map}{A character vector containing colors and possible the levels they map to (as names).}
\item{name}{A name for the color mapping.}
\item{page}{The name of the page to be added.}
\item{page}{The name of the page to which add the sidebar.}
\item{title}{The title of the page to be added.}
......@@ -54,20 +71,6 @@
\item{global}{Whether or not to add the content to the global sidebar.}
\item{copy}{Whether or not to copy images to \code{dashboard@datadir}.}
\item{dashboard}{A \linkS4class{i2dash::i2dashboard}.}
\item{dashboard}{A \linkS4class{i2dash::i2dashboard}.}
\item{dashboard}{A \linkS4class{i2dash::i2dashboard}.}
\item{page}{The name of the page to be removed.}
\item{dashboard}{A \linkS4class{i2dash::i2dashboard}.}
\item{page}{The name of the page to which add the sidebar.}
\item{...}{Additional parameters passed to the components render function.}
}
\description{
This method allows to add content either to the global sidebar, or to a sidebar of an existing page.
......
......@@ -12,6 +12,9 @@
i2dashboard(...)
}
\value{
An i2dashboard object.
}
\description{
The idashboard S4 class.
......@@ -34,7 +37,7 @@ Create a new i2dashboard object.
\item{\code{datadir}}{Path to the directory, where report data is stored.}
\item{\code{file}}{Filename of the resulting report Rmd file.}
\item{\code{file}}{The output filename (recommend that the suffix should be '.Rmd').}
\item{\code{pages}}{A list of dashboard pages}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment