dreamrs / shinywidgets Goto Github PK
View Code? Open in Web Editor NEWshinyWidgets : Extend widgets available in shiny
Home Page: https://dreamrs.github.io/shinyWidgets/
License: GNU General Public License v3.0
shinyWidgets : Extend widgets available in shiny
Home Page: https://dreamrs.github.io/shinyWidgets/
License: GNU General Public License v3.0
Hi,
I am wondering if you can add updateSearchInput just like other input UI. I understand there's a button involved so it may be a bit tricky. I personally attempted to do that using session$sendInputMessage but it won't simulate button click to trigger input value change. Any idea?
Steve
Hi folks, first you've created a wonderful package with dozens of features that I frequently use. Thanks for that! In one application I want to measure the sentiment of a given tweet.
radioGroupButtons(
inputId = "sent",
label = h3("Sentiment"),
choiceValues = -2:2,
choiceNames = paste0(-2:2),
justified = T
)
The result is well known:
(-2
is active)
But the coloring I'm looking for is
Do you know how to tweak the code to get a kind of result?
Thanks in advance!
Simon
I am trying to use updateCheckboxGroupButtons
to update the buttons that are selected but when I do selected = NULL
the buttons selected does not get updated. The previous buttons that were selected remains in the selection.
Following is a minimal example to reproduce the issue:
library(shiny)
library(shinyWidgets)
ui <- fluidPage(
selectInput(inputId = "SI_Element", label = "Element:", choices = c("Title", "Body")),
checkboxGroupButtons(inputId = "CBK_Button", label = "Font Style:",
choices = c("bold", "italic", "underline")
, selected = c("bold"))
)
server <- function(input,output, session){
observeEvent(input$SI_Element,{
if(input$SI_Element == "Body"){
updateCheckboxGroupButtons(session, "CBK_Button", selected = NULL)
}else{
updateCheckboxGroupButtons(session, "CBK_Button", selected = "bold")
}
})
}
shinyApp(ui = ui, server = server)
Hi!
Your package is really super awesome!
Please see the example below.
While using prettyToggle and actionBttn in one app, the design of the button is like resetted (not sure if it's the proper word - image below)
However when I delete prettyToggle from the app, the actionBttn looks nice
Why is it like that?
Here is the code, just basic.
library(shiny)
library(shinyWidgets)
ui <- fluidPage(
# prettyToggle(inputId = "toggle1",
# label_on = "Checked!",
# label_off = "Unchecked..."),
actionBttn('button','Button', style='gradient')
)
server <- function(input, output, session) {
}
shinyApp(ui, server)
Thank you
Marta
When ever i click pickerInput it closes the dropdownButton.
Hi
The following does not work with a simple shiny module.
The output$res
just stays NULL
(after clicking on the input$somevalue
)
library(shiny)
library(shinyWidgets)
moduleUI <- function(id){
ns <- NS(id)
fluidPage(
awesomeCheckboxGroup(
# checkboxGroupInput(
inputId = ns("somevalue"),
choices = c("A", "B", "C"),
label = "My label"
),
verbatimTextOutput(outputId = ns("res")),
actionButton(inputId = ns("updatechoices"), label = "Random choices")
)
}
module <- function(input, output, session) {
output$res <- renderPrint({
input$somevalue
})
observeEvent(input$updatechoices, {
updateAwesomeCheckboxGroup(
# updateCheckboxGroupInput(
session = session, inputId = "somevalue",
choices = sample(letters, sample(2:6))
)
})
}
ui <- fluidPage(
moduleUI("module")
)
server <- function(input, output, session) {
callModule(module, "module")
}
shinyApp(ui = ui, server = server)
However using shiny::CheckboxGroupInput
does not produce this error, (can test by uncommenting and commenting above code)
At first I thought it was only when using the updateAwesomeCheckboxGroup
that there are problems but sometimes without using it causes problems.
Below is
> sessionInfo()
R version 3.4.2 (2017-09-28)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 7 x64 (build 7601) Service Pack 1
Matrix products: default
locale:
[1] LC_COLLATE=English_South Africa.1252 LC_CTYPE=English_South Africa.1252
[3] LC_MONETARY=English_South Africa.1252 LC_NUMERIC=C
[5] LC_TIME=English_South Africa.1252
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] shinyWidgets_0.3.6 shiny_1.0.5
loaded via a namespace (and not attached):
[1] compiler_3.4.2 R6_2.2.1 htmltools_0.3.6 tools_3.4.2 Rcpp_0.12.12 jsonlite_1.5
[7] digest_0.6.12 xtable_1.8-2 httpuv_1.3.5 mime_0.5
Hi,
shinyjs reset is working for materialSwitch, but it is not working for switchInput.
here an example
library(shiny)
library(shinyjs)
library(shinyWidgets)
#### Server ####
server <- function(input, output){
observeEvent(input$reset_button, {
shinyjs::reset("checkbox_1")
shinyjs::reset("switch_1")
shinyjs::reset("switch_2")
})
output$checkbox_1_output <- renderPrint({
input$checkbox_1
})
output$switch_1_output <- renderPrint({
input$switch_1
})
output$switch_2_output <- renderPrint({
input$switch_2
})
}
#### UI ####
ui <- fluidPage(
useShinyjs(),
fluidRow(
column(
width = 6,
actionButton(inputId = "reset_button",
label = "Reset"),
hr(),
verbatimTextOutput("checkbox_1_output"),
verbatimTextOutput("switch_1_output"),
verbatimTextOutput("switch_2_output")
),
column(
width = 6,
checkboxInput(inputId = "checkbox_1",
label = "CHECK",
value = F),
br(),
switchInput(inputId = "switch_1",
Label = "SWITCH 1",
value = F),
br(),
materialSwitch(inputId = "switch_2",
label = "SWITCH 2",
value = F,
right = T)
)
)
)
#### Run ####
shinyApp(ui = ui, server = server)
Hey Victor,
you already helped me with the sentiment input. Now I tried to update this button or better reset. But updateRadioGroupButtons(session, "sent", selected = "")
updates only the UI and not the value itself. Do you know how to fix this? character(0)
instead of ""
an empty string does not seem to be the solution.
Thanks in Advance,
Simon
Hi,
I found this bug. When pickerInput is inside a dropdownButton, clicking on the selection bar does not open the menu.
Here a minimal working example
library("shiny")
library("shinyWidgets")
server <- function(input, output, session) {}
ui <- fluidPage(
tags$h1("Picker behaviour", style="color: steelblue;"),
fluidRow(
column(
width = 6,
pickerInput(inputId = "id1", label = "Click works", choices = c("a", "b", "c", "d"))
),
column(
width = 6,
dropdownButton(
pickerInput(inputId = "id2", label = "Click doesn't work", choices = c("a", "b", "c", "d")),
circle = TRUE,
status = "default",
icon = icon("gear"),
label = "Click on me", tooltip = FALSE, width = NULL)
)
)
)
shinyApp(ui = ui, server = server)
"Or see the live version here : https://dreamrs-vic.shinyapps.io/shinyWidgets/" ... link does not work
Hi there,
Just found out that in latest release awesomeCheckboxGroup is giving NULL is set to FALSE.
Hi!
First of all, thanks for your great package! I pimp my apps since I've get it!
pickerInput don't work as expected when inside a dropdownButton : dropdown panel is closed when the picker menu is clicked. Here's a reproducible example :
`if (interactive()) {
library("shiny")
library("shinyWidgets")
ui <- fluidPage(
fluidRow(
column(1,
dropdownButton(icon = icon('gear'), width = "400px",
pickerInput(
inputId = "id", label = "Fruits :",
choices = c("Banana", "Blueberry", "Cherry"),
selected = "Banana", width = "350px"
)
)
),
column(11, br(), verbatimTextOutput(outputId = "res"))
)
)
server <- function(input, output, session) {
output$res <- renderPrint({
input$id
})
}
shinyApp(ui = ui, server = server)
}
`
And I've a little request : can you put the code on the "other stuffs" page of shinyWidgetsGallery(), specially for the second dropdown button? It's animation is really nice! I'm less interested by the panel slide animation...
Thanks again for your work!
Hi, the latest commit b0286f78
produces an error with material switch widgets. Head of stack trace:
Warning: Error in .tag_validate: class is: form-group shiny-input-container material-switch, needs to be: form-group shiny-input-container
Stack trace (innermost first):
121: .tag_validate
120: shinyInput_label_embed
119: function_list[[k]]
118: withVisible
I do wrap widgets with div()
so that I can use shinyjs::reset()
. Thank you.
Self explanatory example. awesomeCheckboxGroup does not get value when inline = FALSE. I have the latest version of shinyWidgets_0.3.6.
ui <- fluidPage(
br(),
awesomeCheckboxGroup(
inputId = "id1", label = "Make a choice:",
choices = c("graphics", "ggplot2")
),
verbatimTextOutput(outputId = "res1"),
br(),
awesomeCheckboxGroup(
inputId = "id2", label = "Make a choice:",
choices = list("base" = "b", "dplyr" = "dp", "data.table" = "dt"),
inline = TRUE, status = "danger"
),
verbatimTextOutput(outputId = "res2")
)
server <- function(input, output, session) {
output$res1 <- renderPrint({
input$id1
})
output$res2 <- renderPrint({
input$id2
})
}
shinyApp(ui = ui, server = server)
Update: It does not work either on 0.3.5. However, it works on 0.3.4.
I really like the actionBttn
you've implemented in this great package, and I'd like to add an icon to the left of the label from font awesome like I can with the typical shiny actionButton
. But when I supply the icon
parameter with a value, it just shows the icon text and not the actual icon. I'm trying to put a rocket icon and tried the two methods below with no success. Any suggestions on how to get an icon to properly appear? I'm using version 0.3.6
from CRAN.
# first try: no fa- prefix
actionBttn(inputId = "execProcess",
label = "Launch",
icon = "rocket",
style = "gradient",
color = "primary",
size = "md",
no_outline = FALSE)
# second try: fa-prefix
actionBttn(inputId = "execProcess",
label = "Launch",
icon = "fa-rocket",
style = "gradient",
color = "primary",
size = "md",
no_outline = FALSE)
Pvictor. Sorry it is me again with another question.
I tried to use updatecheckboxinput code to try and change a checkbox from true to false of a checkboxinput inside a dropdownbutton panel.
If this code to update is triggered by a button inside the panel, I.e. the panel is currently open, it works fine. However, I also need to load default on and offs for some checkboxes when the user starts the shiny app, while menu is closed. In this case the updatecheckbox fails to do anything. I even tried suspendwhenhidden = false inside the outoutoption call on both the dropdownbutton ID, the uiOutput id that makes the checkboxes, also tried on checkboxes made directly inside the panel (I.e. not with renderUI) and on the checkboxinput ID tags directly but in non of the scenarios does update checkboxinput (id , .... , value = True ) actually work.
Any clues what I am missing or doing wrong?
Hi All
I'm working on RShiny dashboard development that will eventually be hosted on shiny server. I'm facing an issue with shinyWidgets rendering on LOCAL is fine, but rendering through SERVER link is giving me the following error:
Error: could not find function "checkboxGroupButtons"
On LOCAL run:
`> sessionInfo()
R version 3.2.3 (2015-12-10)
Platform: x86_64-redhat-linux-gnu (64-bit)
Running under: Red Hat Enterprise Linux Server release 6.9 (Santiago)
locale:
[1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C LC_TIME=en_US.UTF-8 LC_COLLATE=en_US.UTF-8
[5] LC_MONETARY=en_US.UTF-8 LC_MESSAGES=en_US.UTF-8 LC_PAPER=en_US.UTF-8 LC_NAME=en_US.UTF-8
[9] LC_ADDRESS=en_US.UTF-8 LC_TELEPHONE=en_US.UTF-8 LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=en_US.UTF-8
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] shinyjs_0.9.1 DT_0.1 shinyBS_0.61 shinyWidgets_0.4.0 covr_1.2.0 testthat_0.11.0
[7] viridisLite_0.1.3 formatR_1.3 zoo_1.7-13 timevis_0.4 stringi_1.1.1 stringr_1.0.0
[13] rvest_0.3.2 xml2_1.0.0 sunburstR_0.6.0 scales_0.4.1 ReporteRs_0.8.6 ReporteRsjars_0.0.2
[19] RColorBrewer_1.1-2 rpivotTable_0.1.5.20 devtools_1.10.0 rmarkdown_1.3 plotly_4.7.1 ggplot2_2.2.1
[25] data.table_1.10.4 jsonlite_0.9.19 htmltools_0.3.5 knitr_1.15.1 shinydashboard_0.5.1 shiny_1.0.0
loaded via a namespace (and not attached):
[1] Rcpp_0.12.5 lattice_0.20-33 tidyr_0.4.1 png_0.1-7 assertthat_0.1 rprojroot_1.2 digest_0.6.9 mime_0.4
[9] R6_2.1.2 plyr_1.8.4 backports_1.0.4 evaluate_0.10 httr_1.1.0 gdtools_0.0.7 lazyeval_0.2.0 miniUI_0.1.1
[17] R.utils_2.3.0 R.oo_1.20.0 htmlwidgets_0.9 munsell_0.4.3 httpuv_1.3.3 rvg_0.1.0 tibble_1.2 crayon_1.3.1
[25] dplyr_0.4.3 R.methodsS3_1.7.1 grid_3.2.3 xtable_1.8-2 gtable_0.2.0 DBI_0.3.1 magrittr_1.5 rex_1.1.1
[33] tools_3.2.3 purrr_0.2.2 crosstalk_1.0.0 parallel_3.2.3 yaml_2.1.13 colorspace_1.2-6 memoise_1.0.0 rJava_0.9-8
`
On SERVER:
`R version 3.2.3 (2015-12-10)
Platform: x86_64-redhat-linux-gnu (64-bit)
Running under: Red Hat Enterprise Linux Server release 6.9 (Santiago)
locale:
[1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C LC_TIME=en_US.UTF-8 LC_COLLATE=en_US.UTF-8
[5] LC_MONETARY=en_US.UTF-8 LC_MESSAGES=en_US.UTF-8 LC_PAPER=en_US.UTF-8 LC_NAME=en_US.UTF-8
[9] LC_ADDRESS=en_US.UTF-8 LC_TELEPHONE=en_US.UTF-8 LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=en_US.UTF-8
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] shinyjs_0.9.1 DT_0.1 shinyBS_0.61 shinyWidgets_0.4.0 covr_1.2.0 testthat_0.11.0
[7] viridisLite_0.1.3 formatR_1.3 zoo_1.7-13 timevis_0.4 stringi_1.1.1 stringr_1.0.0
[13] rvest_0.3.2 xml2_1.0.0 sunburstR_0.6.0 scales_0.4.1 ReporteRs_0.8.6 ReporteRsjars_0.0.2
[19] RColorBrewer_1.1-2 rpivotTable_0.1.5.20 devtools_1.10.0 rmarkdown_1.3 plotly_4.7.1 ggplot2_2.2.1
[25] data.table_1.10.4 jsonlite_0.9.19 htmltools_0.3.5 knitr_1.15.1 shinydashboard_0.5.1 shiny_1.0.0
loaded via a namespace (and not attached):
[1] Rcpp_0.12.5 lattice_0.20-33 tidyr_0.4.1 png_0.1-7 assertthat_0.1 rprojroot_1.2 digest_0.6.9 mime_0.4
[9] R6_2.1.2 plyr_1.8.4 backports_1.0.4 evaluate_0.10 httr_1.1.0 gdtools_0.0.7 lazyeval_0.2.0 miniUI_0.1.1
[17] R.utils_2.3.0 R.oo_1.20.0 htmlwidgets_0.9 munsell_0.4.3 httpuv_1.3.3 rvg_0.1.0 tibble_1.2 crayon_1.3.1
[25] dplyr_0.4.3 R.methodsS3_1.7.1 grid_3.2.3 xtable_1.8-2 gtable_0.2.0 DBI_0.3.1 magrittr_1.5 rex_1.1.1
[33] tools_3.2.3 purrr_0.2.2 crosstalk_1.0.0 parallel_3.2.3 yaml_2.1.13 colorspace_1.2-6 memoise_1.0.0 rJava_0.9-8
`
Moreover, at a different location in dashboard, I'm getting following error in conjunction with the above one... even though, I'm working with shiny 1.0...
Please let me know if you need any additional information regarding this.
Thanks
Nishant
Congrats for the great package!
I was wondering whether there could be support for tooltips for all widgets, not only the drop-down menu. Popular packages to add tooltips to Shiny, such as bsplus, work only for certain ShinyWidgets (e.g. materialSwitch) but not for others (e.g. pickerInput).
Thanks
hi!
great package! Small question, can you add an option to have buttons e.g. a materialSwitch behave like inline elements? Say with an option materialSwitch( ..., inline = TRUE)
. Sometimes you want to place buttons next to each other instead of below each other.
kind regards, Herman
I get strange output when using dropdown with a leaflet map. The dropdown looks then something like this
sliderInput
and textInput
behave very strangely when I add a leaflet map.
This is the code:
library(shiny)
library(leaflet)
library(shinyWidgets)
ui <- fluidPage(
tabsetPanel(
tabPanel("Karte",
leafletOutput("map", height = "150px"),
dropdown(
textInput("Art", label = "Art"),
sliderInput("Jahr", "Jahr", min = 2010, max = 2017,
value = c(2012, 2017))
)
)
)
)
server <- function(input, output, session) {
output$map <- renderLeaflet({
leaflet() %>% addTiles() %>% setView(11, 48, 12)
})
}
shinyApp(ui, server)
Hi, very excited about the possibilities with this package. I want to use awesomeRadio and one of the options has a long text string that forces some unexpected display problems because I can't specify the width of the box similar to the width argument in the radioButtons function in shiny. Is it possible to add this to the function?
I can't seem to use both actionBttn and prettyRadioButtons in the same app. Looks like there could be an incompatibility between the libraries.
library(shiny)
library(shinyWidgets)
server <- function(input, output, session) {
}
ui <- fluidPage(
actionBttn(inputId = 'but1', label = 'but1'),
prettyRadioButtons(inputId = 'rad1', label = 'rad1', choices = c(1,2,3), inline = TRUE, shape = 'square')
)
shinyApp(ui, server)
library(shiny)
library(shinyWidgets)
server <- function(input, output, session) {
}
ui <- fluidPage(
prettyRadioButtons(inputId = 'rad1', label = 'rad1', choices = c(1,2,3), inline = TRUE, shape = 'square'),
actionBttn(inputId = 'but1', label = 'but1')
)
shinyApp(ui, server)
Hello,
I love the package, it makes my apps look much more appealing, thank you for sharing it!
I updated to the latest version of shinyWidgets today (0.3.6) and the awesomeCheckboxGroup input is no longer returning anything if inline=FALSE. However if inline=TRUE it correctly returns the selections. I noticed this on my app as well as on shinyWidgetsGallery(). I believe this is probably a bug in the coding, though I also wondered if it was a conflict with one of my other packages?
Thank you!
Hello !
Would it be possible to access the reset button of the searchInput
as a proper input ?
I would like to attach an event to it other than just reseting the searchfield, using observeEvent
.
On the simpliest form, it would be something like so :
library(shiny)
library(shinyWidgets)
ui <- fluidPage(
sidebarLayout(
sidebarPanel(
textInput(inputId="text", value=NULL),
searchInput(inputId ="search", value=NULL)
)
)
)
server <- function(input, output) {
observeEvent(search$reset){
updateTextInput("text", value = "RESET!")
}
}
shinyApp(ui = ui, server = server)
Maybe is it only possible in Jquery ?
Thanks !
First of all, I really like the widget!
It's the user friendliest way I know to select and deselect items.
This is more a question than a issue: Is it possible to set the columns below each other instead of next to each other?
For instance:
sliderTextInput(inputId = "year", grid = TRUE, label = "Select year", choices = c("2012", "2014", "2016"))
There appears to be a space between the 2 and the 0. Is there an option to remove the spacing?
library(shiny)
library(shinydashboard)
library(shinyWidgets)
ui <- dashboardPage(
dashboardHeader(),
dashboardSidebar(
sidebarMenuOutput("menu"),
sliderInput("x", "Outside of menu", 1, 100, 50)),
dashboardBody()
)
server <- function(input, output) {
output$menu <- renderMenu({
sidebarMenu(id = "sidebarmenu",
menuItem("A", tabName = "a", icon = icon("group", lib="font-awesome")),
menuItem("B", tabName = "b", icon = icon("check-circle", lib = "font-awesome")),
conditionalPanel("input.sidebarmenu === 'b'",
sliderInput("c", "Under sidebarMenu", 1, 100, 50),
pickerInput(
inputId = "p1",
label = "Select all option",
choices = rownames(mtcars),
multiple = TRUE,
options = list(`actions-box` = TRUE,`selected-text-format` = "count > 3")
)
)
)
})
}
shinyApp(ui, server)
Thanks for the package, I'm trying to render pickerInput, but it doesn't seem to work under tab b. Any thoughts to solve this?
Cheers
Hi,
Thank you for this amazing package.
I am trying to place a checkboxGroupButtons
inside of a dropdownButton
but the checkboxGroupbutton
does not work as expected. I am not able to select more than one button at a time.
Following is a minimal example:
library(shiny)
library(shinyWidgets)
ui <- fluidPage(
dropdownButton(icon = icon("gear"),
tooltip = tooltipOptions(title = "Settings"), circle = TRUE, status = "primary",
selectInput(inputId = "SI_Element", label = "Element:", choices = c("Title", "Body")),
selectInput(inputId = "SI_FontFam", label = "Choose Font Family:",
choices = c("Sans", "Times New Roman"), selected = "Sans"),
numericInput(inputId = "Num_FontSiz", label = "Font Size:", value = 14, min = 1,max = 25),
checkboxGroupButtons(inputId = "CBK_Button", label = "Font Style:",
choices = c(`<i class='fa fa-bold'></i>` = "bold",
`<i class='fa fa-italic'></i>` = "italic",
`<i class='fa fa-underline'></i>` ="underline"))
)
)
server <- function(input,output){
}
shinyApp(ui = ui, server = server)
This has completely replaced the original Shiny input widgets for me!
I have one question about your multiInput() widget. This is less of an "issue" but more of a "feature request". I really like the look of the two column selector. Is it possible to only allow 1 item selected (i.e. disable multiple). Although the name seems to imply "multiple", the UI of the two column view is very attractive.
I attempted to use shinyjs::disable()
on it without success. Is it possible to have an option to only allow 1 choice selected and the selected choice displayed on the right? If a second choice is selected, then remove & replace the previously selected.
I was wondering why the HTML = T option on the sendSweetAlert function has been remove? Is there a solution to use the same code as before to have some html text display in the sweet alert?
Also, is it possible not to close the alert when we click outside the popup?
Thanks
If you try to open the select menu of a pickerInput within a dropdownButton, the dropdownButton collapses.
For example, this code does not work:
ui <- fluidPage(
dropdownButton(
pickerInput(inputId = "letters", label = "Letters",
choices = LETTERS,
options = list(title = "Select"),
multiple = TRUE),
circle = TRUE, status = "danger", icon = icon("sliders", lib = "font-awesome"), width = "300px",
tooltip = tooltipOptions(title = "Drop Down"))
)
server <- function(input, output) {}
shinyApp(ui, server)
but this code does:
ui <- fluidPage(
pickerInput(inputId = "letters", label = "Letters",
choices = LETTERS,
options = list(title = "Select"),
multiple = TRUE)
)
server <- function(input, output) {}
shinyApp(ui, server)
Firstly thank you for sharing - this is an excellent package. I'm hoping the answer to my question below is easy, as it has me a little stumped due to little knowledge of how the jQuery is being built up.
I've setup a dropdownButton and want to be able to use the p
dropdownButton(
"Select adverts to drill down",
circle = TRUE, status = "default", icon = icon("sliders"), width = "300px",
tooltip = tooltipOptions(title = "Click to see inputs !"),
uiOutput("choose_adverts")
)
I want to be able to render a pickerInput in this box, with dynamically updated list of choices
pickerInput(inputId = "Adverts",
label = "Adverts",
choices = adverts, # a list of strings
options = list(`actions-box` = TRUE, `live-search` = TRUE),
multiple = TRUE)
It currently renders the picker but does not populate choices.
Are you able to suggest what I might try to get it to work?
Hi,
The default size of dropdownButton seems to be too large, and btn-lg was automatically added to the component. Is it possible to allow class like small / large / x-small / x-large to that user can decide the size to go with?
Hi
Thanks so much for the amazing package.
Please see the example below (I edited your example for pickerInput
):
library(shiny)
library(shinyWidgets)
test = "Jean Mare’"
ui <- fluidPage(
pickerInput(inputId = "somevalue", label = "A label", choices = test),
verbatimTextOutput("value"),
actionBttn('update', 'Update')
)
server <- function(input, output, session) {
output$value <- renderPrint({ input$somevalue })
observeEvent(input$update, {
updatePickerInput(session = session,
inputId = 'somevalue',
choices = test)
})
}
shinyApp(ui, server)
The issue as far as I can tell is the apostrophe http://www.fileformat.info/info/unicode/char/92/index.htm. However, I am wondering why pickerInput displays an unknown character box whereas updatePickerInput displays nothing. Both display:
[1] "Jean Mare<U+0092>"
in the verbatimTextOutput.
The encoding seems to be latin1 as below:
> test
[1] "Jean Mare'"
> Encoding(test)
[1] "latin1"
It does not end there though...
If I run that script directly in the console I get the above but if I create an app and run the script then pickerInput displays Jean Mare’ correctly and verbatimTextOutput displays the unknown character box [1] "Jean Mare�"
, while updatePickerInput displays the unknown character box and [1] "Jean Mare<U+0092>"
in the verbatimTextOutput.
Finally, my app at https://elib.shinyapps.io/EncodingBug/ displays Jean Mare’ for both pickerInput and updatePickerInput and [1] "Jean Mare’" for verbatimTextOutput.
for comparison, the basic selectInput and updateSelectInput both display Jean Mare’ but [1] "Jean Mare�"
in the verbatimTextOutput. A breakpoint for both displays:
Browse[2]> input$somevalue
[1] "Jean Mare’"
Here's the real problem for me. For pickerInput it displays the same above correctly but for updatePickerInput it displays:
Browse[2]> input$somevalue
[1] "Jean Mare\u0092"
That really is my biggest problem as I cannot use that value to get the relevant data. I could hard-code it in this case but thought there might be something more to it.
I am sorry this is so long but I decided to try be as comprehensive as possible. There may be OS differences at play too. I am using a Windows 10 64-bit.
Looking forward to hearing from you,
Eli
Would this not be a "quick" change?
dropdownButton <- function (... ,inputId=NULL, circle = TRUE, status = "default", size = "default",
icon = NULL, label = NULL, tooltip = FALSE, right = FALSE,
up = FALSE, width = NULL)
{
status <- match.arg(arg = status, choices = c("default",
"primary", "success", "info", "warning", "danger"))
size <- match.arg(arg = size, choices = c("default", "lg",
"sm", "xs"))
buttonID <- inputId
html_ul <- list(class = paste("dropdown-menu", ifelse(right,
"dropdown-menu-right", "")), class = "dropdown-shinyWidgets",
id = paste("dropdown-menu", buttonID, sep = "-"), style = if (!is.null(width)) paste0("width: ",
htmltools::validateCssUnit(width), ";"), aria-labelledby
= buttonID,
lapply(X = list(...), FUN = htmltools::tags$li, style = "margin-left: 10px; margin-right: 10px;"))
if (circle) {
html_button <- circleButton(inputId = buttonID, icon = icon,
status = status, size = size, class = "dropdown-toggle",
data-toggle
= "dropdown")
}
else {
html_button <- list(class = paste0("btn btn-", status,
" dropdown-toggle "), class = if (size == "default") paste0("btn-",
size), type = "button", id = buttonID, data-toggle
= "dropdown",
aria-haspopup
= "true", aria-expanded
= "true",
list(icon, label), tags$span(class = "caret"))
html_button <- do.call(htmltools::tags$button, html_button)
}
if (identical(tooltip, TRUE))
tooltip <- tooltipOptions(title = label)
if (!is.null(tooltip) && !identical(tooltip, FALSE)) {
tooltip <- lapply(tooltip, function(x) {
if (identical(x, TRUE))
"true"
else if (identical(x, FALSE))
"false"
else x
})
tooltipJs <- htmltools::tags$script(sprintf("$('#%s').tooltip({ placement: '%s', title: '%s', html: %s });",
buttonID, tooltip$placement, tooltip$title, tooltip$html))
}
else {
tooltipJs <- ""
}
dropdownTag <- htmltools::tags$div(class = ifelse(up, "dropup",
"dropdown"), html_button, do.call(htmltools::tags$ul,
html_ul), tooltipJs)
attachShinyWidgetsDep(dropdownTag, "dropdown")
}
Hi Team
I'm using ShinyWidgets library in my RShiny dashboard. While it works when I locally 'runApp' in browser, I'm getting the following error when my start my dashboard through a server link
ERROR: package or namespace load failed for ‘shinyWidgets’
I've explicitly installed and loaded following dependency libraries as well, but the problem persists:
shinydashboard, formatR, viridisLite, RColorBrewer, testthat, and covr
Following is the sessionInfo of local run
`
sessionInfo()
R version 3.2.3 (2015-12-10)
Platform: x86_64-redhat-linux-gnu (64-bit)
Running under: Red Hat Enterprise Linux Server release 6.9 (Santiago)
locale:
[1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C LC_TIME=en_US.UTF-8 LC_COLLATE=en_US.UTF-8 LC_MONETARY=en_US.UTF-8
[6] LC_MESSAGES=en_US.UTF-8 LC_PAPER=en_US.UTF-8 LC_NAME=en_US.UTF-8 LC_ADDRESS=en_US.UTF-8 LC_TELEPHONE=en_US.UTF-8
[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=en_US.UTF-8
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] shinyWidgets_0.4.0 shinyjs_0.9.1 RRWE_0.1-1 RODBC_1.3-12 DT_0.1 shinyBS_0.61 zoo_1.7-13
[8] timevis_0.4 stringr_1.0.0 rvest_0.3.2 xml2_1.0.0 sunburstR_0.6.0 scales_0.4.1 ReporteRs_0.8.6
[15] ReporteRsjars_0.0.2 RColorBrewer_1.1-2 rpivotTable_0.1.5.20 devtools_1.10.0 rmarkdown_1.3 plotly_4.7.1 ggplot2_2.2.1
[22] data.table_1.10.4 jsonlite_0.9.19 htmltools_0.3.5 knitr_1.15.1 shinydashboard_0.5.1 shiny_1.0.0
loaded via a namespace (and not attached):
[1] purrr_0.2.2 rJava_0.9-8 lattice_0.20-33 colorspace_1.2-6 miniUI_0.1.1 viridisLite_0.1.3 yaml_2.1.13 R.oo_1.20.0
[9] DBI_0.3.1 R.utils_2.3.0 gdtools_0.0.7 plyr_1.8.4 munsell_0.4.3 gtable_0.2.0 R.methodsS3_1.7.1 htmlwidgets_0.9
[17] evaluate_0.10 memoise_1.0.0 crosstalk_1.0.0 httpuv_1.3.3 parallel_3.2.3 Rcpp_0.12.5 xtable_1.8-2 backports_1.0.4
[25] mime_0.4 png_0.1-7 digest_0.6.9 stringi_1.1.1 dplyr_0.4.3 grid_3.2.3 rprojroot_1.2 tools_3.2.3
[33] magrittr_1.5 lazyeval_0.2.0 tibble_1.2 tidyr_0.4.1 rvg_0.1.0 assertthat_0.1 httr_1.1.0 R6_2.1.2
`
Please let me know if you need any additional information regarding this.
Thanks
Nishant Gupta
Hi, love the package, use it a lot, thank you very much for creating it! I have a small issue where I need to force the sw-dropdown
to click open on client visit as I have dependencies under renderUI
. How can I achieve this? As can be seen from my example the uiOutput("S1")
doesnt render until the dropdown
is clicked, but uiOutput("S2")
does not.
library("shiny")
library("shinyWidgets")
ui <- fluidPage(
dropdown(style = "unite", icon = icon("gear"),status = "danger", width = "300px",
uiOutput("S1")
),
uiOutput("S2")
)
server <- function(input, output, session) {
output$S1 <- renderUI({
radioGroupButtons("Species", label = "Species", choices = unique(iris$Species), status = "success")
})
output$S2 <- renderUI({
radioGroupButtons("Species2", label = "Species2", choices = unique(iris$Species), status = "success")
})
}
shinyApp(ui = ui, server = server)
Hi pvictor,
I found out that the dialog window under a dropdownButton doesn't seem to have an easyclose = T/F option,
related to that, is there a way to trigger the opening of the window from the server side? I have some code functionality that closes a modalDialog that is opened by a button inside the dropdownbutton modal window. Closing this second modalDialog sadly also closes the dropdownButton panel, which I would like to be able to re-open, or keep open even when it is closed by other modals.
Would you know a solution for this in combination with your widget?
Hello,
I have been trying the dropdownbutton in my app to see if it would be a nice improvement.
In my app I construct a plotly plot from a custom fuction that takes a lot of input$variables to make the plot, i.e. marker size, axis titles etc are all coming from options the user has to customize the app.
In the test version, all these inputs are in the main panel, so today I tried to put them inside a dropdownButton. However, it seems that non of the input elements register (i.e. input values not available) until the menu is opened. This means for me that on start up of the app, no plot can be made until the dropdownButton menu is opened.
Is this normal?
In the code below the checkboxGroupButtons()
line works within renderUI()
, but not the pickerInput()
line.
library(shiny)
library(tidyverse)
library(forcats)
tmp <- tibble(Cat = c(rep("IV", 5), rep("III", 5)),
Subcat = LETTERS[1:10])
tmp <- mutate(tmp, Cat = factor(Cat), Subcat = factor(Subcat))
ui <- fluidPage(
titlePanel(""),
sidebarLayout(
sidebarPanel(
checkboxGroupButtons("Cat", "Category:", choices = levels(tmp$Cat), selected = levels(tmp$Cat)),
uiOutput("Subcat")
),
mainPanel(tableOutput("Table"))
)
)
server <- function(input, output) {
output$Subcat <- renderUI({
tmp <- tmp %>%
filter(Cat %in% input$Cat) %>%
mutate(Subcat = fct_drop(Subcat))
# pickerInput("what", label = "hello?", choices = levels(tmp$Subcat), selected = levels(tmp$Subcat), multiple = TRUE) #Does not appear
checkboxGroupButtons("what", label = "hello?", choices = levels(tmp$Subcat), selected = levels(tmp$Subcat)) #Appears
})
output$Table <- renderTable({ filter(tmp, Cat %in% input$Cat, Subcat %in% input$what)})
}
shinyApp(ui = ui, server = server)
As it is, it's not clear how to get the code for the 2 examples being currently displayed in "Other stuffs".
First of all, thank you for your wonderful package !
I am currently using the pickerInput, with grouped choices (in a list).
I am looking for a way to select/unselect a whole groupe in one click (ex. by clicking on the name of the group or something else...)
In the following example I would like to quickly select all the "listA" choices.
library("shiny")
library("shinyWidgets")
ui <- fluidPage(
br(),
pickerInput(
inputId = "p1",
label = "Default",
multiple = TRUE,
choices = list("listA"=rownames(mtcars)[1:16], "listB"=rownames(mtcars)[17:32]),
selected = rownames(mtcars)
)
)
server <- function(input, output, session) {}
shinyApp(ui = ui, server = server)
Thank you
Elise
Special characters like "&" , ">", and "<" are displayed as "$amp;", "<", and ">". I believe this is related to UTF encoding. For selectInput / selectizeInput in Shiny, special characters are treated correctly and I never had problems with th I am not sure what makes pickerInput not behave the same
library(shiny)
library(shinyWidgets)
server <- function(input, output) {
output$pickerSelectionOutput <- renderText({
paste("pickerInput value: ", input$pickerSelection)
})
output$selectSelectionOutput <- renderText({
paste("selectInput value: ", input$selectSelection)
})
}
ui <- fluidPage(
sidebarLayout(
sidebarPanel(
pickerInput("pickerSelection", "Has Special Characters",
choices =
list("Special Character: &" = c("one & two" = "three & four"),
"Special Character: <, <=" = c("one <, <= two" = "three <, <= four"),
"Special Character: >, >=" = c("one >, >= two" = "three >, >= four")
)
),
selectInput("selectSelection", "Has Special Characters",
choices =
list("Special Character: &" = c("one & two" = "three & four"),
"Special Character: <, <=" = c("one <, <= two" = "three <, <= four"),
"Special Character: >, >=" = c("one >, >= two" = "three >, >= four")
))
),
mainPanel(
wellPanel(
textOutput("pickerSelectionOutput"),
textOutput("selectSelectionOutput")
))
)
)
shinyApp(ui = ui, server = server)
p.s. the library is very useful, especially the dropdownButton()!
Do you think there's a way to add adateInput
picker to your package such that individual dates can use custom CSS to reactively show icons/specific values?
I'm basically trying to create something like the Google flights calendar that shows a value associated with each date
My plan for now is to use renderUI
and change the CSS in one of your pickerInput
select boxes. I'd love to contribute and create a proper calendar widget, but not even sure where to begin, have very limited jQuery
knowledge.
Hi; first of all, thank you very much for shinyWidgets
; thanks to it I am building quite fast a rather complex website; first testing it locally, and then uploading the app to my own server in AWS.
The thing is, I have observed that the function switchInput()
not always work, and instead the website renders a default Shiny checkbox (that is not reactive; it can be checked / unchecked, but it doesn't trigger the desired action).
After some experimentation, what I have observed is:
switchInput()
does work locally, but not in the AWS server. I have tried with a couple of virtual machines, and the bug seems reproducible.renderUI()
function. If I code a switchInput()
in ui.R
instead that in server.R
, everything is ok.shinyWidgets
work perfectly, wheter in local or in the cloud, inside or outside renderUI()
. I haven't been exhaustive, but dropdown menus, checkboxgroup or buttons do work.materialSwitch()
also works fine, so I have a fancy substitute for switchInput()
. Anyway, I thought that you would like to try to reproduce my observations.
In the most recent CRAN version 0.3.3.
Warning: Error in FUN: could not find function "btn_wrapper"
Stack trace (innermost first):
84: FUN
83: lapply
82: generateCBGB
81: tag
80: tags$div
79: tag
78: tags$div
77: tagList
76: <Anonymous>
75: do.call
74: tagList
73: widget_wrapper [/home/leon/R/x86_64-redhat-linux-gnu-library/3.3/shinyWidgets/examples/shinyWidgets/global.R#64]
72: tag
71: tags$div
70: div
69: tag
68: tags$div
67: div
66: tag
65: tags$div
64: div
63: box
62: box_wrapper [/home/leon/R/x86_64-redhat-linux-gnu-library/3.3/shinyWidgets/examples/shinyWidgets/global.R#81]
61: tag
60: tags$div
59: div
58: column
57: tag
56: tags$div
55: div
54: fluidRow
53: tag
52: tags$div
51: div
50: tabItem
49: lapply
48: tabItems
47: tag
46: tags$section
45: tag
44: tags$div
43: div
42: dashboardBody
2: shiny::runApp
1: shinyWidgetsGallery
Error : could not find function "btn_wrapper"
I was having immense struggles seeing what the options to pickerInput were, event after looking at the source code. Documentation would be lovely - because the overlay title being a concatenation of the selected values is obnoxious in my use case.
Thanks.
Great work first of all!
I noticed my older app built in 0.3.2 behaves a little differently after I upgraded shinyWidgets to 0.3.4+. searchInput in shinydashboard's sidebar now gets separated into 3 components: Textbox, search button and remove button. This is likely due to changes from tags to htmltools::tags
I am no shiny expert but this is likely the only changes made that affects the searchInput functionality.
Hello!
pickerInput(inputId = "values", label = "Select values", choices = c(1, 2, 3, 4, 5))
If I select values in next order: 5,1,2,4. And get values from input they will be sorted
Is there any way to disable sorting then getting selected values of pickerInput?
Using a '.' in your pickerInput inputId, when using renderUI to render the pickerInput, results in the pickerInput dropdown menu not showing up. The default value is evaluated and it does show up in the shiny.reactlog, however.
I have made a demo to show this behavior:
library(shiny)
library(shinyWidgets)
# Define UI for application that draws a histogram
ui <- fluidPage(
# Application title
titlePanel("Old Faithful Geyser Data"),
# Sidebar with a slider input for number of bins
sidebarLayout(
sidebarPanel(
uiOutput("picker1"),
uiOutput("picker2")
),
# Show a plot of the generated distribution
mainPanel(
plotOutput("distPlot")
)
)
)
# Define server logic required to draw a histogram
server <- function(input, output) {
output$picker1 <- renderUI({
#Renders
pickerInput(inputId = "old_faithfull",
label = "Bins",
choices = 1:10)
})
output$picker2 <- renderUI({
#Does not render
pickerInput(inputId = "old.faithfull",
label = "Times",
choices = 1:2)
})
output$distPlot <- renderPlot({
# generate bins based on input$bins from ui.R
x <- faithful[, 2]
bins <- seq(min(x), max(x), length.out = as.numeric(input$old_faithfull)*as.numeric(input$old.faithfull) + 1)
# draw the histogram with the specified number of bins
hist(x, breaks = bins, col = 'darkgray', border = 'white')
})
}
# Run the application
shinyApp(ui = ui, server = server)
> sessionInfo()
R version 3.4.0 (2017-04-21)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Ubuntu 14.04.5 LTS
Matrix products: default
BLAS: /usr/lib/openblas-base/libblas.so.3
LAPACK: /usr/lib/lapack/liblapack.so.3.0
locale:
[1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C LC_TIME=en_US.UTF-8 LC_COLLATE=en_US.UTF-8 LC_MONETARY=en_US.UTF-8
[6] LC_MESSAGES=en_US.UTF-8 LC_PAPER=en_US.UTF-8 LC_NAME=C LC_ADDRESS=C LC_TELEPHONE=C
[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] shinyWidgets_0.2.0 shiny_1.0.3
loaded via a namespace (and not attached):
[1] compiler_3.4.0 R6_2.1.3 htmltools_0.3.6 tools_3.4.0 Rcpp_0.12.11 jsonlite_1.5 digest_0.6.12 xtable_1.8-2 httpuv_1.3.3
[10] mime_0.5
Very strange bug, took me a while to figure out what was going on ;).
I haven't tested any of the other widgets for this bug.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.