-
Notifications
You must be signed in to change notification settings - Fork 157
/
Copy pathupdateColorPickr.R
77 lines (69 loc) · 1.66 KB
/
updateColorPickr.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
library(shiny)
library(shinyWidgets)
ui <- fluidPage(
tags$h2("Update colorPickr example"),
fluidRow(
column(
width = 6,
colorPickr(
inputId = "id1",
label = "Update this label:",
width = "300px"
),
textInput(
inputId = "update_label",
label = "Update label above :"
)
),
column(
width = 6,
colorPickr(
inputId = "id2",
label = "Swatches :",
selected = "#440154",
swatches = c(
scales::viridis_pal()(9)
),
update = "change",
opacity = FALSE,
preview = FALSE,
hue = FALSE,
interaction = list(
hex= FALSE,
rgba = FALSE,
input = FALSE,
save = FALSE,
clear = FALSE
),
pickr_width = "245px",
inline = TRUE
),
verbatimTextOutput("res"),
actionButton("red", "Update red"),
actionButton("green", "Update green"),
actionButton("blue", "Update blue")
)
)
)
server <- function(input, output, session) {
observeEvent(
input$update_label,
updateColorPickr(inputId = "id1", label = input$update_label),
ignoreInit = TRUE
)
output$res <- renderPrint(input$id1)
observeEvent(
input$red,
updateColorPickr(inputId = "id2", swatches = scales::brewer_pal(palette = "Reds")(9))
)
observeEvent(
input$green,
updateColorPickr(inputId = "id2", swatches = scales::brewer_pal(palette = "Greens")(9))
)
observeEvent(
input$blue,
updateColorPickr(inputId = "id2", swatches = scales::brewer_pal(palette = "Blues")(9))
)
}
if (interactive())
shinyApp(ui, server)