All Projects → ayayron → shinydnd

ayayron / shinydnd

Licence: other
Creating drag and drop elements in Shiny

Programming Languages

r
7636 projects
javascript
184084 projects - #8 most used programming language
CSS
56736 projects

Projects that are alternatives of or similar to shinydnd

tweet-conf-dash
A shiny twitter conference dashboard
Stars: ✭ 117 (+31.46%)
Mutual labels:  shiny, shinyapps
shiny.fluent
Microsoft's Fluent UI for Shiny apps
Stars: ✭ 170 (+91.01%)
Mutual labels:  shiny, shiny-apps
financial-asset-comparison-tool
R Shiny app to compare the relative performance of cryptos and equities.
Stars: ✭ 97 (+8.99%)
Mutual labels:  shiny, shiny-apps
PlotsOfData
Shiny App for comparison of samples
Stars: ✭ 47 (-47.19%)
Mutual labels:  shiny, shiny-apps
capm shiny
Demo project of creating an interactive analytical tool for stock market using CAPM.
Stars: ✭ 31 (-65.17%)
Mutual labels:  shiny, shinyapps
PlotTwist
PlotTwist - a web app for plotting and annotating time-series data
Stars: ✭ 21 (-76.4%)
Mutual labels:  shiny, shiny-apps
shinyFilters
Cascading filter modules for Shiny
Stars: ✭ 13 (-85.39%)
Mutual labels:  shiny, shiny-apps
shinyapps
code to reproduce my shiny apps
Stars: ✭ 28 (-68.54%)
Mutual labels:  shiny, shinyapps
learning R
List of resources for learning R
Stars: ✭ 32 (-64.04%)
Mutual labels:  shiny, shiny-apps
machLearn
Machine learning dashboard created with R/shiny
Stars: ✭ 74 (-16.85%)
Mutual labels:  shiny, shiny-apps
shinyAppTutorials
a collection of shiny app demonstrations 📊
Stars: ✭ 50 (-43.82%)
Mutual labels:  shiny, shinyapps
shiny crud
Example Shiny apps implementing CRUD database functionality
Stars: ✭ 88 (-1.12%)
Mutual labels:  shiny, shiny-apps
antaresViz
ANTARES Visualizations
Stars: ✭ 19 (-78.65%)
Mutual labels:  shiny, shiny-apps
tablerDash
tabler dashboard template for shiny
Stars: ✭ 72 (-19.1%)
Mutual labels:  shiny, shinyapps
memory-hex
Hex Memory Game in Shiny
Stars: ✭ 29 (-67.42%)
Mutual labels:  shiny, shiny-apps
workshops-setup cloud analytics machine
Tips and Tricks to setup a cloud machine for Analytics and Data Science with R, RStudio and Shiny Servers, Python and JupyterLab
Stars: ✭ 12 (-86.52%)
Mutual labels:  shiny, shiny-apps
shiny-apps
Some of my Shiny apps for fun
Stars: ✭ 54 (-39.33%)
Mutual labels:  shiny, shiny-apps
RagGrid
R interface to ag-grid.
Stars: ✭ 31 (-65.17%)
Mutual labels:  shiny
shinyhttr
Give httr::progress the ability to talk to shinyWidgets::progressBar.
Stars: ✭ 32 (-64.04%)
Mutual labels:  shiny
Shinycssloaders
⌛ Add loading animations to a Shiny output while it's recalculating
Stars: ✭ 248 (+178.65%)
Mutual labels:  shiny

shinyDNDBuild Status

shinyDND is an R package to create Shiny drag and drop elements in R.

See the example at: https://ayayron.shinyapps.io/dragndrop/. That example shown below is also available in the package /examples/app.R. (It will be added to shinyapps.io once the package is accepted in CRAN.)

The package can be installed and loaded with:

devtools::install_github('ayayron/shinydnd')
library(shinyDND)

Functions

  • dragUI: Draggable div element.
  • dragSetUI: Set of draggable div elements.
  • dropUI: Droppable div element.

dragUI

Draggable div elements can now be easily created in your shiny code by running:

dragUI("div6", "bar")

where div6 is the name of the div element and bar is the text in the element. The elements can be styled using css (the class is currently dragelement) and setting the class parameter.

dragUI("div5", "foo", style = "background-color:red", class = "dragelement")

Also, the elements don't have to just be text. You can use HTML tag elements (e.g. tags$a("mylink", )) or HTML() inside the element.

dragUI("div4",tags$a("a",href = "foo"))

dropUI

A drop area can be created for these draggable elements with the function:

dropUI("div3")

If you try to drop more than one draggable element into a drop area, they are placed horizontally. If you want to place them vertically, you can add the parameters row_n = X and col_n = Y, where X and Y are the number of rows and columns, respectively, that will be generated in the drop area.

dropUI("div4",row_n = 4, col_n = 3) 

The drop area can be made reactive, such that when something is dragged into it a reactive function will run. Using the observeEvent function where the event is the input name of the dropUI div, can trigger a server action. Here, if you drag each element into the dropUI it will print the name of the element.

observeEvent(input$div2, {
    output$foo = renderText(paste("The dropUI element currently contains:", input$div2))
})

Similar to the dragUI elements, the element can be styled using the style parameter or the class parameter (the class is currently dropelement) in css.

dragSetUI

To make it easier to create multiple draggable elements there is a secoond function called DragSetUI. Here you can specify each of the elements in a list and it will create multiple elements with the div name prefix you feed it.

dragSetUI("div1", textval = list("foo", tags$a("a", href = "bar"), "baz"))

Example

After installing the package you can run this example app: runApp(system.file('examples', package='shinyDND')). For readability, this code below excludes the explanations above.

library(shiny)
library(shinyDND)

# Define UI for application that draws a histogram
ui <- shinyUI(
  mainPanel(
    h2("DragUI"),
    dragUI("div6","bar"),
    dragUI("div5","foo", style = "background-color:red", class = "dragelement"),
    dragUI("div4",tags$a("a",href = "foo")),
    h2("Drop UI"),
    dropUI("div3",row_n = 4, col_n = 3),
    h2("Drop UI Reactive"),
    dropUI("div2"),
    h2("DragSetUI"),
    dragSetUI("div1", textval = list("foo",tags$a("a",href = "bar"),"baz"))
  )
)

# server with reactive for observing reactive drop event
server = shinyServer(function(input, output,session) {
  observeEvent(input$div2,{
    output$foo = renderText(
      paste("The dropUI element currently contains:", input$div2))
  })
})

# Run the application 
shinyApp(ui = ui, server = server)
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].