-
Notifications
You must be signed in to change notification settings - Fork 28
/
aesColourCont.R
61 lines (56 loc) · 1.6 KB
/
aesColourCont.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
#' @title aesColorCont
#' @description ColorInput UI production for continuous variables.
#' @param type character of label and inputId of element
#' @param session shiny session object
#' @return UI object
#' @keywords internal
#' @import shiny
aesColourCont <- function(type, session = NULL) {
if (is.null(session)) {
ns <- function(x) x
} else {
ns <- session$ns
}
id <- gsub("-a", "", ns("a"))
iId <- sprintf("pop%sfixedPal", toupper(type))
fP <- ns(iId)
shiny::div(
shiny::selectizeInput(
inputId = fP,
label = "Pallete",
choices = c("Manual", "Blues", "BuGn", "BuPu", "GnBu", "Greens", "Greys", "Oranges", "OrRd", "PuBu", "PuBuGn", "PuRd", "Purples", "RdPu", "Reds", "YlGn", "YlGnBu", "YlOrBr", "YlOrRd"),
selected = "Blues"
),
shiny::conditionalPanel(
sprintf("input['%s-%s'] == 'Manual'", id, iId),
lapply(
c("Low", "High"),
function(x, type) {
if (x == "Low") {
pad <- "padding:0px 0px 0px 10px;"
init.col <- "red"
}
if (x == "High") {
pad <- "padding:0px 10px 0px 0px;"
init.col <- "blue"
}
shiny::column(
width = 6,
style = pad,
do.call(
colourpicker::colourInput,
args = list(
inputId = ns(sprintf("pop%s%s", toupper(type), x)),
label = x,
value = init.col,
returnName = FALSE,
showColour = "background"
)
)
)
},
type
)
)
)
}