Package 'shinyXYpad'

Title: XY Controller for 'Shiny'
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.
Authors: Stéphane Laurent [aut, cre], Anthony Terrien [cph] ('jqueryKontrol library')
Maintainer: Stéphane Laurent <[email protected]>
License: GPL-3
Version: 0.2.0
Built: 2024-11-17 03:39:32 UTC
Source: https://github.com/stla/shinyxypad

Help Index


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 NULL for no change

value

new value, or NULL for no change

xmin

new xmin, or NULL for no change

xmax

new xmax, or NULL for no change

ymin

new ymin, or NULL for no change

ymax

new ymax, or NULL for no change

ndecimals

new ndecimals, or NULL for no change

bgColor

new bgColor, or NULL for no change

pointColor

new pointColor, or NULL for no change

pointRadius

new pointRadius, or NULL for no change

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)
}

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 NULL for no label

value

the initial value, a list of two numbers named "x" and "y"

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 displayXY=TRUE)

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 displayXY=TRUE), a HTML color

xySize

font size of the labels of the coordinates (if displayXY=TRUE)

xyStyle

font style of the labels of the coordinates (if displayXY=TRUE), "normal", "italic" or "oblique"

coordsColor

color of the displayed coordinates (if displayXY=TRUE), a HTML color

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 displayXY=TRUE)

y

label of the y-coordinate (if displayXY=TRUE)

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 (TRUE) or on mouse release (FALSE)

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)
}