Skip to content

Commit 645731f

Browse files
authored
VIS-992: add test, use rhtmlBuildUtils (#15)
* Initial commit * Remove prepush * Final line for plotly.yml * Re-add lib * Refactor * Create test * Specify rhtmlBuildUtils version * Remove preinstall script * Delete package-lock.json * Update documentation * Update documentation and remove library * Restore files * Restore file * Update build files
1 parent 0e4abf9 commit 645731f

File tree

11 files changed

+1026
-1082
lines changed

11 files changed

+1026
-1082
lines changed

.travis.yml

Lines changed: 8 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,9 @@
1-
language: R
2-
cache: packages
3-
warnings_are_errors: false
4-
5-
r:
6-
- devel
7-
- oldrel
8-
- release
9-
10-
addons:
11-
apt:
12-
sources:
13-
- sourceline: 'ppa:ubuntugis/ppa'
14-
packages:
15-
- libudunits2-dev
16-
- libproj-dev
17-
- libgeos-dev
18-
- libgdal-dev
19-
20-
env:
21-
global:
22-
# don't treat missing suggested packages as error
23-
- _R_CHECK_FORCE_SUGGESTS_=false
24-
# plotly_api_key (for posting to plot.ly)
25-
- secure: "WsvmMHN4YVhnk0bLRE04APcLbs5s4vWKSHjEdU0bPXd0xdMTzZeP5D7pxyF1983C+P5LpSnGHv4dgwLMBkNzxJwBR7/Ta7lfO1akYILWwxib+1DVbCqUH5Z4Ba1FSCQptIrLNGR3P7+0Lem4hEhqKdPKltFnxhnXO0Y+MeG71IQ="
26-
# MAPBOX_TOKEN (for testing `plot_mapbox()`)
27-
- secure: "QPBEqtLRdwb4ablJORzD0JdCT9ESe3nNdIehM1oxfcNKfpSdf2OFxH3TkeYY1nMpv0mLxiMNTy6xcj9Yk5MaaBCIA0P7q6OdZv9ruzQD1j3g84gP45KwBilbPGjb+/EvOS0fM25vR/pAmA8IyoUfPC2J8HwiNnW8DYdt/hJOJ9A="
28-
# GITHUB_PAT
29-
- secure: "lZf7GBt1+ogux5WAXmIZ6/VBTmR1G7rv+8Aevogfan7GWb32K3IVatsrKr1pSvz0hysP0MDueQqTv0GcNOvrFnYvobyo6fFpx+n33WkXQCGybUOHyfJpPdw1L2wtAy88ugNJDl+n9fdXr4yL2cWvRqq4WBKeeSi6hpdiKOaoB3Y="
30-
1+
language: node_js
2+
node_js:
3+
- "12"
4+
sudo: required
5+
dist: xenial
316
before_install:
32-
- echo "Sys.setenv('plotly_username' = 'cpsievert')" > ~/.Rprofile
33-
34-
before_script:
35-
- if [[ "$TRAVIS_R_VERSION_STRING" == "release" ]]; then docker run -e GITHUB_PAT=$GITHUB_PAT -e MAPBOX_TOKEN=$MAPBOX_TOKEN -e VMODE="ci" -v $(pwd):/home/plotly --privileged cpsievert/plotly-orca; fi
36-
7+
- sudo apt-get update
8+
script:
9+
- jest

README.md

Lines changed: 2 additions & 113 deletions
Original file line numberDiff line numberDiff line change
@@ -1,114 +1,3 @@
1+
This is a fork of the ropensci/plotly HtmlWidget for use in Displayr. The repository has been modified to be an node package and use the rhtmlBuildUtils framework. This was done in order to run unit tests on the widget js code, which has been modified by Displayr. The integration with rhtmlBuildUtils is incomplete, and only the building and unit testing of widget js code is supported. Features from rhtmlBuildUtils such as visual regression testing, linting and the internal web server are absent.
12

2-
<!-- README.md is generated from README.Rmd. Please edit that file -->
3-
4-
<img src="man/figures/plotly.png" width="200" />
5-
6-
[![Build
7-
Status](https://travis-ci.org/ropensci/plotly.png?branch=master)](https://travis-ci.org/ropensci/plotly)
8-
[![CRAN
9-
Status](https://www.r-pkg.org/badges/version/plotly)](https://cran.r-project.org/package=plotly)
10-
[![CRAN
11-
Downloads](https://cranlogs.r-pkg.org/badges/grand-total/plotly)](https://www.rpackages.io/package/plotly)
12-
[![monthly](https://cranlogs.r-pkg.org/badges/plotly)](https://www.rpackages.io/package/plotly)
13-
14-
An R package for creating interactive web graphics via the open source
15-
JavaScript graphing library
16-
[plotly.js](https://github.com/plotly/plotly.js).
17-
18-
## Installation
19-
20-
Install from CRAN:
21-
22-
``` r
23-
install.packages("plotly")
24-
```
25-
26-
Or install the latest development version (on GitHub) via devtools:
27-
28-
``` r
29-
devtools::install_github("ropensci/plotly")
30-
```
31-
32-
## Getting started
33-
34-
### Web-based ggplot2 graphics
35-
36-
If you use [ggplot2](https://github.com/tidyverse/ggplot2), `ggplotly()`
37-
converts your static plots to an interactive web-based version\!
38-
39-
``` r
40-
library(plotly)
41-
g <- ggplot(faithful, aes(x = eruptions, y = waiting)) +
42-
stat_density_2d(aes(fill = ..level..), geom = "polygon") +
43-
xlim(1, 6) + ylim(40, 100)
44-
ggplotly(g)
45-
```
46-
47-
![<https://i.imgur.com/G1rSArP.gifv>](https://i.imgur.com/G1rSArP.gif)
48-
49-
By default, `ggplotly()` tries to replicate the static ggplot2 version
50-
exactly (before any interaction occurs), but sometimes you need greater
51-
control over the interactive behavior. The `ggplotly()` function itself
52-
has some convenient “high-level” arguments, such as `dynamicTicks`,
53-
which tells plotly.js to dynamically recompute axes, when appropriate.
54-
The `style()` function also comes in handy for *modifying* the
55-
underlying trace
56-
attributes (e.g. [hoveron](https://plotly.com/r/reference/#scatter-hoveron)) used to generate the plot:
57-
58-
``` r
59-
gg <- ggplotly(g, dynamicTicks = "y")
60-
style(gg, hoveron = "points", hoverinfo = "x+y+text", hoverlabel = list(bgcolor = "white"))
61-
```
62-
63-
![<https://i.imgur.com/qRvLgea.gifv>](https://imgur.com/qRvLgea.gif)
64-
65-
Moreover, since `ggplotly()` returns a plotly object, you can apply
66-
essentially any function from the R package on that object. Some useful
67-
ones include `layout()` (for [customizing the
68-
layout](https://plotly-r.com/improving-ggplotly.html#modifying-layout)),
69-
`add_traces()` (and its higher-level `add_*()` siblings, for example
70-
`add_polygons()`, for [adding new
71-
traces/data](https://plotly-r.com/improving-ggplotly.html#leveraging-statistical-output)),
72-
`subplot()` (for [combining multiple plotly
73-
objects](https://plotly-r.com/arranging-views.html#arranging-plotly-objects)),
74-
and `plotly_json()` (for inspecting the underlying JSON sent to
75-
plotly.js).
76-
77-
The `ggplotly()` function will also respect some “unofficial”
78-
**ggplot2** aesthetics, namely `text` (for [customizing the
79-
tooltip](https://plotly-r.com/controlling-tooltips.html#tooltip-text-ggplotly)),
80-
`frame` (for [creating
81-
animations](https://plotly-r.com/animating-views.html)),
82-
and `ids` (for ensuring sensible smooth transitions).
83-
84-
### Using plotly without ggplot2
85-
86-
The `plot_ly()` function provides a more direct interface to plotly.js
87-
so you can leverage more specialized chart types (e.g., [parallel
88-
coordinates](https://plotly.com/r/parallel-coordinates-plot/) or
89-
[maps](https://plotly.com/r/maps/)) or even some visualization that the
90-
ggplot2 API won’t ever support (e.g., surface,
91-
[mesh](https://plotly.com/r/3d-mesh/),
92-
[trisurf](https://plotly.com/r/trisurf/), etc).
93-
94-
``` r
95-
plot_ly(z = ~volcano, type = "surface")
96-
```
97-
98-
![<https://plot.ly/~brnvg/1134>](https://plot.ly/~brnvg/1134.png)
99-
100-
## Learn more
101-
102-
To learn more about special features that the plotly R package provides (e.g., [client-side linking](https://plotly-r.com/client-side-linking.html), [**shiny** integration](https://plotly-r.com/linking-views-with-shiny.html), [editing and generating static images](https://plotly-r.com/publish.html), [custom events in JavaScript](https://plotly-r.com/javascript.html), and more), see <https://plotly-r.com>. You may already be familiar with existing plotly documentation (e.g., <https://plotly.com/r/>), which is essentially a language-agnostic how-to guide for learning plotly.js, whereas <https://plotly-r.com> is meant to be more wholistic tutorial written by and for the R user. The package itself ships with a number of demos (list them by running `demo(package = "plotly")`) and shiny/rmarkdown examples (list them by running `plotly_example("shiny")` or `plotly_example("rmd")`). [Carson](https://cpsievert.me) also keeps numerous [slide decks](https://talks.cpsievert.me) with useful examples and concepts.
103-
104-
## Contributing
105-
106-
Please read through our [contributing
107-
guidelines](https://github.com/ropensci/plotly/blob/master/CONTRIBUTING.md).
108-
Included are directions for opening issues, asking questions,
109-
contributing changes to plotly, and our code of
110-
conduct.
111-
112-
-----
113-
114-
![<https://ropensci.org>](https://www.ropensci.org/public_images/github_footer.png)
3+
Changes to widget js code should be made in [theSrc/tasks](theSrc/tasks) and `gulp compileWidgetEntryPoint` needs to be called to compile the code and write it to [inst/htmlwidgets](inst/htmlwidgets).

build/config/widget.config.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
const cliArgs = require('yargs').argv
2+
const _ = require('lodash')
3+
4+
const config = {
5+
widgetEntryPoint: 'theSrc/scripts/plotly.js',
6+
widgetFactory: 'theSrc/scripts/plotly.factory.js',
7+
widgetName: 'plotly',
8+
}
9+
10+
const commandLineOverides = _.omit(cliArgs, ['_', '$0'])
11+
module.exports = _.merge(config, commandLineOverides)

gulpfile.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
const gulp = require('gulp')
2+
const rhtmlBuildUtils = require('rhtmlBuildUtils')
3+
4+
const dontRegisterTheseTasks = []
5+
rhtmlBuildUtils.registerGulpTasks({
6+
gulp: gulp,
7+
exclusions: dontRegisterTheseTasks
8+
})

0 commit comments

Comments
 (0)