shinydnd

Creating drag and drop elements in Shiny

https://github.com/ayayron/shinydnd

Science Score: 10.0%

This score indicates how likely this project is to be science-related based on various indicators:

  • CITATION.cff file
  • codemeta.json file
  • .zenodo.json file
  • DOI references
  • Academic publication links
  • Committers with academic emails
    1 of 4 committers (25.0%) from academic institutions
  • Institutional organization owner
  • JOSS paper metadata
  • Scientific vocabulary similarity
    Low similarity (12.0%) to scientific vocabulary

Keywords

draggable-elements drop-elements r shiny shiny-apps shinyapps
Last synced: 9 months ago · JSON representation

Repository

Creating drag and drop elements in Shiny

Basic Info
  • Host: GitHub
  • Owner: ayayron
  • Language: R
  • Default Branch: master
  • Size: 65.4 KB
Statistics
  • Stars: 92
  • Watchers: 8
  • Forks: 26
  • Open Issues: 6
  • Releases: 0
Topics
draggable-elements drop-elements r shiny shiny-apps shinyapps
Created almost 10 years ago · Last pushed over 8 years ago
Metadata Files
Readme

README.md

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: r 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: r 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. r 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", href="#mylink")) or HTML() inside the element.

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

dropUI

A drop area can be created for these draggable elements with the function: r 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. r 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. r 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. r 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. ```r 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",rown = 4, coln = 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) ```

Owner

  • Name: Aaron Hoffer
  • Login: ayayron
  • Kind: user
  • Location: San Francisco

GitHub Events

Total
Last Year

Committers

Last synced: over 1 year ago

All Time
  • Total Commits: 28
  • Total Committers: 4
  • Avg Commits per committer: 7.0
  • Development Distribution Score (DDS): 0.321
Past Year
  • Commits: 0
  • Committers: 0
  • Avg Commits per committer: 0.0
  • Development Distribution Score (DDS): 0.0
Top Committers
Name Email Commits
Aaron Hoffer a****r@n****m 19
Aaron Hoffer h****a@m****u 5
Aaron Hoffer a****2@g****m 3
Jaehyeon Kim j****m@z****m 1
Committer Domains (Top 20 + Academic)

Issues and Pull Requests

Last synced: 9 months ago

All Time
  • Total issues: 12
  • Total pull requests: 2
  • Average time to close issues: 1 day
  • Average time to close pull requests: about 2 hours
  • Total issue authors: 10
  • Total pull request authors: 1
  • Average comments per issue: 1.17
  • Average comments per pull request: 0.0
  • Merged pull requests: 2
  • Bot issues: 0
  • Bot pull requests: 0
Past Year
  • Issues: 0
  • Pull requests: 0
  • Average time to close issues: N/A
  • Average time to close pull requests: N/A
  • Issue authors: 0
  • Pull request authors: 0
  • Average comments per issue: 0
  • Average comments per pull request: 0
  • Merged pull requests: 0
  • Bot issues: 0
  • Bot pull requests: 0
Top Authors
Issue Authors
  • cardiomoon (3)
  • timelyportfolio (1)
  • YuxinZhang9615 (1)
  • mrhopko (1)
  • jaehyeon-kim (1)
  • MehMog (1)
  • zhiiiyang (1)
  • maddyobrienjones (1)
  • michaelmccarthy404 (1)
Pull Request Authors
  • ayayron (2)
Top Labels
Issue Labels
Pull Request Labels

Packages

  • Total packages: 1
  • Total downloads:
    • cran 356 last-month
  • Total dependent packages: 0
  • Total dependent repositories: 0
  • Total versions: 1
  • Total maintainers: 1
cran.r-project.org: shinyDND

Shiny Drag-n-Drop

  • Versions: 1
  • Dependent Packages: 0
  • Dependent Repositories: 0
  • Downloads: 356 Last month
Rankings
Forks count: 2.9%
Stargazers count: 4.3%
Average: 24.4%
Dependent packages count: 29.8%
Dependent repos count: 35.5%
Downloads: 49.3%
Maintainers (1)
Last synced: 9 months ago

Dependencies

DESCRIPTION cran
  • htmltools * imports
  • shiny >= 0.11 imports