Skip to content

Commit c4ab3dc

Browse files
HammadTheOneRyan Patrick Kylerpkylenicolaskruchtenrpkyle
authored
Merge dev into master (#282)
* 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]>
1 parent 6a36dd9 commit c4ab3dc

9 files changed

+221
-425
lines changed

LICENSE

+2-21
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,2 @@
1-
MIT License
2-
3-
Copyright (c) 2019 Plotly
4-
5-
Permission is hereby granted, free of charge, to any person obtaining a copy
6-
of this software and associated documentation files (the "Software"), to deal
7-
in the Software without restriction, including without limitation the rights
8-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9-
copies of the Software, and to permit persons to whom the Software is
10-
furnished to do so, subject to the following conditions:
11-
12-
The above copyright notice and this permission notice shall be included in all
13-
copies or substantial portions of the Software.
14-
15-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21-
SOFTWARE.
1+
YEAR: 2021
2+
COPYRIGHT HOLDER: Plotly, Inc.

R/dash.R

+2-2
Original file line numberDiff line numberDiff line change
@@ -780,7 +780,7 @@ Dash <- R6::R6Class(
780780
#'
781781
#' For detailed examples of how to use pattern-matching callbacks, see the
782782
#' entry for \link{selectors} or visit our interactive online
783-
#' documentation at \url{https://dashr.plotly.com}.
783+
#' documentation at \url{https://dash.plotly.com/r/}.
784784
#'
785785
#' The `output` argument defines which layout component property should
786786
#' receive the results (via the [output] object). The events that
@@ -1149,7 +1149,7 @@ Dash <- R6::R6Class(
11491149
#' @param block Logical. Start the server while blocking console input? Default is `TRUE`.
11501150
#' @param showcase Logical. Load the Dash application into the default web browser when server starts? Default is `FALSE`.
11511151
#' @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`.
1152-
#' @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`.
1152+
#' @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`.
11531153
#' @param dev_tools_ui Logical. Show Dash's developer tools UI? Default is `TRUE` if `debug == TRUE`, `FALSE` otherwise. Environment variable: `DASH_UI`.
11541154
#' @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`.
11551155
#' @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`.

R/utils.R

+21-7
Original file line numberDiff line numberDiff line change
@@ -338,12 +338,26 @@ clean_dependencies <- function(deps) {
338338
}
339339

340340
insertIntoCallbackMap <- function(map, inputs, output, state, func, clientside_function) {
341-
map[[createCallbackId(output)]] <- list(inputs=inputs,
342-
output=output,
343-
state=state,
344-
func=func,
345-
clientside_function=clientside_function
346-
)
341+
output_id <- createCallbackId(output)
342+
343+
if (output_id %in% names(map)) {
344+
stop(
345+
sprintf(
346+
"One or more of the following outputs are duplicated across callbacks: %s. Please ensure that all ID and property combinations are unique.",
347+
output_id
348+
),
349+
call. = FALSE
350+
)
351+
}
352+
353+
map[[output_id]] <- list(
354+
inputs = inputs,
355+
output = output,
356+
state = state,
357+
func = func,
358+
clientside_function = clientside_function
359+
)
360+
347361
if (length(map) >= 2) {
348362
ids <- lapply(names(map), function(x) getIdProps(x)$ids)
349363
props <- lapply(names(map), function(x) getIdProps(x)$props)
@@ -1139,7 +1153,7 @@ createCallbackId <- function(output) {
11391153
}
11401154

11411155
getIdProps <- function(output) {
1142-
output_ids <- strsplit(substr(output, 3, nchar(output)-2), '...', fixed=TRUE)
1156+
output_ids <- strsplit(gsub("^\\.{2}|\\.{2}$", "", output), '...', fixed=TRUE)
11431157
idprops <- lapply(output_ids, strsplit, '.', fixed=TRUE)
11441158
ids <- vapply(unlist(idprops, recursive=FALSE), '[', character(1), 1)
11451159
props <- vapply(unlist(idprops, recursive=FALSE), '[', character(1), 2)

README.md

+56-85
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
1-
[![CircleCI](https://circleci.com/gh/plotly/dashR/tree/master.svg?style=svg)](https://circleci.com/gh/plotly/dashR/tree/master)
1+
[![CircleCI](https://circleci.com/gh/plotly/dashR/tree/master.svg?style=svg)](https://app.circleci.com/pipelines/github/plotly/dashR?branch=master)
22
[![GitHub](https://img.shields.io/github/license/plotly/dashR.svg?color=dark-green)](https://github.com/plotly/dashR/blob/master/LICENSE)
3-
[![CRAN status](https://www.r-pkg.org/badges/version-ago/dash)](https://cran.r-project.org/web/packages/dash/index.html)
4-
[![](http://cranlogs.r-pkg.org/badges/grand-total/dash)](https://cran.r-project.org/package=dash)
5-
[![](https://cranlogs.r-pkg.org/badges/dash)](https://cran.r-project.org/package=dash)
3+
[![CRAN status](https://www.r-pkg.org/badges/version-ago/dash)](https://CRAN.R-project.org/package=dash)
4+
[![](http://cranlogs.r-pkg.org/badges/grand-total/dash)](https://CRAN.R-project.org/package=dash)
5+
[![](https://cranlogs.r-pkg.org/badges/dash)](https://CRAN.R-project.org/package=dash)
66

77
# Dash for R
88

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

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

1313
## Installation
1414

15-
<https://dashr.plotly.com/installation>
15+
<https://dash.plotly.com/r/installation>
1616

1717
> 🛑 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.
1818
@@ -42,9 +42,9 @@ That's it!
4242

4343
## Getting Started
4444

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

47-
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.
47+
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.
4848

4949
```r
5050
library(dash)
@@ -55,96 +55,67 @@ app <- Dash$new()
5555
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:
5656

5757
```r
58-
app$layout(
59-
htmlDiv(
60-
list(
61-
dccInput(id = "inputID", value = "initial value", type = "text"),
62-
htmlDiv(id = "outputID")
63-
)
64-
)
65-
)
66-
67-
app$callback(output = list(id="outputID", property="children"),
68-
params = list(input(id="inputID", property="value"),
69-
state(id="inputID", property="type")),
70-
function(x, y) {
71-
sprintf("You've entered: '%s' into a '%s' input control", x, y)
72-
}
73-
)
58+
library(dash)
7459

75-
app$run_server(showcase = TRUE)
60+
dash_app() %>%
61+
set_layout(
62+
dccInput(id = "text", "sample"),
63+
div("CAPS: ", span(id = "out1")),
64+
div("small: ", span(id = "out2"))
65+
) %>%
66+
add_callback(
67+
list(
68+
output("out1", "children"),
69+
output("out2", "children")
70+
),
71+
input("text", "value"),
72+
function(text) {
73+
list(
74+
toupper(text),
75+
tolower(text)
76+
)
77+
}
78+
) %>%
79+
run_app()
7680
```
7781

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

8084
## Hello world example using `dccGraph`
8185

8286
```r
83-
app <- Dash$new()
87+
library(dash)
8488

85-
app$layout(
86-
htmlDiv(
87-
list(
88-
dccInput(id = "graphTitle",
89-
value = "Let's Dance!",
90-
type = "text"),
91-
htmlDiv(id = "outputID"),
92-
dccGraph(id = "giraffe",
93-
figure = list(
94-
data = list(x = c(1,2,3), y = c(3,2,8), type = "bar"),
95-
layout = list(title = "Let's Dance!")
96-
)
97-
)
89+
# Create a Dash app
90+
app <- dash_app()
91+
92+
# Set the layout of the app
93+
app %>% set_layout(
94+
h1('Hello Dash'),
95+
div("Dash: A web application framework for your data."),
96+
dccGraph(
97+
figure = list(
98+
data = list(
99+
list(
100+
x = list(1, 2, 3),
101+
y = list(4, 1, 2),
102+
type = 'bar',
103+
name = 'SF'
104+
),
105+
list(
106+
x = list(1, 2, 3),
107+
y = list(2, 4, 5),
108+
type = 'bar',
109+
name = 'Montr\U{00E9}al'
110+
)
111+
),
112+
layout = list(title = 'Dash Data Visualization')
98113
)
99114
)
100115
)
101116

102-
app$callback(output = list(id = "giraffe", property = "figure"),
103-
params = list(input("graphTitle", "value")),
104-
function(newTitle) {
105-
106-
rand1 <- sample(1:10, 1)
107-
108-
rand2 <- sample(1:10, 1)
109-
rand3 <- sample(1:10, 1)
110-
rand4 <- sample(1:10, 1)
111-
112-
x <- c(1,2,3)
113-
y <- c(3,6,rand1)
114-
y2 <- c(rand2,rand3,rand4)
115-
116-
df = data.frame(x, y, y2)
117-
118-
list(
119-
data =
120-
list(
121-
list(
122-
x = df$x,
123-
y = df$y,
124-
type = "bar"
125-
),
126-
list(
127-
x = df$x,
128-
y = df$y2,
129-
type = "scatter",
130-
mode = "lines+markers",
131-
line = list(width = 4)
132-
)
133-
),
134-
layout = list(title = newTitle)
135-
)
136-
}
137-
)
138-
139-
app$callback(output = list(id = "outputID", property = "children"),
140-
params = list(input("graphTitle", "value"),
141-
state("graphTitle", "type")),
142-
function(x, y) {
143-
sprintf("You've entered: '%s' into a '%s' input control", x, y)
144-
}
145-
)
146-
147-
app$run_server(showcase = TRUE)
117+
# Run the app
118+
app %>% run_app()
148119
```
149120

150121
---

man/Dash.Rd

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/dash-package.Rd

+2-2
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,12 @@ Dash apps are rendered in the web browser. You can deploy your apps to servers a
1515
1616
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}.
1717
18-
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}.
18+
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}.
1919
}
2020
\seealso{
2121
Useful links:
2222
\itemize{
23-
\item \url{http://dashr.plotly.com}
23+
\item \url{https://dash.plotly.com/r/}
2424
\item \url{https://github.com/plotly/dashR}
2525
\item Report bugs at \url{https://github.com/plotly/dashR/issues}
2626
}

0 commit comments

Comments
 (0)