diff --git a/.Rbuildignore b/.Rbuildignore index a8df264..508b8ef 100644 --- a/.Rbuildignore +++ b/.Rbuildignore @@ -23,3 +23,4 @@ tools/gallery-template.Rmd ^\.github$ ^codecov\.yml$ ^docs$ +^cran-comments\.md$ diff --git a/DESCRIPTION b/DESCRIPTION index d2a4b12..27f5866 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,12 +1,12 @@ Package: r2d3 Type: Package Title: Interface to 'D3' Visualizations -Version: 0.2.5 +Version: 0.2.6 Authors@R: c( person("Nick", "Strayer", email = "nick.strayer@rstudio.com", role = c("aut", "cre")), person("Javier", "Luraschi", email = "jluraschi@gmail.com", role = c("aut")), person("JJ", "Allaire", role = c("aut")), - person("Mike", "Bostock", role = c("ctb", "cph"), comment = "d3.js library, http://d3js.org"), + person("Mike", "Bostock", role = c("ctb", "cph"), comment = "d3.js library, https://d3js.org"), person(family = "RStudio", role = c("cph")) ) Description: Suite of tools for using 'D3', a library for producing dynamic, interactive data diff --git a/NEWS.md b/NEWS.md index 867c2b9..4d063d5 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,3 +1,7 @@ +# r2d3 0.2.6 + +- Fix bug that would cause multiple dependencies for css or js to silently fail. + # r2d3 0.2.5 - Support for D3 v6 (@dkjoluju, #85). @@ -28,4 +32,4 @@ - Publish D3 visualizations to the web - Incorporate D3 scripts into R Markdown reports, presentations, and dashboards - Create interacive D3 applications with Shiny -- Distribute D3 based htmlwidgets in R packages \ No newline at end of file +- Distribute D3 based htmlwidgets in R packages diff --git a/R/script.R b/R/script.R index 25d34e9..21c27b3 100644 --- a/R/script.R +++ b/R/script.R @@ -29,12 +29,16 @@ script_wrap <- function(deps, script, container) { ) } + script_read <- function(script) { - if ( - is.null(script) || + # Make sure we can properly resolve the scripts as files. If we can't, because + # none were passed or because the script was just in-lined, then just return + # the scripts back to the caller + unresolvable_script_paths <- is.null(script) || length(script) == 0 || any(!file.exists(script)) - ) { + + if (unresolvable_script_paths) { return(script) } diff --git a/R/zzz.R b/R/zzz.R index 509b908..05d1d8f 100644 --- a/R/zzz.R +++ b/R/zzz.R @@ -14,7 +14,7 @@ if (rstudio$version < "1.2.637") packageStartupMessage( "r2d3 should be run under RStudio v1.2 or higher. Please update at:\n", - "https://rstudio.com/products/rstudio/download/\n" + "https://www.rstudio.com/products/rstudio/download/\n" ) } } diff --git a/README.md b/README.md index 70cbbba..3fcb450 100644 --- a/README.md +++ b/README.md @@ -26,7 +26,7 @@ visualizations](https://d3js.org/) with R, including: - Creating interactive D3 applications with [Shiny](https://shiny.rstudio.com/) -- Distributing D3 based [htmlwidgets](http://www.htmlwidgets.org) in R +- Distributing D3 based [htmlwidgets](https://www.htmlwidgets.org) in R packages
@@ -75,7 +75,7 @@ devtools::install_github("rstudio/r2d3") ``` Next, install the [preview release of RStudio -v1.2](https://rstudio.com/products/rstudio/download/) of RStudio (you +v1.2](https://www.rstudio.com/products/rstudio/download/) of RStudio (you need this version of RStudio to take advantage of various integrated tools for authoring D3 scripts with r2d3). @@ -91,7 +91,7 @@ graphics programming (similar to creating custom grid graphics in R). It’s therefore a good fit when you need highly custom visualizations that aren’t covered by existing libraries. If on the other hand you are looking for pre-fabricated D3 / JavaScript visualizations, check out the -packages created using [htmlwidgets](http://www.htmlwidgets.org), which +packages created using [htmlwidgets](https://www.htmlwidgets.org), which provide a much higher level interface. If you are completely new to D3, you may also want to check out the @@ -169,7 +169,7 @@ are provided automatically are: ## D3 Preview The [RStudio v1.2 preview -release](https://rstudio.com/products/rstudio/download/) of RStudio +release](https://www.rstudio.com/products/rstudio/download/) of RStudio includes support for previewing D3 scripts as you write them. To try this out, create a D3 script using the new file menu: diff --git a/cran-comments.md b/cran-comments.md new file mode 100644 index 0000000..2b7b6d1 --- /dev/null +++ b/cran-comments.md @@ -0,0 +1,6 @@ +## R CMD check results + +0 errors | 0 warnings | 1 note + +This fixes the bug caused by the lines `is.null(script) || length(script) == 0 || !file.exists(script)` in the `script_read()` function within `script.R`. The +potentially length > 1 vector of booleans is now reduced to a single with `any()`. diff --git a/vignettes/data_conversion.Rmd b/vignettes/data_conversion.Rmd index 332ff9f..26b5048 100644 --- a/vignettes/data_conversion.Rmd +++ b/vignettes/data_conversion.Rmd @@ -13,7 +13,7 @@ knitr::opts_chunk$set(eval = FALSE) ## Default conversion -R objects provided as `data` for D3 visualizations are converted to JSON using the [jsonlite::toJSON()](https://www.rdocumentation.org/packages/jsonlite/versions/1.5/topics/toJSON%2C%20fromJSON) function, and use the same default serialization behavior as [Shiny](https://shiny.rstudio.com) and [htmlwidgets](http://www.htmlwidgets.org/develop_advanced.html#custom-json-serializer). +R objects provided as `data` for D3 visualizations are converted to JSON using the [jsonlite::toJSON()](https://www.rdocumentation.org/packages/jsonlite/versions/1.5/topics/toJSON%2C%20fromJSON) function, and use the same default serialization behavior as [Shiny](https://shiny.rstudio.com) and [htmlwidgets](https://www.htmlwidgets.org/develop_advanced.html#custom-json-serializer). This corresponds to the following call to `jsonlite::toJSON()`: @@ -28,7 +28,7 @@ jsonlite::toJSON( #### Data frames -Data frames are serialized with a columns orientation as that is a more compact over the wire representation than rows orientation. When the data frame gets to the client **r2d3** calls the [HTMLWidgets.dataframeToD3()](http://www.htmlwidgets.org/develop_advanced.html#htmlwidgets.dataframetod3) method to transform the data to a D3-friendly rows orientation. +Data frames are serialized with a columns orientation as that is a more compact over the wire representation than rows orientation. When the data frame gets to the client **r2d3** calls the [HTMLWidgets.dataframeToD3()](https://www.htmlwidgets.org/develop_advanced.html#htmlwidgets.dataframetod3) method to transform the data to a D3-friendly rows orientation. Here is an example of the JSON columns-based representation of an R data frame: diff --git a/vignettes/development_and_debugging.Rmd b/vignettes/development_and_debugging.Rmd index 872c778..021a051 100644 --- a/vignettes/development_and_debugging.Rmd +++ b/vignettes/development_and_debugging.Rmd @@ -19,11 +19,11 @@ This article describes recommend workflow for developing D3 visualizations, incl 2) Using browser debugging tools to pinpoint errors in your code. -Note that the development tools described above are only fully supported within the [RStudio v1.2 preview release](https://rstudio.com/products/rstudio/download/) (as opposed to the current stable release) so you should download the daily build before trying these features out. +Note that the development tools described above are only fully supported within the [RStudio v1.2 preview release](https://www.rstudio.com/products/rstudio/download/) (as opposed to the current stable release) so you should download the daily build before trying these features out. ## RStudio Preview -The [RStudio v1.2 preview release](https://rstudio.com/products/rstudio/download/) includes support for previewing D3 scripts as you write them. To try this out, create a D3 script using the new file menu: +The [RStudio v1.2 preview release](https://www.rstudio.com/products/rstudio/download/) includes support for previewing D3 scripts as you write them. To try this out, create a D3 script using the new file menu: diff --git a/vignettes/gallery/morley/box.js b/vignettes/gallery/morley/box.js index 3e800d3..07fbf57 100644 --- a/vignettes/gallery/morley/box.js +++ b/vignettes/gallery/morley/box.js @@ -1,6 +1,6 @@ (function() { -// Inspired by http://informationandvisualization.de/blog/box-plot +// Inspired by https://informationandvisualization.de/blog/box-plot d3.box = function() { var width = 1, height = 1, diff --git a/vignettes/gallery/stackedbars/stackedbars.js b/vignettes/gallery/stackedbars/stackedbars.js index 1ed39b3..f295653 100644 --- a/vignettes/gallery/stackedbars/stackedbars.js +++ b/vignettes/gallery/stackedbars/stackedbars.js @@ -1,6 +1,6 @@ // !preview r2d3 d3_version = 4 -// Based on: http://bl.ocks.org/mbostock/3943967 +// Based on: https://bl.ocks.org/mbostock/3943967 var n = 4, // The number of series. m = 58; // The number of values per series. @@ -102,7 +102,7 @@ function transitionStacked() { // Returns an array of m psuedorandom, smoothly-varying non-negative numbers. // Inspired by Lee Byron’s test data generator. -// http://leebyron.com/streamgraph/ +// https://leebyron.com/streamgraph/ function bumps(m) { var values = [], i, j, w, x, y, z; diff --git a/vignettes/publishing.Rmd b/vignettes/publishing.Rmd index 971ff66..fc1d907 100644 --- a/vignettes/publishing.Rmd +++ b/vignettes/publishing.Rmd @@ -127,11 +127,11 @@ Note that in order to use the `d3` engine you need to add `library(r2d3)` to the ### flexdashboard -The [flexdashboard](https://rmarkdown.rstudio.com/flexdashboard) R Markdown format is a great way to publish a set of related D3 visualizations. You can use flexdashbaord to combine D3 visualizations with narrative, data tables, other [htmlwidgets](http://www.htmlwidgets.org), and static R plots: +The [flexdashboard](https://pkgs.rstudio.com/flexdashboard/) R Markdown format is a great way to publish a set of related D3 visualizations. You can use flexdashbaord to combine D3 visualizations with narrative, data tables, other [htmlwidgets](https://www.htmlwidgets.org), and static R plots: -Check out the [flexdashboard online documentation](https://rmarkdown.rstudio.com/flexdashboard) for additional details. +Check out the [flexdashboard online documentation](https://pkgs.rstudio.com/flexdashboard/) for additional details. ## Shiny applications diff --git a/vignettes/shiny.Rmd b/vignettes/shiny.Rmd index 2d3a117..53212fd 100644 --- a/vignettes/shiny.Rmd +++ b/vignettes/shiny.Rmd @@ -158,7 +158,7 @@ In the D3 script, we called `Shiny.setInputValued()` with an input named `bar_cl The `output$selected()` function uses `renderText()` to display the cosine of the bar that was clicked on. The call to `input$bar_clicked` is used inside `renderText()` to execute the `cos()` calculation. -The default value of `input$bar_clicked` will be `NULL` at the startup of the app. In this state you won't want to perform any calculation (as it would result in an error) or display any output. Shiny's `req()` function can be used to prevent errors in this case `req()` stops reactivity if the value of the variable passed as an argument is not valid, read more about this function in Shiny's official site: [Check for required values](http://shiny.rstudio.com/reference/shiny/latest/req.html) +The default value of `input$bar_clicked` will be `NULL` at the startup of the app. In this state you won't want to perform any calculation (as it would result in an error) or display any output. Shiny's `req()` function can be used to prevent errors in this case `req()` stops reactivity if the value of the variable passed as an argument is not valid, read more about this function in Shiny's official site: [Check for required values](https://shiny.rstudio.com/reference/shiny/latest/req.html) Here is the Shiny application in action: diff --git a/vignettes/visualization_options.Rmd b/vignettes/visualization_options.Rmd index 0dc2863..33cd75c 100644 --- a/vignettes/visualization_options.Rmd +++ b/vignettes/visualization_options.Rmd @@ -106,7 +106,7 @@ When you render a D3 visualization, **r2d3** creates an R [htmlwidget](http://ww 2) Conforming to the currently active `fig.width` and `fig.height` chunk options within [R Markdown](https://rmarkdown.rstudio.com) documents. -3) Filling available space when used in a [Shiny application](https://shiny.rstudio.com) or a [flexdashboard](https://rmarkdown.rstudio.com/flexdashboard). +3) Filling available space when used in a [Shiny application](https://shiny.rstudio.com) or a [flexdashboard](https://pkgs.rstudio.com/flexdashboard/). In order to take advantage of this dynamic sizing behavior, your should ensure that your D3 visualization uses the `width` and `height` variables that are provided automatically. Note the use of `height` in the computation of `barHeight` and `width` in the call to `.attr()` in this example: @@ -175,5 +175,5 @@ The `viewer` argument to the `r2d3()` function enables you to customize how D3 v The "external" option is useful if your visualization requires more space than an RStudio pane affords. The "browser" option is useful if you need access to browser debugging tools during development. -Note that the `viewer` options described above are only fully supported within the [preview release of RStudio v1.2](https://rstudio.com/products/rstudio/download/) (as opposed to the current stable release). +Note that the `viewer` options described above are only fully supported within the [preview release of RStudio v1.2](https://www.rstudio.com/products/rstudio/download/) (as opposed to the current stable release).