Skip to content

A Shiny app built on top R script to demo the use case of interactively point selection from a plot and which are added to a data table

License

Notifications You must be signed in to change notification settings

ardanpat/PlotlyDataTableDemo

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

PlotlyDataTableDemo

Overview

This is a Shiny app built on top R script to demo the use case of being able to interactively select points from a plot and have these added to a data table. We use the Plotlty library for displaying plot as it provides functionality zoom and pan the chart, and hover on points out of the box. The app augments the functionality with interactive clicking on points to add them to a table. The table is implemented using the Data Table library. Screenshot of the PlotlyDataTableDemo in action

Key Implemention Features

  • The onRender event handler of Plotly is coupled to the setInputValue function of Shiny to handle click events on the plot on the Shiny server.
  • The ID column in the table has a dummy hyperlink to demo how hyperlinks may be implemented.
  • The table has a fourth column with a Fire button. When pressed, the ID of the corresponding row is shown below the table.
  • The table has buttons to download the data in various formats. This functionality comes out of the box with the Buttons extension of Data Tables. However one problem with the default implementation is that it writes out all the columns which would include the column with the Fire button. This implementation omits the 4th column from being written out.
  • The user may select rows in the table and click the Delete button to removed them. A potentially conflict then arises between selecting a row and pressing the Fire button. In this implementation, clicking the Fire button will not change the selection status of the row.
  • There are two ways to load data into the plot:
    1. New random data can be generated by using a slider to select the number of points desired and clicking on Generate dataset!.
    2. There is a selection of saved data files in the data directory that can be loaded by selecting them and pressing the Load dataset button. One of the files, Points 20 no y, has been modified to remove the y column to show how the validation works using the shinyFeedback library.
  • The shinythemes library is used to skin the application.

Installation

Clone/download the repository and run it using R Studio or R script. Any required libraries will be installed when the script is run unless they have been already installed. To run it from the command line (assuming you have R script installed and PROJECT_DIR is where the project has been installed, e.g., "./PlotlyDataTableDemo"):

R -e "shiny::runApp(PROJECT_DIR)"

The required uninstalled libraries will be downloaded and installed and when the script is running you will be given a URL that has to be copy and pasted into a web browser. Here is a small snippet of a typical output:

Loading required package: purrr
Loading required package: shinyFeedback
Loading required package: shinythemes
Loading required package: vroom

Listening on http://127.0.0.1:4859

Usage

A live demo of the app can be found at https://patwar.shinyapps.io/PlotlyDataTableDemo/.

License

The project is distributed under the Apache-2.0 license and the details can be found in the LICENSE file.

About

A Shiny app built on top R script to demo the use case of interactively point selection from a plot and which are added to a data table

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages