Type: | Package |
Title: | XY Controller for 'Shiny' |
Version: | 0.2.0 |
Maintainer: | Stéphane Laurent <laurent_step@outlook.fr> |
Description: | Provides an XY pad input for the 'Shiny' framework. An XY pad is like a bivariate slider. It allows to pick up a pair of numbers. |
License: | GPL-3 |
Encoding: | UTF-8 |
Imports: | shiny |
URL: | https://github.com/stla/shinyXYpad |
BugReports: | https://github.com/stla/shinyXYpad/issues |
RoxygenNote: | 7.2.1 |
NeedsCompilation: | no |
Packaged: | 2022-09-26 14:24:37 UTC; stla |
Author: | Stéphane Laurent [aut, cre], Anthony Terrien [cph] ('jqueryKontrol library') |
Repository: | CRAN |
Date/Publication: | 2022-09-27 08:10:02 UTC |
XY pad controller
Description
Creates a XY pad controller to be included in a Shiny UI.
Usage
XYpadInput(
inputId,
label = NULL,
value = list(x = 50, y = 50),
xmin = 0,
xmax = 100,
ymin = 0,
ymax = 100,
ndecimals = 2,
width = 200,
height = 200,
bgColor = "rgba(255,200,200,0.2)",
xyColor = "blue",
xySize = 11,
xyStyle = "italic",
coordsColor = xyColor,
pointColor = "#16235a",
pointRadius = 5,
border = "2px solid #777CA8",
x = "x",
y = "y",
displayPrevious = TRUE,
displayXY = TRUE,
onMove = FALSE
)
Arguments
inputId |
the input slot that will be used to access the value |
label |
label for the XY pad, or |
value |
the initial value, a list of two numbers named |
xmin , xmax |
minimal x-value and maximal x-value |
ymin , ymax |
minimal y-value and maximal y-value |
ndecimals |
number of decimals of the displayed coordinates (if |
width |
a positive number, the width in pixels |
height |
a positive number, the height in pixels |
bgColor |
background color, a HTML color; you have to set some transparency in order to see the coordinates |
xyColor |
color of the labels of the coordinates (if |
xySize |
font size of the labels of the coordinates (if |
xyStyle |
font style of the labels of the coordinates (if |
coordsColor |
color of the displayed coordinates (if |
pointColor |
color of the point, a HTML color |
pointRadius |
radius of the point in pixels |
border |
CSS for the border of the XY pad |
x |
label of the x-coordinate (if |
y |
label of the y-coordinate (if |
displayPrevious |
logical, whether to display the previous position of the point |
displayXY |
logical, whether to display the coordinates |
onMove |
logical, whether to send value to server on mouse move
( |
Value
A shiny.tag.list
object generating a XY pad input control that
can be added to a Shiny UI definition.
See Also
updateXYpadInput
for updating the XY pad on server-side.
Examples
library(shiny)
library(shinyXYpad)
ui <- fluidPage(
fluidRow(
column(
6,
XYpadInput("xy1", onMove = TRUE, label = "XY pad - on move")
),
column(
6,
XYpadInput(
"xy2", label = "XY pad - on release",
displayXY = FALSE, displayPrevious = FALSE
)
)
),
fluidRow(
column(6, verbatimTextOutput("xy1value")),
column(6, verbatimTextOutput("xy2value"))
)
)
server <- function(input, output, session){
output[["xy1value"]] <- renderPrint({ input[["xy1"]] })
output[["xy2value"]] <- renderPrint({ input[["xy2"]] })
}
if(interactive()){
shinyApp(ui, server)
}
Change a XY pad input on the client
Description
Changes a XY pad input on the client.
Usage
updateXYpadInput(
session,
inputId,
label = NULL,
value = NULL,
xmin = NULL,
xmax = NULL,
ymin = NULL,
ymax = NULL,
ndecimals = NULL,
bgColor = NULL,
pointColor = NULL,
pointRadius = NULL
)
Arguments
session |
session object passed to the Shiny server function |
inputId |
id of the XY pad input |
label |
new label, or |
value |
new value, or |
xmin |
new |
xmax |
new |
ymin |
new |
ymax |
new |
ndecimals |
new |
bgColor |
new |
pointColor |
new |
pointRadius |
new |
Value
No value is returned, called for side-effect.
Examples
library(shiny)
library(shinyXYpad)
ui <- fluidPage(
fluidRow(
column(6, XYpadInput("xy", onMove = TRUE, label = "XY pad")),
column(6, verbatimTextOutput("xyvalue"))
),
br(),
actionButton("update", "Update")
)
server <- function(input, output, session){
output[["xyvalue"]] <- renderPrint({ input[["xy"]] })
observeEvent(input[["update"]], {
updateXYpadInput(session, "xy", value = list(x = 25, y = 25),
bgColor = "chartreuse", pointColor = "yellow",
pointRadius = 10, ndecimals = 3)
})
}
if(interactive()){
shinyApp(ui, server)
}