Skip to content

Commit

Permalink
Merge dev into master (#282)
Browse files Browse the repository at this point in the history
* contribute test script

* remove version updating in DESCRIPTION

* fix EOL

Co-authored-by: HammadTheOne <[email protected]>

* Add support for user-defined server routes (#225)

* Provide support for script and stylesheet attributes (#226)

* Authenticate on pulls from Docker Hub (#231)

* Add support for callback graph improvements and timing (#224)

* Update CHANGELOG.md

* 189 - Add Pattern Matching Callbacks for Dash R (#228)

* Testing initial implementation

* More testing

* Callback Context Updates

* Updating callback context logic

* Fixing callback returns

* Adding callback args conditional

* Cleanup and additional changes to callback value conditionals

* Comment cleanup

* Added PMC callback validation, removed unnecessary code

* Update R/dependencies.R

Co-authored-by: Ryan Patrick Kyle <[email protected]>

* Update R/dependencies.R

Co-authored-by: Ryan Patrick Kyle <[email protected]>

* Update R/dependencies.R

Co-authored-by: Ryan Patrick Kyle <[email protected]>

* Update R/dependencies.R

Co-authored-by: Ryan Patrick Kyle <[email protected]>

* Added build to gitignore

* Updated dependencies.R

* Update boilerplate docs and add wildcard symbols

* Drying up validation code and applying symbol logic

* Update test to use symbols

* Cleaned up code and added allsmaller test example

* Cleaning up redundant code

* Update FUNDING.yml

* Updated callback_args logic and example

* Adding basic unittests, updated validation

* Fixed response for MATCH callbacks

* Added integration test and updated examples for docs

* Added additional integration test

* Formatting and cleanup

* update docs

* Update to-do app

* Add comments to examples

* Change empy vector to character type.

Co-authored-by: Ryan Patrick Kyle <[email protected]>

* Update boilerplate text.

Co-authored-by: Ryan Patrick Kyle <[email protected]>

* Update tests/integration/callbacks/test_pattern_matching.py

Co-authored-by: Ryan Patrick Kyle <[email protected]>

* Update tests/integration/callbacks/test_pattern_matching.py

Co-authored-by: Ryan Patrick Kyle <[email protected]>

* Update tests/integration/callbacks/test_pattern_matching.py

Co-authored-by: Ryan Patrick Kyle <[email protected]>

* Update tests/integration/callbacks/test_pattern_matching.py

Co-authored-by: Ryan Patrick Kyle <[email protected]>

* Update tests/integration/callbacks/test_pattern_matching.py

Co-authored-by: Ryan Patrick Kyle <[email protected]>

* Update tests/testthat/test-wildcards.R

Co-authored-by: Ryan Patrick Kyle <[email protected]>

* Update wildcards_test.R

Co-authored-by: Ryan Patrick Kyle <[email protected]>

* Update wildcards_test.R

Co-authored-by: Ryan Patrick Kyle <[email protected]>

* Update wildcards_test.R

Co-authored-by: Ryan Patrick Kyle <[email protected]>

* Update wildcards_test.R

Co-authored-by: Ryan Patrick Kyle <[email protected]>

* Update wildcards_test.R

Co-authored-by: Ryan Patrick Kyle <[email protected]>

* Update wildcards_test.R

Co-authored-by: Ryan Patrick Kyle <[email protected]>

* Update wildcards_test.R

Co-authored-by: Ryan Patrick Kyle <[email protected]>

* Update wildcards_test.R

Co-authored-by: Ryan Patrick Kyle <[email protected]>

* Removed triple colon syntax

* Use seq_along and remove unnecessary unittest

* Update CHANGELOG.md

* Update CHANGELOG.md

* Add support for arbitrary and sorted keys

* Whitespace deleted

* Added integration tests

* Fixing test output

* Fixing flakiness

* Update test_pattern_matching.py

* Update test_pattern_matching.py

* Updating boilerplate text and test with generalized keys

* Minor test fixes

Co-authored-by: Ryan Patrick Kyle <[email protected]>
Co-authored-by: Nicolas Kruchten <[email protected]>
Co-authored-by: rpkyle <[email protected]>

* Fixing Null error with glue::glue interpolation (#233)

* Fixing NULL error with glue interpolation

* Update utils.R

* Update utils.R

* Update CHANGELOG.md

* Update dash-renderer to v1.8.2 (#234)

* bump dash-renderer to v1.8.2

* Update CHANGELOG.md

* add note about update to dash-renderer

* Fixing flaky test

* bump package version to v0.8.0

* Update R/dash.R

Co-authored-by: HammadTheOne <[email protected]>

* Update tests/testthat/test-wildcards.R

Co-authored-by: HammadTheOne <[email protected]>

* Update DESCRIPTION

Co-authored-by: HammadTheOne <[email protected]>

* add PMC example

* update documentation

* update CHANGELOG release date

* 🔨 PMC docs refactor

* Update tests/integration/callbacks/test_pattern_matching.py

Co-authored-by: HammadTheOne <[email protected]>

* Update tests/integration/callbacks/test_pattern_matching.py

Co-authored-by: HammadTheOne <[email protected]>

* Update tests/integration/callbacks/test_pattern_matching.py

Co-authored-by: HammadTheOne <[email protected]>

* add import of glue

* add glue to imports.R

* fix line length issue

* Fix setCallbackContext for wildcard and ordinary inputs (#237)

* Update setCallbackContext

* Adding graphs test

* Slight fix

* bump version and update CHANGELOG

* Less flaky test

Co-authored-by: rpkyle <[email protected]>

* bump dependency versions

* update CHANGELOG

* update dash-renderer to v1.8.3

* update CHANGELOG

* Favicon fix (#240)

* Adding default favicon

* Removing redundant codeblock

* Added default favicon

* Minor fix to requests prefix

* Update CHANGELOG.md

Co-authored-by: Ryan Patrick Kyle <[email protected]>

* Added simple test

* Fixed typo

* Fixed typo

Co-authored-by: Ryan Patrick Kyle <[email protected]>

* Remove context reference from CircleCI (#241)

* Dash R Core Package Unification (#243)

* Initialize npm and gulpfile in repo

* Adding directory structure

* Initial implementation of unification script

* Minor grep fixes

* Fixed DESCRIPTION imports

* Added updated dash-table deps

* Regex for version numbers

* Cut import entries from NAMESPACE

* Remove && include(dashr)

* Removing gulp-asset artifacts and rebuilding complete package

* Removing unnecessary files

* fix: remove html, core pkgs from tests

* fix: update script tags unit test

* Revert R6 import

* Add temporary collate

* Update README examples

* Scrubbing imports

* More import scrubbing

* Package development updates

* Update gitignore and namespace

* Updated gulpfile jobs

* Updated all dependencies

* Added templates for namespace/internal exports

* Update internal, namespace, and gulpfile cleanup

* Fix dependency sourcing

* Linting

* Adding job for asset retrieval and deletion

* Minor src change

* Added error handling

* Fixing favicon bug

* chore: use shallow clone

Co-authored-by: Ryan Patrick Kyle <[email protected]>

* Added deprecation warning if dcc, html, or table packages are attached (#249)

* Added deprecation warning

* Update R/dash.R

Co-authored-by: Ryan Patrick Kyle <[email protected]>

Co-authored-by: Ryan Patrick Kyle <[email protected]>

* Update `highlight.js` dependency for dash-table (#262)

* Updating gulpfile

* Updating dependencies for dash components

* Updated highlight.js dependency source

* Add Dash 2 layout syntax wrappers and html tags (#265)

* Added add_meta helper

* Add helper functions and export pipe

* Adding in tags wrapper

* Updating ci config

* Updated CHANGELOG

* Updated circleci to include rust package manager (cargo).

* Removed dashr command in circleci config.

* Updating changelog

* added basic test

* Cleaning up Dash 2 references and duplication

* Updated documentation

* Allow conditional UI

* Add meta tag check

* More cleanup

* Last bit of cleanup

Co-authored-by: Steve Sperandeo <[email protected]>

* Fix suppress_callback_exceptions config (#268)

* Add config key

* Fixing CI

* Simplified callback syntax and addtional utility functions (#270)

* Tag updates

* Added RStudio dash snippet

* Added simple_table

* Added flexible callbacks

* Documentation and NAMESPACE updates

* Updated DESCRIPTION

* Adding unittests

* Adding context tags to tests

* Updated CHANGELOG

* Update monorepo and rebuild package (#271)

* Updating gulpfile and package.json

* More package.json and linting updates

* Adding in simplified callback updates/tests

* Import fixes

* Updating package.json

* Gulpfile script changes

* Gulpfile updates

* Rebuilding package with monorepo updates

* Re-running test

* Updating unittest

* Updating test dependencies

* Updating DESCRIPTION and .Rbuildignore forchecks

* Updating function descriptions and NAMESPACE imports

* Fixed examples and updated docs

* Updating version

* Remove references to dash namespace within package

* Update testthat and remove deprecated context calls

* Removed fixup_metadata.R

* Removing more dash namespace references

* Concatenating component function files

* Updating checks

* Merging components into package R files

* Fixing check

* More package cleanup

* testthat 3.0.0

* Rebuilding package

* Fixed conditional for multiple outputs

* Fix no_update test

* Fixing callback_instrumentation test

* Fixing unit test

* Added DBC to Dash R package (#273)

* Adding dbc to dashR namespace

* updated gitignore

* Adding dbc docs and updating gulpfile

* Updating test with dbc

* Moved misc tests and added dbc snapshot

* Fixing test

* fixing id

* Fixed export and test

* Reverting sorted prop order

* Checks updates

* Re-running test

* Remove html exports and update tags (#274)

* Updating tags and html exports

* Re-running tests

* Updating tag generation

* Re-running tests

* Updating tests to use new html list syntax

* Adjusting tests

* Re-run tests again

* Updating tests

* Wrapping up test fixes

* Percy test

* CRAN submission updates

* Fix callback outputs with short ID's (#280)

* CRAN submission updates

* Callback output ID validation fixes

* Updating duplicate callbacks test

* Security updates

* Update R/utils.R

Co-authored-by: Dean Attali <[email protected]>

* Updating error message

Co-authored-by: Dean Attali <[email protected]>

* Updating README link

Co-authored-by: Ryan Patrick Kyle <[email protected]>
Co-authored-by: Ryan Patrick Kyle <[email protected]>
Co-authored-by: Nicolas Kruchten <[email protected]>
Co-authored-by: rpkyle <[email protected]>
Co-authored-by: Steve Sperandeo <[email protected]>
Co-authored-by: Dean Attali <[email protected]>
  • Loading branch information
7 people authored Nov 1, 2021
1 parent 6a36dd9 commit c4ab3dc
Show file tree
Hide file tree
Showing 9 changed files with 221 additions and 425 deletions.
23 changes: 2 additions & 21 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -1,21 +1,2 @@
MIT License

Copyright (c) 2019 Plotly

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
YEAR: 2021
COPYRIGHT HOLDER: Plotly, Inc.
4 changes: 2 additions & 2 deletions R/dash.R
Original file line number Diff line number Diff line change
Expand Up @@ -780,7 +780,7 @@ Dash <- R6::R6Class(
#'
#' For detailed examples of how to use pattern-matching callbacks, see the
#' entry for \link{selectors} or visit our interactive online
#' documentation at \url{https://dashr.plotly.com}.
#' documentation at \url{https://dash.plotly.com/r/}.
#'
#' The `output` argument defines which layout component property should
#' receive the results (via the [output] object). The events that
Expand Down Expand Up @@ -1149,7 +1149,7 @@ Dash <- R6::R6Class(
#' @param block Logical. Start the server while blocking console input? Default is `TRUE`.
#' @param showcase Logical. Load the Dash application into the default web browser when server starts? Default is `FALSE`.
#' @param use_viewer Logical. Load the Dash application into RStudio's viewer pane? Requires that `host` is either `127.0.0.1` or `localhost`, and that Dash application is started within RStudio; if `use_viewer = TRUE` and these conditions are not satisfied, the user is warned and the app opens in the default browser instead. Default is `FALSE`.
#' @param debug Logical. Enable/disable all the Dash developer tools (and the within-browser user interface for the callback graph visualizer and stack traces) unless overridden by the arguments or environment variables. Default is `FALSE` when called via `run_server`. For more information, please visit \url{https://dashr.plotly.com/devtools}. Environment variable: `DASH_DEBUG`.
#' @param debug Logical. Enable/disable all the Dash developer tools (and the within-browser user interface for the callback graph visualizer and stack traces) unless overridden by the arguments or environment variables. Default is `FALSE` when called via `run_server`. For more information, please visit \url{https://dash.plotly.com/r/devtools}. Environment variable: `DASH_DEBUG`.
#' @param dev_tools_ui Logical. Show Dash's developer tools UI? Default is `TRUE` if `debug == TRUE`, `FALSE` otherwise. Environment variable: `DASH_UI`.
#' @param dev_tools_hot_reload Logical. Activate hot reloading when app, assets, and component files change? Default is `TRUE` if `debug == TRUE`, `FALSE` otherwise. Requires that the Dash application is loaded using `source()`, so that `srcref` attributes are available for executed code. Environment variable: `DASH_HOT_RELOAD`.
#' @param dev_tools_hot_reload_interval Numeric. Interval in seconds for the client to request the reload hash. Default is `3`. Environment variable: `DASH_HOT_RELOAD_INTERVAL`.
Expand Down
28 changes: 21 additions & 7 deletions R/utils.R
Original file line number Diff line number Diff line change
Expand Up @@ -338,12 +338,26 @@ clean_dependencies <- function(deps) {
}

insertIntoCallbackMap <- function(map, inputs, output, state, func, clientside_function) {
map[[createCallbackId(output)]] <- list(inputs=inputs,
output=output,
state=state,
func=func,
clientside_function=clientside_function
)
output_id <- createCallbackId(output)

if (output_id %in% names(map)) {
stop(
sprintf(
"One or more of the following outputs are duplicated across callbacks: %s. Please ensure that all ID and property combinations are unique.",
output_id
),
call. = FALSE
)
}

map[[output_id]] <- list(
inputs = inputs,
output = output,
state = state,
func = func,
clientside_function = clientside_function
)

if (length(map) >= 2) {
ids <- lapply(names(map), function(x) getIdProps(x)$ids)
props <- lapply(names(map), function(x) getIdProps(x)$props)
Expand Down Expand Up @@ -1139,7 +1153,7 @@ createCallbackId <- function(output) {
}

getIdProps <- function(output) {
output_ids <- strsplit(substr(output, 3, nchar(output)-2), '...', fixed=TRUE)
output_ids <- strsplit(gsub("^\\.{2}|\\.{2}$", "", output), '...', fixed=TRUE)
idprops <- lapply(output_ids, strsplit, '.', fixed=TRUE)
ids <- vapply(unlist(idprops, recursive=FALSE), '[', character(1), 1)
props <- vapply(unlist(idprops, recursive=FALSE), '[', character(1), 2)
Expand Down
141 changes: 56 additions & 85 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
[![CircleCI](https://circleci.com/gh/plotly/dashR/tree/master.svg?style=svg)](https://circleci.com/gh/plotly/dashR/tree/master)
[![CircleCI](https://circleci.com/gh/plotly/dashR/tree/master.svg?style=svg)](https://app.circleci.com/pipelines/github/plotly/dashR?branch=master)
[![GitHub](https://img.shields.io/github/license/plotly/dashR.svg?color=dark-green)](https://github.com/plotly/dashR/blob/master/LICENSE)
[![CRAN status](https://www.r-pkg.org/badges/version-ago/dash)](https://cran.r-project.org/web/packages/dash/index.html)
[![](http://cranlogs.r-pkg.org/badges/grand-total/dash)](https://cran.r-project.org/package=dash)
[![](https://cranlogs.r-pkg.org/badges/dash)](https://cran.r-project.org/package=dash)
[![CRAN status](https://www.r-pkg.org/badges/version-ago/dash)](https://CRAN.R-project.org/package=dash)
[![](http://cranlogs.r-pkg.org/badges/grand-total/dash)](https://CRAN.R-project.org/package=dash)
[![](https://cranlogs.r-pkg.org/badges/dash)](https://CRAN.R-project.org/package=dash)

# Dash for R

#### Create beautiful, analytic web applications in R.

[Documentation](https://dashr.plotly.com/) | [Gallery](https://dash-gallery.plotly.host/Portal/)
[Documentation](https://dash.plotly.com/r/) | [Gallery](https://dash.gallery/Portal/)

## Installation

<https://dashr.plotly.com/installation>
<https://dash.plotly.com/r/installation>

> 🛑 Make sure you're on at least version `3.0.2` of R. You can see what version of R you have by entering `version` in the R CLI. [CRAN](https://cran.r-project.org/bin/) is the easiest place to download the latest R version.
Expand Down Expand Up @@ -42,9 +42,9 @@ That's it!

## Getting Started

<https://dashr.plotly.com/getting-started>
<https://dash.plotly.com/r/layout>

The R package **dash** makes it easy to create reactive web applications powered by R. It provides an [R6](https://cran.r-project.org/web/packages/R6/index.html) class, named `Dash`, which may be initialized via the `new()` method.
The R package **dash** makes it easy to create reactive web applications powered by R. It provides an [R6](https://CRAN.R-project.org/package=R6) class, named `Dash`, which may be initialized via the `new()` method.

```r
library(dash)
Expand All @@ -55,96 +55,67 @@ app <- Dash$new()
Similar to [Dash for Python](https://github.com/plotly/dash) and [Dash for Julia](https://github.com/plotly/Dash.jl), every Dash for R application needs a layout (i.e., user interface) and a collection of callback functions which define the updating logic to perform when input value(s) change. Take, for instance, this basic example of formatting a string:

```r
app$layout(
htmlDiv(
list(
dccInput(id = "inputID", value = "initial value", type = "text"),
htmlDiv(id = "outputID")
)
)
)

app$callback(output = list(id="outputID", property="children"),
params = list(input(id="inputID", property="value"),
state(id="inputID", property="type")),
function(x, y) {
sprintf("You've entered: '%s' into a '%s' input control", x, y)
}
)
library(dash)

app$run_server(showcase = TRUE)
dash_app() %>%
set_layout(
dccInput(id = "text", "sample"),
div("CAPS: ", span(id = "out1")),
div("small: ", span(id = "out2"))
) %>%
add_callback(
list(
output("out1", "children"),
output("out2", "children")
),
input("text", "value"),
function(text) {
list(
toupper(text),
tolower(text)
)
}
) %>%
run_app()
```

Here the `showcase = TRUE` argument opens a browser window and automatically loads the Dash app for you.

## Hello world example using `dccGraph`

```r
app <- Dash$new()
library(dash)

app$layout(
htmlDiv(
list(
dccInput(id = "graphTitle",
value = "Let's Dance!",
type = "text"),
htmlDiv(id = "outputID"),
dccGraph(id = "giraffe",
figure = list(
data = list(x = c(1,2,3), y = c(3,2,8), type = "bar"),
layout = list(title = "Let's Dance!")
)
)
# Create a Dash app
app <- dash_app()

# Set the layout of the app
app %>% set_layout(
h1('Hello Dash'),
div("Dash: A web application framework for your data."),
dccGraph(
figure = list(
data = list(
list(
x = list(1, 2, 3),
y = list(4, 1, 2),
type = 'bar',
name = 'SF'
),
list(
x = list(1, 2, 3),
y = list(2, 4, 5),
type = 'bar',
name = 'Montr\U{00E9}al'
)
),
layout = list(title = 'Dash Data Visualization')
)
)
)

app$callback(output = list(id = "giraffe", property = "figure"),
params = list(input("graphTitle", "value")),
function(newTitle) {

rand1 <- sample(1:10, 1)

rand2 <- sample(1:10, 1)
rand3 <- sample(1:10, 1)
rand4 <- sample(1:10, 1)

x <- c(1,2,3)
y <- c(3,6,rand1)
y2 <- c(rand2,rand3,rand4)

df = data.frame(x, y, y2)

list(
data =
list(
list(
x = df$x,
y = df$y,
type = "bar"
),
list(
x = df$x,
y = df$y2,
type = "scatter",
mode = "lines+markers",
line = list(width = 4)
)
),
layout = list(title = newTitle)
)
}
)

app$callback(output = list(id = "outputID", property = "children"),
params = list(input("graphTitle", "value"),
state("graphTitle", "type")),
function(x, y) {
sprintf("You've entered: '%s' into a '%s' input control", x, y)
}
)

app$run_server(showcase = TRUE)
# Run the app
app %>% run_app()
```

---
Expand Down
4 changes: 2 additions & 2 deletions man/Dash.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions man/dash-package.Rd
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@ Dash apps are rendered in the web browser. You can deploy your apps to servers a
There is a lot behind the framework. To learn more about how it is built and what motivated Dash, watch our talk from \href{https://youtu.be/5BAthiN0htc}{Plotcon} or read our \href{https://medium.com/@plotlygraphs/introducing-dash-5ecf7191b503}{announcement letter}.
Dash is an open source package, released under the permissive MIT license. Plotly develops Dash and offers a \href{https://plotly.com/dash/pricing/}{platform for easily deploying Dash apps in an enterprise environment}. If you're interested, \href{https://plotly.typeform.com/to/rkO85m?_ga=2.223907347.9240264.1560484539-2037997284.1554944507}{please get in touch}.
Dash is an open source package, released under the permissive MIT license. Plotly develops Dash and offers a \href{https://plotly.com/dash/}{platform for easily deploying Dash apps in an enterprise environment}. If you're interested, \href{https://plotly.com/get-pricing/}{please get in touch}.
}
\seealso{
Useful links:
\itemize{
\item \url{http://dashr.plotly.com}
\item \url{https://dash.plotly.com/r/}
\item \url{https://github.com/plotly/dashR}
\item Report bugs at \url{https://github.com/plotly/dashR/issues}
}
Expand Down
Loading

0 comments on commit c4ab3dc

Please sign in to comment.