Server part of plot-with-settings module
plot_with_settings_srv.Rd
Arguments
- id
An ID string that corresponds with the ID used to call the module's UI function.
- plot_r
(
reactive
)
reactive expression to draw a plot.- height
(
numeric
, optional)
vector with three elements c(VAL, MIN, MAX), where VAL is the starting value of the slider in the main and modal plot display. The value in the modal display is taken from the value of the slider in the main plot display.- width
(
numeric
, optional)
vector with three elementsc(VAL, MIN, MAX)
, where VAL is the starting value of the slider in the main and modal plot display;NULL
for default display. The value in the modal display is taken from the value of the slider in the main plot display.- show_hide_signal
optional, (
reactive logical
a mechanism to allow modules which call this module to show/hide the plot_with_settings UI)- brushing
(
logical
, optional)
a mechanism to enable / disable brushing on the main plot (in particular: not the one displayed in modal). All the brushing data is stored as a reactive object in the"brush"
element of returned list. See the example for details.- clicking
(
logical
)
a mechanism to enable / disable clicking on data points on the main plot (in particular: not the one displayed in modal). All the clicking data is stored as a reactive object in the"click"
element of returned list. See the example for details.- dblclicking
(
logical
, optional)
a mechanism to enable / disable double-clicking on data points on the main plot (in particular: not the one displayed in modal). All the double clicking data is stored as a reactive object in the"dblclick"
element of returned list. See the example for details.- hovering
(
logical(1)
, optional)
a mechanism to enable / disable hovering over data points on the main plot (in particular: not the one displayed in modal). All the hovering data is stored as a reactive object in the"hover"
element of returned list. See the example for details.- graph_align
(
character(1)
, optional)
one of"left"
(default),"center"
,"right"
or"justify"
. The alignment of the graph on the main page.
Details
By default the plot is rendered with 72 dpi
. In order to change this, to for example 96 set
options(teal.plot_dpi = 96)
. The minimum allowed dpi
value is 24
and it must be a whole number.
If an invalid value is set then the default value is used and a warning is outputted to the console.
Examples
if (FALSE) {
library(shiny)
shinyApp(
ui = fluidPage(
plot_with_settings_ui(
id = "plot_with_settings"
)
),
server = function(input, output, session) {
plot_r <- reactive({
ggplot2::qplot(x = 1, y = 1)
})
plot_with_settings_srv(
id = "plot_with_settings",
plot_r = plot_r,
height = c(400, 100, 1200),
width = c(500, 250, 750)
)
}
)
# Example with brushing/hovering/clicking/double-clicking
shinyApp(
ui = fluidPage(
plot_with_settings_ui(
id = "plot_with_settings"
),
fluidRow(
column(4, h3("Brush"), verbatimTextOutput("brushing_data")),
column(4, h3("Click"), verbatimTextOutput("clicking_data")),
column(4, h3("DblClick"), verbatimTextOutput("dblclicking_data")),
column(4, h3("Hover"), verbatimTextOutput("hovering_data"))
)
),
server = function(input, output, session) {
plot_r <- reactive({
ggplot2::qplot(x = 1:5, y = 1:5)
})
plot_data <- plot_with_settings_srv(
id = "plot_with_settings",
plot_r = plot_r,
height = c(400, 100, 1200),
brushing = TRUE,
clicking = TRUE,
dblclicking = TRUE,
hovering = TRUE
)
output$brushing_data <- renderPrint(plot_data$brush())
output$clicking_data <- renderPrint(plot_data$click())
output$dblclicking_data <- renderPrint(plot_data$dblclick())
output$hovering_data <- renderPrint(plot_data$hover())
}
)
# Example which allows module to be hidden/shown
library("shinyjs")
shinyApp(
ui = fluidPage(
useShinyjs(),
plot_with_settings_ui(
id = "plot_with_settings"
),
actionButton("button", "Show/Hide")
),
server = function(input, output, session) {
plot_r <- reactive(ggplot2::qplot(x = 1, y = 1))
show_hide_signal_rv <- reactiveVal(TRUE)
observeEvent(input$button, show_hide_signal_rv(!show_hide_signal_rv()))
plot_with_settings_srv(
id = "plot_with_settings",
plot_r = plot_r,
height = c(400, 100, 1200),
width = c(500, 250, 750),
show_hide_signal = reactive(show_hide_signal_rv())
)
}
)
}