Git Product home page Git Product logo

shinyvs's Introduction

shinyvs

Lifecycle: experimental R-CMD-check

Virtual Select widget for shiny applications built for performance. Powered by virtual-select.

๐Ÿšจ ๐Ÿšจ ๐Ÿšจ This widget is now available in package shinyWidgets (>= 0.7.0 on CRAN) ๐Ÿšจ ๐Ÿšจ ๐Ÿšจ

Installation

You can install the development version of shinyvs from GitHub with:

# install.packages("remotes")
remotes::install_github("dreamRs/shinyvs")

Example

Minimal example with 97310 choices from babynames package:

library(shiny)
library(shinyvs)

ui <- fluidPage(
  tags$h2("Virtual Select example"),
  
  virtualSelectInput(
    inputId = "single",
    label = "Single select (with 97310 choices) :",
    choices = sort(unique(babynames::babynames$name)),
    search = TRUE
  ),
  verbatimTextOutput("res_single")
)

server <- function(input, output, session) {
  output$res_single <- renderPrint(input$single)
}

shinyApp(ui, server)

Development

This package use {packer} to manage JavaScript assets, see packer's documentation for more.

Install nodes modules with:

packer::npm_install()

Modify srcjs/inputs/virtual-select.js, then run:

packer::bundle()

Re-install R package and try virtualSelectInput() function.

shinyvs's People

Contributors

pvictor avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

shinyvs's Issues

Even in single mode, pressing the group name seems to result in multiple selection.

Thank you for the fantastic package.
Even in single mode, pressing the group name seems to result in multiple selection.

image

library(shiny)
library(shinyvs)

choices <- list(Human = c("Han Solo","Darth Vader","Luke Skywalker"), Robot = "R2-D2", Etc = c("Chewbacca","Boba Fett"))

ui <- fluidPage(
  tags$h2("Virtual Select example"),
  
  virtualSelectInput(
    inputId = "single",
    label = NULL,
    choices = choices,
    search = TRUE,
    multiple = FALSE
  ),
  verbatimTextOutput("res_single")
)

server <- function(input, output, session) {
  output$res_single <- renderPrint(input$single)
}

shinyApp(ui, server)

tagAppendAttributes doesnt add class

There seems to be a difference with pickerInput when using tagAppendAttributes for example. It's a bug/feature of tagList

tagAppendAttributes(class = "extraclass",
  tagList("asd"))

asd
extraclass

tagAppendAttributes(class = "extraclass",
  tags$div("asd"))

<div class="extraclass">asd</div>

So maybe we can switch the tagList to tags$div ?

Plans for CRAN release

Hi! Thank you for developing this great package - it allows to overcome many performance issues in Shiny Apps.

I wonder if you plan to release the package to CRAN?

I plan to release there one of my packages that imports shinyvs, so I'll need to wait for shinyvs release first.

Please let me know if you know the answer already.
I'd be also happy to contribute to shinyvs (doing required checks and fixes) if it helps.

Labels with HTML

Hey folks, this package is awesome! It is something that I really need in my current project.

I think the one crucial thing that I didn't manage to do was to include HTML in the labels, something like this:

library(shiny)
library(shinyvs)

ui <- fluidPage(
  tags$h2("Virtual Select example"),
  
  virtualSelectInput(
    inputId = "single",
    label = "Single select (with 97310 choices) :",
    choices = list(label=c("A <br> second row info",
                           "B <br> second row indo"), 
                   value=1:2) |> purrr::transpose(),
    search = TRUE
  ),
  verbatimTextOutput("res_single")
)

server <- function(input, output, session) {
  output$res_single <- renderPrint(input$single)
}

shinyApp(ui, server)

Here I'm trying to make labels with more than one row.

Any help will be much appreciated.

Problem when there is only one group member (updateVirtualSelect also problem)

Thank you for the fantastic package.
There seems to be a problem with dropdown when there is only one group member. The names are separated.

image

image

library(shiny)
library(shinyvs)

ui <- fluidPage(
  tags$h2("Virtual Select example"),
  
  choices <- list(Human = c("Han Solo","Darth Vader","Luke Skywalker"), Robot = "R2-D2", Etc = c("Chewbacca","Boba Fett"))
  
  virtualSelectInput(
    inputId = "single",
    label = NULL,
    choices = choices,
    search = TRUE
  ),
  verbatimTextOutput("res_single")
)

server <- function(input, output, session) {
  output$res_single <- renderPrint(input$single)
}

shinyApp(ui, server)

Input/output ordering issues

Hey folks, shinyvs seem to have some input/output ordering issues. It forces the order to be the same as the one in value passed to choices. For example:

library(shiny)
library(shinyvs)

ui <- fluidPage(

  shinyvs::virtualSelectInput(
    inputId = "vs_inputs",
    label = " ",
    html = TRUE,
    choices = data.frame(label = c("val4","val3","val2","val1"),
                         value = c(4, 3, 2, 1)) |> purrr::transpose(),
    selected = c(2,4,3),
    multiple=TRUE,
    search = TRUE,
    position = "top right", 
    disableSelectAll = TRUE
  ),

  verbatimTextOutput("selected_items")
)

server <- function(input, output, session){
  output$selected_items <- renderText({input$vs_inputs})
}

shiny::shinyApp(ui, server)

Instead of outputting 2, 4, 3 which is the order passed to selected, it returns 4, 3, 2, as shown in the figure above:
image

Also, the labels in the tooltip are being automatically reordered as well, while I believe it is important to follow the order the user selected (unless specified otherwise), which is the standard. Is there an option to do that? I could not find one.

Another detail is that the output order actually follows the input order selected later interactively but not the initial selected order passed to selected.

As an aside, position and disableSelectAll parameters seem to have no effect. Am I missing something here or do you want me to open separate issues for that?

Thank you

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.