From 87ead97bb62b61f2c0f3d6088f80c406f995f442 Mon Sep 17 00:00:00 2001 From: zawam Date: Thu, 9 Nov 2017 09:08:27 +0100 Subject: [PATCH 1/2] update doc --- man/MWController-class.Rd | 154 +++++----- man/combineWidgets-shiny.Rd | 60 ++-- man/compareOptions.Rd | 106 +++---- man/knit_print.MWController.Rd | 32 +-- man/manipulateWidget-package.Rd | 152 +++++----- man/manipulateWidget.Rd | 490 ++++++++++++++++---------------- man/mwGroup.Rd | 90 +++--- man/mwModule.Rd | 170 +++++------ man/mwSharedValue.Rd | 118 ++++---- man/staticPlot.Rd | 108 +++---- man/summary.MWController.Rd | 32 +-- 11 files changed, 756 insertions(+), 756 deletions(-) diff --git a/man/MWController-class.Rd b/man/MWController-class.Rd index ade349d..a3a60ef 100644 --- a/man/MWController-class.Rd +++ b/man/MWController-class.Rd @@ -1,77 +1,77 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/controller.R -\docType{class} -\name{MWController-class} -\alias{MWController-class} -\alias{MWController} -\title{Controller object of a manipulateWidget application} -\description{ -\code{MWController} is a reference class that is used to manage interaction -with data and update of the view created by manipulateWidget. Only users who -desire to create automatic tests for applications created with -\code{\link{manipulateWidget}} should care about this object. -} -\section{Fields}{ - -\describe{ -\item{\code{ncharts}}{Number of charts in the application} - -\item{\code{nrow}}{Number of rows.} - -\item{\code{ncol}}{Number of columns.} - -\item{\code{autoUpdate}}{Boolean indicating if charts should be automatically -updated when a value changes. list with \code{value} and \code{initBtn} (not autoUpdate, if want first charts on init)} -}} - -\section{Methods}{ - -\describe{ -\item{\code{getParams(name, chartId = 1)}}{Get parameters of an input for a given chart} - -\item{\code{getValue(name, chartId = 1)}}{Get the value of a variable for a given chart.} - -\item{\code{getValues(chartId = 1)}}{Get all values for a given chart.} - -\item{\code{isVisible(name, chartId = 1)}}{Indicates if a given input is visible} - -\item{\code{returnCharts()}}{Return all charts.} - -\item{\code{setValue(name, value, chartId = 1, reactive = FALSE)}}{Update the value of a variable for a given chart.} - -\item{\code{updateCharts()}}{Update all charts.} -}} - -\section{Testing a manipulateWidget application}{ - -When \code{\link{manipulateWidget}} is used in a test script, it returns a -\code{MWController} object instead of starting a shiny gadget. This object has -methods to modify inputs values and check the state of the application. This -can be useful to automatically checks if your application behaves like desired. -Here is some sample code that uses package \code{testthat}: - -\preformatted{ -library("testthat") - -controller <- manipulateWidget( - x + y, - x = mwSlider(0, 10, 5), - y = mwSlider(0, x, 0), - .compare = "y" -) - -test_that("Two charts are created", { - expect_equal(controller$ncharts, 2) -}) - -test_that("Parameter 'max' of 'y' is updated when 'x' changes", { - expect_equal(controller$getParams("y", 1)$max, 5) - expect_equal(controller$getParams("y", 2)$max, 5) - controller$setValue("x", 3) - expect_equal(controller$getParams("y", 1)$max, 3) - expect_equal(controller$getParams("y", 2)$max, 3) -}) - -} -} - +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/controller.R +\docType{class} +\name{MWController-class} +\alias{MWController-class} +\alias{MWController} +\title{Controller object of a manipulateWidget application} +\description{ +\code{MWController} is a reference class that is used to manage interaction +with data and update of the view created by manipulateWidget. Only users who +desire to create automatic tests for applications created with +\code{\link{manipulateWidget}} should care about this object. +} +\section{Fields}{ + +\describe{ +\item{\code{ncharts}}{Number of charts in the application} + +\item{\code{nrow}}{Number of rows.} + +\item{\code{ncol}}{Number of columns.} + +\item{\code{autoUpdate}}{Boolean indicating if charts should be automatically +updated when a value changes. list with \code{value} and \code{initBtn} (not autoUpdate, if want first charts on init)} +}} + +\section{Methods}{ + +\describe{ +\item{\code{getParams(name, chartId = 1)}}{Get parameters of an input for a given chart} + +\item{\code{getValue(name, chartId = 1)}}{Get the value of a variable for a given chart.} + +\item{\code{getValues(chartId = 1)}}{Get all values for a given chart.} + +\item{\code{isVisible(name, chartId = 1)}}{Indicates if a given input is visible} + +\item{\code{returnCharts()}}{Return all charts.} + +\item{\code{setValue(name, value, chartId = 1, reactive = FALSE)}}{Update the value of a variable for a given chart.} + +\item{\code{updateCharts()}}{Update all charts.} +}} + +\section{Testing a manipulateWidget application}{ + +When \code{\link{manipulateWidget}} is used in a test script, it returns a +\code{MWController} object instead of starting a shiny gadget. This object has +methods to modify inputs values and check the state of the application. This +can be useful to automatically checks if your application behaves like desired. +Here is some sample code that uses package \code{testthat}: + +\preformatted{ +library("testthat") + +controller <- manipulateWidget( + x + y, + x = mwSlider(0, 10, 5), + y = mwSlider(0, x, 0), + .compare = "y" +) + +test_that("Two charts are created", { + expect_equal(controller$ncharts, 2) +}) + +test_that("Parameter 'max' of 'y' is updated when 'x' changes", { + expect_equal(controller$getParams("y", 1)$max, 5) + expect_equal(controller$getParams("y", 2)$max, 5) + controller$setValue("x", 3) + expect_equal(controller$getParams("y", 1)$max, 3) + expect_equal(controller$getParams("y", 2)$max, 3) +}) + +} +} + diff --git a/man/combineWidgets-shiny.Rd b/man/combineWidgets-shiny.Rd index 17567a6..51e1617 100644 --- a/man/combineWidgets-shiny.Rd +++ b/man/combineWidgets-shiny.Rd @@ -1,30 +1,30 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/combine_widgets.R -\name{combineWidgets-shiny} -\alias{combineWidgets-shiny} -\alias{combineWidgetsOutput} -\alias{renderCombineWidgets} -\title{Shiny bindings for combineWidgets} -\usage{ -combineWidgetsOutput(outputId, width = "100\%", height = "400px") - -renderCombineWidgets(expr, env = parent.frame(), quoted = FALSE) -} -\arguments{ -\item{outputId}{output variable to read from} - -\item{width, height}{Must be a valid CSS unit (like \code{'100\%'}, -\code{'400px'}, \code{'auto'}) or a number, which will be coerced to a -string and have \code{'px'} appended.} - -\item{expr}{An expression that generates a combineWidgets} - -\item{env}{The environment in which to evaluate \code{expr}.} - -\item{quoted}{Is \code{expr} a quoted expression (with \code{quote()})? This -is useful if you want to save an expression in a variable.} -} -\description{ -Output and render functions for using combineWidgets within Shiny -applications and interactive Rmd documents. -} +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/combine_widgets.R +\name{combineWidgets-shiny} +\alias{combineWidgets-shiny} +\alias{combineWidgetsOutput} +\alias{renderCombineWidgets} +\title{Shiny bindings for combineWidgets} +\usage{ +combineWidgetsOutput(outputId, width = "100\%", height = "400px") + +renderCombineWidgets(expr, env = parent.frame(), quoted = FALSE) +} +\arguments{ +\item{outputId}{output variable to read from} + +\item{width, height}{Must be a valid CSS unit (like \code{'100\%'}, +\code{'400px'}, \code{'auto'}) or a number, which will be coerced to a +string and have \code{'px'} appended.} + +\item{expr}{An expression that generates a combineWidgets} + +\item{env}{The environment in which to evaluate \code{expr}.} + +\item{quoted}{Is \code{expr} a quoted expression (with \code{quote()})? This +is useful if you want to save an expression in a variable.} +} +\description{ +Output and render functions for using combineWidgets within Shiny +applications and interactive Rmd documents. +} diff --git a/man/compareOptions.Rd b/man/compareOptions.Rd index 513ecf0..1473d72 100644 --- a/man/compareOptions.Rd +++ b/man/compareOptions.Rd @@ -1,53 +1,53 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/compare_options.R -\name{compareOptions} -\alias{compareOptions} -\title{Options for comparison mode} -\usage{ -compareOptions(ncharts = NULL, nrow = NULL, ncol = NULL) -} -\arguments{ -\item{ncharts}{Number of charts to generate.} - -\item{nrow}{Number of rows. If \code{NULL}, the function tries to pick the -best number of rows given the number of charts and columns.} - -\item{ncol}{Number of columns. If \code{NULL}, the function tries to pick the -best number of columns given the number of charts and rows.} -} -\value{ -List of options -} -\description{ -This function generates a list of options that are used by -\code{\link{manipulateWidget}} to compare multiple charts. -} -\examples{ -if (require(dygraphs)) { - - mydata <- data.frame( - year = 2000+1:100, - series1 = rnorm(100), - series2 = rnorm(100), - series3 = rnorm(100) - ) - manipulateWidget( - dygraph(mydata[range[1]:range[2] - 2000, c("year", series)], main = title), - range = mwSlider(2001, 2100, c(2001, 2100)), - series = mwSelect(c("series1", "series2", "series3")), - title = mwText("Fictive time series"), - .compare = list(title = NULL, series = NULL), - .compareOpts = compareOptions(ncharts = 4) - ) - - manipulateWidget( - dygraph(mydata[range[1]:range[2] - 2000, c("year", series)], main = title), - range = mwSlider(2001, 2100, c(2001, 2100)), - series = mwSelect(c("series1", "series2", "series3")), - title = mwText("Fictive time series"), - .compare = list(title = NULL, series = NULL), - .compareOpts = compareOptions(ncharts = 3, nrow = 3) - ) -} - -} +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/compare_options.R +\name{compareOptions} +\alias{compareOptions} +\title{Options for comparison mode} +\usage{ +compareOptions(ncharts = NULL, nrow = NULL, ncol = NULL) +} +\arguments{ +\item{ncharts}{Number of charts to generate.} + +\item{nrow}{Number of rows. If \code{NULL}, the function tries to pick the +best number of rows given the number of charts and columns.} + +\item{ncol}{Number of columns. If \code{NULL}, the function tries to pick the +best number of columns given the number of charts and rows.} +} +\value{ +List of options +} +\description{ +This function generates a list of options that are used by +\code{\link{manipulateWidget}} to compare multiple charts. +} +\examples{ +if (require(dygraphs)) { + + mydata <- data.frame( + year = 2000+1:100, + series1 = rnorm(100), + series2 = rnorm(100), + series3 = rnorm(100) + ) + manipulateWidget( + dygraph(mydata[range[1]:range[2] - 2000, c("year", series)], main = title), + range = mwSlider(2001, 2100, c(2001, 2100)), + series = mwSelect(c("series1", "series2", "series3")), + title = mwText("Fictive time series"), + .compare = list(title = NULL, series = NULL), + .compareOpts = compareOptions(ncharts = 4) + ) + + manipulateWidget( + dygraph(mydata[range[1]:range[2] - 2000, c("year", series)], main = title), + range = mwSlider(2001, 2100, c(2001, 2100)), + series = mwSelect(c("series1", "series2", "series3")), + title = mwText("Fictive time series"), + .compare = list(title = NULL, series = NULL), + .compareOpts = compareOptions(ncharts = 3, nrow = 3) + ) +} + +} diff --git a/man/knit_print.MWController.Rd b/man/knit_print.MWController.Rd index b8d3b9e..56b2410 100644 --- a/man/knit_print.MWController.Rd +++ b/man/knit_print.MWController.Rd @@ -1,16 +1,16 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/controller.R -\name{knit_print.MWController} -\alias{knit_print.MWController} -\title{knit_print method for MWController object} -\usage{ -knit_print.MWController(x, ...) -} -\arguments{ -\item{x}{MWController object} - -\item{...}{arguments passed to function knit_print} -} -\description{ -knit_print method for MWController object -} +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/controller.R +\name{knit_print.MWController} +\alias{knit_print.MWController} +\title{knit_print method for MWController object} +\usage{ +knit_print.MWController(x, ...) +} +\arguments{ +\item{x}{MWController object} + +\item{...}{arguments passed to function knit_print} +} +\description{ +knit_print method for MWController object +} diff --git a/man/manipulateWidget-package.Rd b/man/manipulateWidget-package.Rd index d9f1629..3e6211f 100644 --- a/man/manipulateWidget-package.Rd +++ b/man/manipulateWidget-package.Rd @@ -1,76 +1,76 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/zzz.R -\docType{package} -\name{manipulateWidget-package} -\alias{manipulateWidget-package} -\title{Add even more interactivity to interactive charts} -\description{ -This package is largely inspired by the \code{manipulate} package from -Rstudio. It can be used to easily create graphical interface that let the -user modify the data or the parameters of an interactive chart. It also -provides the \code{\link{combineWidgets}} function to easily combine multiple -interactive charts in a single view. -} -\details{ -\code{\link{manipulateWidget}} is the main function of the package. It -accepts an expression that generates an interactive chart (and more precisely -an \code{htmlwidget} object. See \url{http://www.htmlwidgets.org/} if you -have never heard about it) and a set of controls created with functions -\code{mwSlider}, \code{mwCheckbox}... which are used to dynamically change -values within the expression. Each time the user modifies the value of a -control, the expression is evaluated again and the chart is updated. Consider -the following code: - -\code{manipulateWidget(myPlotFun(country), country = mwSelect(c("BE", "DE", "ES", "FR")))} - -It will generate a graphical interface with a select input on its left with -options "BE", "DE", "ES", "FR". By default, at the beginning the value of the -variable \code{country} will be equal to the first choice of the -corresponding input. So the function will first execute -\code{myPlotFun("BE")} and the result will be displayed in the main panel of -the interface. If the user changes the value to "FR", then the expression -\code{myPlotFun("FR")} is evaluated and the new result is displayed. - -The interface also contains a button "Done". When the user clicks on it, the -last chart is returned. It can be stored in a variable, be modified by the -user, saved as a html file with \code{\link[htmlwidgets]{saveWidget}} from package -\code{htmlwidgets} or converted to a static image file with package -\code{webshot}. - -Finally one can easily create complex layouts thanks to function -\code{\link{combineWidgets}}. For instance, assume we want to see a map that -displays values of some variable for a given year, but on its right side we also -want to see the distributions of three variables. Then we could write: - -\preformatted{ -myPlotFun <- function(year, variable) { - combineWidgets( - ncol = 2, colSize = c(3, 1), - myMap(year, variable), - combineWidgets( - ncol = 1, - myHist(year, "V1"), - myHist(year, "V2"), - myHist(year, "V3"), - ) - ) -} - -manipulateWidget( - myPlotFun(year, variable), - year = mwSlider(2000, 2016, value = 2000), - variable = mwSelect(c("V1", "V2", "V3")) -) -} - -Of course, \code{\link{combineWidgets}} can be used outside of -\code{\link{manipulateWidget}}. For instance, it can be used in an -Rmarkdown document to easily put together interactive charts. - -For more concrete examples of usage, you should look at the documentation and -especially the examples of \code{\link{manipulateWidget}} and -\code{\link{combineWidgets}}. -} -\seealso{ -\code{\link{manipulateWidget}}, \code{\link{combineWidgets}} -} +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/zzz.R +\docType{package} +\name{manipulateWidget-package} +\alias{manipulateWidget-package} +\title{Add even more interactivity to interactive charts} +\description{ +This package is largely inspired by the \code{manipulate} package from +Rstudio. It can be used to easily create graphical interface that let the +user modify the data or the parameters of an interactive chart. It also +provides the \code{\link{combineWidgets}} function to easily combine multiple +interactive charts in a single view. +} +\details{ +\code{\link{manipulateWidget}} is the main function of the package. It +accepts an expression that generates an interactive chart (and more precisely +an \code{htmlwidget} object. See \url{http://www.htmlwidgets.org/} if you +have never heard about it) and a set of controls created with functions +\code{mwSlider}, \code{mwCheckbox}... which are used to dynamically change +values within the expression. Each time the user modifies the value of a +control, the expression is evaluated again and the chart is updated. Consider +the following code: + +\code{manipulateWidget(myPlotFun(country), country = mwSelect(c("BE", "DE", "ES", "FR")))} + +It will generate a graphical interface with a select input on its left with +options "BE", "DE", "ES", "FR". By default, at the beginning the value of the +variable \code{country} will be equal to the first choice of the +corresponding input. So the function will first execute +\code{myPlotFun("BE")} and the result will be displayed in the main panel of +the interface. If the user changes the value to "FR", then the expression +\code{myPlotFun("FR")} is evaluated and the new result is displayed. + +The interface also contains a button "Done". When the user clicks on it, the +last chart is returned. It can be stored in a variable, be modified by the +user, saved as a html file with \code{\link[htmlwidgets]{saveWidget}} from package +\code{htmlwidgets} or converted to a static image file with package +\code{webshot}. + +Finally one can easily create complex layouts thanks to function +\code{\link{combineWidgets}}. For instance, assume we want to see a map that +displays values of some variable for a given year, but on its right side we also +want to see the distributions of three variables. Then we could write: + +\preformatted{ +myPlotFun <- function(year, variable) { + combineWidgets( + ncol = 2, colSize = c(3, 1), + myMap(year, variable), + combineWidgets( + ncol = 1, + myHist(year, "V1"), + myHist(year, "V2"), + myHist(year, "V3"), + ) + ) +} + +manipulateWidget( + myPlotFun(year, variable), + year = mwSlider(2000, 2016, value = 2000), + variable = mwSelect(c("V1", "V2", "V3")) +) +} + +Of course, \code{\link{combineWidgets}} can be used outside of +\code{\link{manipulateWidget}}. For instance, it can be used in an +Rmarkdown document to easily put together interactive charts. + +For more concrete examples of usage, you should look at the documentation and +especially the examples of \code{\link{manipulateWidget}} and +\code{\link{combineWidgets}}. +} +\seealso{ +\code{\link{manipulateWidget}}, \code{\link{combineWidgets}} +} diff --git a/man/manipulateWidget.Rd b/man/manipulateWidget.Rd index 0a8a211..1c9baab 100644 --- a/man/manipulateWidget.Rd +++ b/man/manipulateWidget.Rd @@ -1,245 +1,245 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/manipulate_widget.R -\name{manipulateWidget} -\alias{manipulateWidget} -\title{Add Controls to Interactive Plots} -\usage{ -manipulateWidget(.expr, ..., .updateBtn = FALSE, .saveBtn = TRUE, - .updateBtnInit = FALSE, .viewer = c("pane", "window", "browser"), - .compare = NULL, .compareOpts = compareOptions(), - .return = function(widget, envs) { widget }, .width = NULL, - .height = NULL, .runApp = TRUE) -} -\arguments{ -\item{.expr}{expression to evaluate that returns an interactive plot of class -\code{htmlwidget}. This expression is re-evaluated each time a control is -modified.} - -\item{...}{One or more named control arguments created with functions -\code{\link{mwSlider}}, \code{\link{mwText}}, etc. The name of each control -is the name of the variable the controls modifies in the expression. One -can also create a group of inputs by passing a list of such control -arguments. for instance \code{mygroup = list(txt = mwText(""), nb = -mwNumeric(0))} creates a group of inputs named mygroup with two inputs -named "txt" and "nb".} - -\item{.updateBtn}{Should an update button be added to the controls ? If -\code{TRUE}, then the graphic is updated only when the user clicks on the -update button.} - -\item{.saveBtn}{Should an save button be added to the controls ?} - -\item{.updateBtnInit}{In case of update button. Do you want to render graphics on init ?} - -\item{.viewer}{Controls where the gadget should be displayed. \code{"pane"} -corresponds to the Rstudio viewer, \code{"window"} to a dialog window, and -\code{"browser"} to an external web browser.} - -\item{.compare}{Sometimes one wants to compare the same chart but with two -different sets of parameters. This is the purpose of this argument. It can -be a character vector of input names or a named list whose names are the -names of the inputs that should vary between the two charts. Each element -of the list must be a vector or a list of length equal to the number of -charts with the initial values of the corresponding parameter for each -chart. It can also be \code{NULL}. In this case, the parameter is -initialized with the default value for the two charts.} - -\item{.compareOpts}{List of options created \code{\link{compareOptions}}. -These options indicate the number of charts to create and their disposition.} - -\item{.return}{A function that can be used to modify the output of -\code{manipulateWidget}. It must take two parameters: the first one is the -final widget, the second one is a list of environments containing the input -values of each individual widget. The length of this list is one if .compare -is null, two or more if it has been defined.} - -\item{.width}{Width of the UI. Used only on Rmarkdown documents with option -\code{runtime: shiny}.} - -\item{.height}{Height of the UI. Used only on Rmarkdown documents with option -\code{runtime: shiny}.} - -\item{.runApp}{(advanced usage) If true, a shiny gadget is started. If false, -the function returns a \code{\link{MWController}} object. This object can be -used to check with command line instructions the behavior of the application. -(See help page of \code{\link{MWController}}). Notice that this parameter is -always false in a non-interactive session (for instance when running tests of -a package).} -} -\value{ -The result of the expression evaluated with the last values of the controls. -It should be an object of class \code{htmlWidget}. -} -\description{ -This function permits to add controls to an interactive plot created with -packages like \code{dygraphs}, \code{highcharter} or \code{plotly} in order -to change the input data or the parameters of the plot. - -Technically, the function starts a shiny gadget. The R session is bloqued -until the user clicks on "cancel" or "done". If he clicks on "done", then the -the function returns the last displayed plot so the user can modify it and/or -save it. -} -\section{Advanced Usage}{ - -The "normal" use of the function is to provide an expression that always -return an \code{htmlwidget}. In such case, every time the user changes the -value of an input, the current widget is destroyed and a new one is created -and rendered. - -Some packages provide functions to update a widget that has already been -rendered. This is the case for instance for package \code{leaflet} with the -function \code{\link[leaflet]{leafletProxy}}. To use such functions, -\code{manipulateWidget} evaluates the parameter \code{.expr} with four extra -variables: - -\itemize{ - \item{\code{.initial}:}{ - \code{TRUE} if the expression is evaluated for the first time and then - the widget has not been rendered yet, \code{FALSE} if the widget has - already been rendered. - } - \item{\code{.session}:}{ - A shiny session object. - } - \item{\code{.output}:}{ - ID of the output in the shiny interface. - } - \item{\code{.id}:}{ - Id of the chart. It can be used in comparison mode to make further - customization without the need to create additional input controls. - } -} - -You can take a look at the last example to see how to use these two -variables to update a leaflet widget. -} - -\section{Modify the returned widget}{ - - In some specific situations, a developer may want to use - \code{manipulateWidget} in a function that waits the user to click on the - "Done" button and modifies the widget returned by \code{manipulateWidget}. - In such situation, parameter \code{.return} should be used so that - \code{manipulateWidget} is the last function called. Indeed, if other code - is present after, the custom function will act very weird in a Rmarkdown - document with "runtime: shiny". -} - -\examples{ -if (require(dygraphs)) { - - mydata <- data.frame(year = 2000+1:100, value = rnorm(100)) - manipulateWidget(dygraph(mydata[range[1]:range[2] - 2000, ], main = title), - range = mwSlider(2001, 2100, c(2001, 2100)), - title = mwText("Fictive time series")) - -} - -# Comparison mode -if (require(dygraphs)) { - - mydata <- data.frame( - year = 2000+1:100, - series1 = rnorm(100), - series2 = rnorm(100), - series3 = rnorm(100) - ) - - manipulateWidget( - dygraph(mydata[range[1]:range[2] - 2000, c("year", series)], main = title), - range = mwSlider(2001, 2100, c(2001, 2100)), - series = mwSelect(c("series1", "series2", "series3")), - title = mwText("Fictive time series"), - .compare = c("title", "series") - ) - - # Setting different initial values for each chart - manipulateWidget( - dygraph(mydata[range[1]:range[2] - 2000, c("year", series)], main = title), - range = mwSlider(2001, 2100, c(2001, 2100)), - series = mwSelect(c("series1", "series2", "series3")), - title = mwText(), - .compare = list( - title = list("First chart", "Second chart"), - series = NULL - ) - ) -} - -# Grouping inputs -if (require(dygraphs)) { - - mydata <- data.frame(year = 2000+1:100, value = rnorm(100)) - manipulateWidget(dygraph(mydata[range[1]:range[2] - 2000, ], - main = title, xlab = xlab, ylab = ylab), - range = mwSlider(2001, 2100, c(2001, 2100)), - "Graphical parameters" = mwGroup( - title = mwText("Fictive time series"), - xlab = mwText("X axis label"), - ylab = mwText("Y axis label") - ) - ) - -} - -# Example of conditional input controls -# -# In this example, we plot a x series against a y series. User can choose to -# use points or lines. If he chooses lines, then an additional input is displayed -# to let him control the width of the lines. -if (require("plotly")) { - - dt <- data.frame ( - x = sort(runif(100)), - y = rnorm(100) - ) - - myPlot <- function(type, lwd) { - if (type == "points") { - plot_ly(dt, x= ~x, y = ~y, type = "scatter", mode = "markers") - } else { - plot_ly(dt, x= ~x, y = ~y, type = "scatter", mode = "lines", line = list(width = lwd)) - } - } - - manipulateWidget( - myPlot(type, lwd), - type = mwSelect(c("points", "lines"), "points"), - lwd = mwSlider(1, 10, 1, .display = type == "lines") - ) - -} - -# Advanced Usage -# -# .expr is evaluated with extra variables .initial, .outputId and .session -# that can be used to update an already rendered widget instead of replacing -# it each time an input value is modified. -# -# Here we generate a UI that permits to change color and size of arbitrary -# points on a map generated with leaflet. - -if (require(leaflet)) { - lon <- rnorm(10, sd = 20) - lat <- rnorm(10, sd = 20) - - myMapFun <- function(radius, color, initial, session, output) { - if (initial) { - # Widget has not been rendered - map <- leaflet() \%>\% addTiles() - } else { - # widget has already been rendered - map <- leafletProxy(output, session) \%>\% clearMarkers() - } - - map \%>\% addCircleMarkers(lon, lat, radius = radius, color = color) - } - - manipulateWidget(myMapFun(radius, color, .initial, .session, .output), - radius = mwSlider(5, 30, 10), - color = mwSelect(c("red", "blue", "green"))) - -} - -} +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/manipulate_widget.R +\name{manipulateWidget} +\alias{manipulateWidget} +\title{Add Controls to Interactive Plots} +\usage{ +manipulateWidget(.expr, ..., .updateBtn = FALSE, .saveBtn = TRUE, + .updateBtnInit = FALSE, .viewer = c("pane", "window", "browser"), + .compare = NULL, .compareOpts = compareOptions(), + .return = function(widget, envs) { widget }, .width = NULL, + .height = NULL, .runApp = TRUE) +} +\arguments{ +\item{.expr}{expression to evaluate that returns an interactive plot of class +\code{htmlwidget}. This expression is re-evaluated each time a control is +modified.} + +\item{...}{One or more named control arguments created with functions +\code{\link{mwSlider}}, \code{\link{mwText}}, etc. The name of each control +is the name of the variable the controls modifies in the expression. One +can also create a group of inputs by passing a list of such control +arguments. for instance \code{mygroup = list(txt = mwText(""), nb = +mwNumeric(0))} creates a group of inputs named mygroup with two inputs +named "txt" and "nb".} + +\item{.updateBtn}{Should an update button be added to the controls ? If +\code{TRUE}, then the graphic is updated only when the user clicks on the +update button.} + +\item{.saveBtn}{Should an save button be added to the controls ?} + +\item{.updateBtnInit}{In case of update button. Do you want to render graphics on init ?} + +\item{.viewer}{Controls where the gadget should be displayed. \code{"pane"} +corresponds to the Rstudio viewer, \code{"window"} to a dialog window, and +\code{"browser"} to an external web browser.} + +\item{.compare}{Sometimes one wants to compare the same chart but with two +different sets of parameters. This is the purpose of this argument. It can +be a character vector of input names or a named list whose names are the +names of the inputs that should vary between the two charts. Each element +of the list must be a vector or a list of length equal to the number of +charts with the initial values of the corresponding parameter for each +chart. It can also be \code{NULL}. In this case, the parameter is +initialized with the default value for the two charts.} + +\item{.compareOpts}{List of options created \code{\link{compareOptions}}. +These options indicate the number of charts to create and their disposition.} + +\item{.return}{A function that can be used to modify the output of +\code{manipulateWidget}. It must take two parameters: the first one is the +final widget, the second one is a list of environments containing the input +values of each individual widget. The length of this list is one if .compare +is null, two or more if it has been defined.} + +\item{.width}{Width of the UI. Used only on Rmarkdown documents with option +\code{runtime: shiny}.} + +\item{.height}{Height of the UI. Used only on Rmarkdown documents with option +\code{runtime: shiny}.} + +\item{.runApp}{(advanced usage) If true, a shiny gadget is started. If false, +the function returns a \code{\link{MWController}} object. This object can be +used to check with command line instructions the behavior of the application. +(See help page of \code{\link{MWController}}). Notice that this parameter is +always false in a non-interactive session (for instance when running tests of +a package).} +} +\value{ +The result of the expression evaluated with the last values of the controls. +It should be an object of class \code{htmlWidget}. +} +\description{ +This function permits to add controls to an interactive plot created with +packages like \code{dygraphs}, \code{highcharter} or \code{plotly} in order +to change the input data or the parameters of the plot. + +Technically, the function starts a shiny gadget. The R session is bloqued +until the user clicks on "cancel" or "done". If he clicks on "done", then the +the function returns the last displayed plot so the user can modify it and/or +save it. +} +\section{Advanced Usage}{ + +The "normal" use of the function is to provide an expression that always +return an \code{htmlwidget}. In such case, every time the user changes the +value of an input, the current widget is destroyed and a new one is created +and rendered. + +Some packages provide functions to update a widget that has already been +rendered. This is the case for instance for package \code{leaflet} with the +function \code{\link[leaflet]{leafletProxy}}. To use such functions, +\code{manipulateWidget} evaluates the parameter \code{.expr} with four extra +variables: + +\itemize{ + \item{\code{.initial}:}{ + \code{TRUE} if the expression is evaluated for the first time and then + the widget has not been rendered yet, \code{FALSE} if the widget has + already been rendered. + } + \item{\code{.session}:}{ + A shiny session object. + } + \item{\code{.output}:}{ + ID of the output in the shiny interface. + } + \item{\code{.id}:}{ + Id of the chart. It can be used in comparison mode to make further + customization without the need to create additional input controls. + } +} + +You can take a look at the last example to see how to use these two +variables to update a leaflet widget. +} + +\section{Modify the returned widget}{ + + In some specific situations, a developer may want to use + \code{manipulateWidget} in a function that waits the user to click on the + "Done" button and modifies the widget returned by \code{manipulateWidget}. + In such situation, parameter \code{.return} should be used so that + \code{manipulateWidget} is the last function called. Indeed, if other code + is present after, the custom function will act very weird in a Rmarkdown + document with "runtime: shiny". +} + +\examples{ +if (require(dygraphs)) { + + mydata <- data.frame(year = 2000+1:100, value = rnorm(100)) + manipulateWidget(dygraph(mydata[range[1]:range[2] - 2000, ], main = title), + range = mwSlider(2001, 2100, c(2001, 2100)), + title = mwText("Fictive time series")) + +} + +# Comparison mode +if (require(dygraphs)) { + + mydata <- data.frame( + year = 2000+1:100, + series1 = rnorm(100), + series2 = rnorm(100), + series3 = rnorm(100) + ) + + manipulateWidget( + dygraph(mydata[range[1]:range[2] - 2000, c("year", series)], main = title), + range = mwSlider(2001, 2100, c(2001, 2100)), + series = mwSelect(c("series1", "series2", "series3")), + title = mwText("Fictive time series"), + .compare = c("title", "series") + ) + + # Setting different initial values for each chart + manipulateWidget( + dygraph(mydata[range[1]:range[2] - 2000, c("year", series)], main = title), + range = mwSlider(2001, 2100, c(2001, 2100)), + series = mwSelect(c("series1", "series2", "series3")), + title = mwText(), + .compare = list( + title = list("First chart", "Second chart"), + series = NULL + ) + ) +} + +# Grouping inputs +if (require(dygraphs)) { + + mydata <- data.frame(year = 2000+1:100, value = rnorm(100)) + manipulateWidget(dygraph(mydata[range[1]:range[2] - 2000, ], + main = title, xlab = xlab, ylab = ylab), + range = mwSlider(2001, 2100, c(2001, 2100)), + "Graphical parameters" = mwGroup( + title = mwText("Fictive time series"), + xlab = mwText("X axis label"), + ylab = mwText("Y axis label") + ) + ) + +} + +# Example of conditional input controls +# +# In this example, we plot a x series against a y series. User can choose to +# use points or lines. If he chooses lines, then an additional input is displayed +# to let him control the width of the lines. +if (require("plotly")) { + + dt <- data.frame ( + x = sort(runif(100)), + y = rnorm(100) + ) + + myPlot <- function(type, lwd) { + if (type == "points") { + plot_ly(dt, x= ~x, y = ~y, type = "scatter", mode = "markers") + } else { + plot_ly(dt, x= ~x, y = ~y, type = "scatter", mode = "lines", line = list(width = lwd)) + } + } + + manipulateWidget( + myPlot(type, lwd), + type = mwSelect(c("points", "lines"), "points"), + lwd = mwSlider(1, 10, 1, .display = type == "lines") + ) + +} + +# Advanced Usage +# +# .expr is evaluated with extra variables .initial, .outputId and .session +# that can be used to update an already rendered widget instead of replacing +# it each time an input value is modified. +# +# Here we generate a UI that permits to change color and size of arbitrary +# points on a map generated with leaflet. + +if (require(leaflet)) { + lon <- rnorm(10, sd = 20) + lat <- rnorm(10, sd = 20) + + myMapFun <- function(radius, color, initial, session, output) { + if (initial) { + # Widget has not been rendered + map <- leaflet() \%>\% addTiles() + } else { + # widget has already been rendered + map <- leafletProxy(output, session) \%>\% clearMarkers() + } + + map \%>\% addCircleMarkers(lon, lat, radius = radius, color = color) + } + + manipulateWidget(myMapFun(radius, color, .initial, .session, .output), + radius = mwSlider(5, 30, 10), + color = mwSelect(c("red", "blue", "green"))) + +} + +} diff --git a/man/mwGroup.Rd b/man/mwGroup.Rd index de27d13..328a6ce 100644 --- a/man/mwGroup.Rd +++ b/man/mwGroup.Rd @@ -1,45 +1,45 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/inputs.R -\name{mwGroup} -\alias{mwGroup} -\title{Group inputs in a collapsible box} -\usage{ -mwGroup(..., .display = TRUE) -} -\arguments{ -\item{...}{inputs that will be grouped in the box} - -\item{.display}{expression that evaluates to TRUE or FALSE, indicating when -the group should be shown/hidden.} -} -\value{ -Input of type "group". -} -\description{ -This function generates a collapsible box containing inputs. It can be useful -when there are a lot of inputs and one wants to group them. -} -\examples{ -if(require(dygraphs)) { - mydata <- data.frame(x = 1:100, y = rnorm(100)) - manipulateWidget( - dygraph(mydata[range[1]:range[2], ], - main = title, xlab = xlab, ylab = ylab), - range = mwSlider(1, 100, c(1, 100)), - "Graphical parameters" = mwGroup( - title = mwText("Fictive time series"), - xlab = mwText("X axis label"), - ylab = mwText("Y axis label") - ) - ) -} - -} -\seealso{ -Other controls: \code{\link{mwCheckboxGroup}}, - \code{\link{mwCheckbox}}, \code{\link{mwDateRange}}, - \code{\link{mwDate}}, \code{\link{mwNumeric}}, - \code{\link{mwPassword}}, \code{\link{mwRadio}}, - \code{\link{mwSelect}}, \code{\link{mwSharedValue}}, - \code{\link{mwSlider}}, \code{\link{mwText}} -} +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/inputs.R +\name{mwGroup} +\alias{mwGroup} +\title{Group inputs in a collapsible box} +\usage{ +mwGroup(..., .display = TRUE) +} +\arguments{ +\item{...}{inputs that will be grouped in the box} + +\item{.display}{expression that evaluates to TRUE or FALSE, indicating when +the group should be shown/hidden.} +} +\value{ +Input of type "group". +} +\description{ +This function generates a collapsible box containing inputs. It can be useful +when there are a lot of inputs and one wants to group them. +} +\examples{ +if(require(dygraphs)) { + mydata <- data.frame(x = 1:100, y = rnorm(100)) + manipulateWidget( + dygraph(mydata[range[1]:range[2], ], + main = title, xlab = xlab, ylab = ylab), + range = mwSlider(1, 100, c(1, 100)), + "Graphical parameters" = mwGroup( + title = mwText("Fictive time series"), + xlab = mwText("X axis label"), + ylab = mwText("Y axis label") + ) + ) +} + +} +\seealso{ +Other controls: \code{\link{mwCheckboxGroup}}, + \code{\link{mwCheckbox}}, \code{\link{mwDateRange}}, + \code{\link{mwDate}}, \code{\link{mwNumeric}}, + \code{\link{mwPassword}}, \code{\link{mwRadio}}, + \code{\link{mwSelect}}, \code{\link{mwSharedValue}}, + \code{\link{mwSlider}}, \code{\link{mwText}} +} diff --git a/man/mwModule.Rd b/man/mwModule.Rd index 5238eff..0b2206e 100644 --- a/man/mwModule.Rd +++ b/man/mwModule.Rd @@ -1,85 +1,85 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/module_ui.R -\name{mwModule} -\alias{mwModule} -\alias{mwModuleUI} -\title{Add a manipulateWidget to a shiny application} -\usage{ -mwModule(id, controller, ...) - -mwModuleUI(id, border = TRUE, okBtn = FALSE, saveBtn = TRUE, margin = 0, - width = "100\%", height = 400) -} -\arguments{ -\item{id}{A unique string that identifies the module} - -\item{controller}{Object of class \code{\link{MWController}} returned by -\code{\link{manipulateWidget}} when parameter \code{.runApp} is -\code{FALSE}.} - -\item{...}{named arguments containing reactive values. They can be used to send data from -the main shiny application to the module.} - -\item{border}{Should a border be added to the module?} - -\item{okBtn}{Should the UI contain the OK button?} - -\item{saveBtn}{Should the UI contain the save button?} - -\item{margin}{Margin to apply around the module UI. Should be one two or four valid css -units.} - -\item{width}{Width of the module UI.} - -\item{height}{Height of the module UI.} -} -\value{ -\code{mwModuleUI} returns the required HTML elements for the module. mwModule is only -used for its side effects. -} -\description{ -These two functions can be used to include a manipulateWidget object in a shiny application. -\code{mwModuleUI} must be used in the UI to generate the required HTML elements and add -javascript and css dependencies. \code{mwModule} must be called once in the server function -of the application. -} -\examples{ -if (interactive() & require("dygraphs")) { - require("shiny") - ui <- fillPage( - fillRow( - flex = c(NA, 1), - div( - textInput("title", label = "Title", value = "glop"), - selectInput("series", "series", choices = c("series1", "series2", "series3")) - ), - mwModuleUI("ui", height = "100\%") - )) - - server <- function(input, output, session) { - mydata <- data.frame( - year = 2000+1:100, - series1 = rnorm(100), - series2 = rnorm(100), - series3 = rnorm(100) - ) - - c <- manipulateWidget( - { - dygraph(mydata[range[1]:range[2] - 2000, c("year", series)], main = title) - }, - range = mwSlider(2001, 2100, c(2001, 2050)), - series = mwSharedValue(), - title = mwSharedValue(), .runApp = FALSE, - .compare = "range" - ) - # - mwModule("ui", c, title = reactive(input$title), series = reactive(input$series)) - } - - shinyApp(ui, server) - - -} - -} +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/module_ui.R +\name{mwModule} +\alias{mwModule} +\alias{mwModuleUI} +\title{Add a manipulateWidget to a shiny application} +\usage{ +mwModule(id, controller, ...) + +mwModuleUI(id, border = TRUE, okBtn = FALSE, saveBtn = TRUE, margin = 0, + width = "100\%", height = 400) +} +\arguments{ +\item{id}{A unique string that identifies the module} + +\item{controller}{Object of class \code{\link{MWController}} returned by +\code{\link{manipulateWidget}} when parameter \code{.runApp} is +\code{FALSE}.} + +\item{...}{named arguments containing reactive values. They can be used to send data from +the main shiny application to the module.} + +\item{border}{Should a border be added to the module?} + +\item{okBtn}{Should the UI contain the OK button?} + +\item{saveBtn}{Should the UI contain the save button?} + +\item{margin}{Margin to apply around the module UI. Should be one two or four valid css +units.} + +\item{width}{Width of the module UI.} + +\item{height}{Height of the module UI.} +} +\value{ +\code{mwModuleUI} returns the required HTML elements for the module. mwModule is only +used for its side effects. +} +\description{ +These two functions can be used to include a manipulateWidget object in a shiny application. +\code{mwModuleUI} must be used in the UI to generate the required HTML elements and add +javascript and css dependencies. \code{mwModule} must be called once in the server function +of the application. +} +\examples{ +if (interactive() & require("dygraphs")) { + require("shiny") + ui <- fillPage( + fillRow( + flex = c(NA, 1), + div( + textInput("title", label = "Title", value = "glop"), + selectInput("series", "series", choices = c("series1", "series2", "series3")) + ), + mwModuleUI("ui", height = "100\%") + )) + + server <- function(input, output, session) { + mydata <- data.frame( + year = 2000+1:100, + series1 = rnorm(100), + series2 = rnorm(100), + series3 = rnorm(100) + ) + + c <- manipulateWidget( + { + dygraph(mydata[range[1]:range[2] - 2000, c("year", series)], main = title) + }, + range = mwSlider(2001, 2100, c(2001, 2050)), + series = mwSharedValue(), + title = mwSharedValue(), .runApp = FALSE, + .compare = "range" + ) + # + mwModule("ui", c, title = reactive(input$title), series = reactive(input$series)) + } + + shinyApp(ui, server) + + +} + +} diff --git a/man/mwSharedValue.Rd b/man/mwSharedValue.Rd index e41dfd9..0d1dc47 100644 --- a/man/mwSharedValue.Rd +++ b/man/mwSharedValue.Rd @@ -1,59 +1,59 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/inputs.R -\name{mwSharedValue} -\alias{mwSharedValue} -\title{Shared Value} -\usage{ -mwSharedValue(expr = NULL) -} -\arguments{ -\item{expr}{Expression used to compute the value of the input.} -} -\value{ -An Input object of type "sharedValue". -} -\description{ -This function creates a virtual input that can be used to store a dynamic -shared variable that is accessible in inputs as well as in output. -} -\examples{ - -if (require(plotly)) { - # Plot the characteristics of a car and compare with the average values for - # cars with same number of cylinders. - # The shared variable 'subsetCars' is used to avoid subsetting multiple times - # the data: this value is updated only when input 'cylinders' changes. - colMax <- apply(mtcars, 2, max) - - plotCar <- function(cardata, carName) { - carValues <- unlist(cardata[carName, ]) - carValuesRel <- carValues / colMax - - avgValues <- round(colMeans(cardata), 2) - avgValuesRel <- avgValues / colMax - - plot_ly() \%>\% - add_bars(x = names(cardata), y = carValuesRel, text = carValues, - hoverinfo = c("x+text"), name = carName) \%>\% - add_bars(x = names(cardata), y = avgValuesRel, text = avgValues, - hoverinfo = c("x+text"), name = "average") \%>\% - layout(barmode = 'group') - } - - c <- manipulateWidget( - plotCar(subsetCars, car), - cylinders = mwSelect(c("4", "6", "8")), - subsetCars = mwSharedValue(subset(mtcars, cylinders == cyl)), - car = mwSelect(choices = row.names(subsetCars)) - ) -} - -} -\seealso{ -Other controls: \code{\link{mwCheckboxGroup}}, - \code{\link{mwCheckbox}}, \code{\link{mwDateRange}}, - \code{\link{mwDate}}, \code{\link{mwGroup}}, - \code{\link{mwNumeric}}, \code{\link{mwPassword}}, - \code{\link{mwRadio}}, \code{\link{mwSelect}}, - \code{\link{mwSlider}}, \code{\link{mwText}} -} +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/inputs.R +\name{mwSharedValue} +\alias{mwSharedValue} +\title{Shared Value} +\usage{ +mwSharedValue(expr = NULL) +} +\arguments{ +\item{expr}{Expression used to compute the value of the input.} +} +\value{ +An Input object of type "sharedValue". +} +\description{ +This function creates a virtual input that can be used to store a dynamic +shared variable that is accessible in inputs as well as in output. +} +\examples{ + +if (require(plotly)) { + # Plot the characteristics of a car and compare with the average values for + # cars with same number of cylinders. + # The shared variable 'subsetCars' is used to avoid subsetting multiple times + # the data: this value is updated only when input 'cylinders' changes. + colMax <- apply(mtcars, 2, max) + + plotCar <- function(cardata, carName) { + carValues <- unlist(cardata[carName, ]) + carValuesRel <- carValues / colMax + + avgValues <- round(colMeans(cardata), 2) + avgValuesRel <- avgValues / colMax + + plot_ly() \%>\% + add_bars(x = names(cardata), y = carValuesRel, text = carValues, + hoverinfo = c("x+text"), name = carName) \%>\% + add_bars(x = names(cardata), y = avgValuesRel, text = avgValues, + hoverinfo = c("x+text"), name = "average") \%>\% + layout(barmode = 'group') + } + + c <- manipulateWidget( + plotCar(subsetCars, car), + cylinders = mwSelect(c("4", "6", "8")), + subsetCars = mwSharedValue(subset(mtcars, cylinders == cyl)), + car = mwSelect(choices = row.names(subsetCars)) + ) +} + +} +\seealso{ +Other controls: \code{\link{mwCheckboxGroup}}, + \code{\link{mwCheckbox}}, \code{\link{mwDateRange}}, + \code{\link{mwDate}}, \code{\link{mwGroup}}, + \code{\link{mwNumeric}}, \code{\link{mwPassword}}, + \code{\link{mwRadio}}, \code{\link{mwSelect}}, + \code{\link{mwSlider}}, \code{\link{mwText}} +} diff --git a/man/staticPlot.Rd b/man/staticPlot.Rd index 338fa58..c6d8ffa 100644 --- a/man/staticPlot.Rd +++ b/man/staticPlot.Rd @@ -1,54 +1,54 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/static_image.R -\name{staticPlot} -\alias{staticPlot} -\alias{staticImage} -\title{Include a static image in a combinedWidgets} -\usage{ -staticPlot(expr, width = 600, height = 400) - -staticImage(file, style = "max-width:100\%\%;max-height:100\%\%") -} -\arguments{ -\item{expr}{Expression that creates a static plot.} - -\item{width}{Width of the image to create.} - -\item{height}{Height of the image to create.} - -\item{file}{path of the image to include.} - -\item{style}{CSS style to apply to the image.} -} -\value{ -a \code{shiny.tag} object containing the HTML code required to include -the image or the plot in a \code{combinedWidgets} object. -} -\description{ -\code{staticPlot} is a function that generates a static plot and then return -the HTML code needed to include the plot in a combinedWidgets. -\code{staticImage} is a more general function that generates the HTML code -necessary to include any image file. -} -\examples{ -staticPlot(hist(rnorm(100))) - -if (require(plotly)) { - data(iris) - - combineWidgets( - plot_ly(iris, x = ~Sepal.Length, type = "histogram", nbinsx = 20), - staticPlot(hist(iris$Sepal.Length, breaks = 20), height = 300) - ) - - # You can also embed static images in the header, footer, left or right - # columns of a combinedWidgets. The advantage is that the space allocated - # to the static plot will be constant when the window is resized. - - combineWidgets( - plot_ly(iris, x = ~Sepal.Length, type = "histogram", nbinsx = 20), - footer = staticPlot(hist(iris$Sepal.Length, breaks = 20), height = 300) - ) -} - -} +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/static_image.R +\name{staticPlot} +\alias{staticPlot} +\alias{staticImage} +\title{Include a static image in a combinedWidgets} +\usage{ +staticPlot(expr, width = 600, height = 400) + +staticImage(file, style = "max-width:100\%\%;max-height:100\%\%") +} +\arguments{ +\item{expr}{Expression that creates a static plot.} + +\item{width}{Width of the image to create.} + +\item{height}{Height of the image to create.} + +\item{file}{path of the image to include.} + +\item{style}{CSS style to apply to the image.} +} +\value{ +a \code{shiny.tag} object containing the HTML code required to include +the image or the plot in a \code{combinedWidgets} object. +} +\description{ +\code{staticPlot} is a function that generates a static plot and then return +the HTML code needed to include the plot in a combinedWidgets. +\code{staticImage} is a more general function that generates the HTML code +necessary to include any image file. +} +\examples{ +staticPlot(hist(rnorm(100))) + +if (require(plotly)) { + data(iris) + + combineWidgets( + plot_ly(iris, x = ~Sepal.Length, type = "histogram", nbinsx = 20), + staticPlot(hist(iris$Sepal.Length, breaks = 20), height = 300) + ) + + # You can also embed static images in the header, footer, left or right + # columns of a combinedWidgets. The advantage is that the space allocated + # to the static plot will be constant when the window is resized. + + combineWidgets( + plot_ly(iris, x = ~Sepal.Length, type = "histogram", nbinsx = 20), + footer = staticPlot(hist(iris$Sepal.Length, breaks = 20), height = 300) + ) +} + +} diff --git a/man/summary.MWController.Rd b/man/summary.MWController.Rd index fee0b5d..f11cf5b 100644 --- a/man/summary.MWController.Rd +++ b/man/summary.MWController.Rd @@ -1,16 +1,16 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/controller.R -\name{summary.MWController} -\alias{summary.MWController} -\title{summary method for MWController object} -\usage{ -\method{summary}{MWController}(object, ...) -} -\arguments{ -\item{object}{MWController object} - -\item{...}{Not use} -} -\description{ -summary method for MWController object -} +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/controller.R +\name{summary.MWController} +\alias{summary.MWController} +\title{summary method for MWController object} +\usage{ +\method{summary}{MWController}(object, ...) +} +\arguments{ +\item{object}{MWController object} + +\item{...}{Not use} +} +\description{ +summary method for MWController object +} From ebb83a29c94c85e3eddee693b8bb90ccb199be54 Mon Sep 17 00:00:00 2001 From: zawam Date: Thu, 9 Nov 2017 09:17:00 +0100 Subject: [PATCH 2/2] build vignette when building package --- manipulateWidget.Rproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/manipulateWidget.Rproj b/manipulateWidget.Rproj index 6daccaa..488ba32 100644 --- a/manipulateWidget.Rproj +++ b/manipulateWidget.Rproj @@ -18,4 +18,4 @@ StripTrailingWhitespace: Yes BuildType: Package PackageUseDevtools: Yes PackageInstallArgs: --no-multiarch --with-keep.source -PackageRoxygenize: rd,collate,namespace +PackageRoxygenize: rd,collate,namespace,vignette