Skip to content

Commit ad82656

Browse files
JustinCCYapchschan
authored andcommitted
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 ce19f9d commit ad82656

File tree

10 files changed

+1018
-1071
lines changed

10 files changed

+1018
-1071
lines changed

README.md

Lines changed: 2 additions & 114 deletions
Original file line numberDiff line numberDiff line change
@@ -1,115 +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-
<!-- badges: start -->
7-
[![R-CMD-check](https://github.com/ropensci/plotly/workflows/R-CMD-check/badge.svg)](https://github.com/plotly/plotly.R/actions)
8-
[![CRAN Status](https://www.r-pkg.org/badges/version/plotly)](https://cran.r-project.org/package=plotly)
9-
[![CRAN Downloads](https://cranlogs.r-pkg.org/badges/grand-total/plotly)](https://cranlogs.r-pkg.org/badges/grand-total/plotly)
10-
[![monthly](https://cranlogs.r-pkg.org/badges/plotly)](https://cranlogs.r-pkg.org/badges/plotly)
11-
<!-- badges: end -->
12-
13-
An R package for creating interactive web graphics via the open source
14-
JavaScript graphing library
15-
[plotly.js](https://github.com/plotly/plotly.js).
16-
17-
<div align="center">
18-
<a href="https://dash.plotly.com/project-maintenance">
19-
<img src="https://dash.plotly.com/assets/images/maintained-by-community.png" width="400px" alt="Maintained by the Plotly Community">
20-
</a>
21-
</div>
22-
23-
## Installation
24-
25-
Install from CRAN:
26-
27-
``` r
28-
install.packages("plotly")
29-
```
30-
31-
Or install the latest development version (on GitHub) via `{remotes}`:
32-
33-
``` r
34-
remotes::install_github("plotly/plotly")
35-
```
36-
37-
## Getting started
38-
39-
### Web-based ggplot2 graphics
40-
41-
If you use [ggplot2](https://github.com/tidyverse/ggplot2), `ggplotly()`
42-
converts your static plots to an interactive web-based version\!
43-
44-
``` r
45-
library(plotly)
46-
g <- ggplot(faithful, aes(x = eruptions, y = waiting)) +
47-
stat_density_2d(aes(fill = ..level..), geom = "polygon") +
48-
xlim(1, 6) + ylim(40, 100)
49-
ggplotly(g)
50-
```
51-
52-
![<https://i.imgur.com/G1rSArP.gifv>](https://i.imgur.com/G1rSArP.gif)
53-
54-
By default, `ggplotly()` tries to replicate the static ggplot2 version
55-
exactly (before any interaction occurs), but sometimes you need greater
56-
control over the interactive behavior. The `ggplotly()` function itself
57-
has some convenient “high-level” arguments, such as `dynamicTicks`,
58-
which tells plotly.js to dynamically recompute axes, when appropriate.
59-
The `style()` function also comes in handy for *modifying* the
60-
underlying trace
61-
attributes (e.g. [hoveron](https://plotly.com/r/reference/#scatter-hoveron)) used to generate the plot:
62-
63-
``` r
64-
gg <- ggplotly(g, dynamicTicks = "y")
65-
style(gg, hoveron = "points", hoverinfo = "x+y+text", hoverlabel = list(bgcolor = "white"))
66-
```
67-
68-
![<https://i.imgur.com/qRvLgea.gifv>](https://imgur.com/qRvLgea.gif)
69-
70-
Moreover, since `ggplotly()` returns a plotly object, you can apply
71-
essentially any function from the R package on that object. Some useful
72-
ones include `layout()` (for [customizing the
73-
layout](https://plotly-r.com/improving-ggplotly.html#modifying-layout)),
74-
`add_traces()` (and its higher-level `add_*()` siblings, for example
75-
`add_polygons()`, for [adding new
76-
traces/data](https://plotly-r.com/improving-ggplotly.html#leveraging-statistical-output)),
77-
`subplot()` (for [combining multiple plotly
78-
objects](https://plotly-r.com/arranging-views.html#arranging-plotly-objects)),
79-
and `plotly_json()` (for inspecting the underlying JSON sent to
80-
plotly.js).
81-
82-
The `ggplotly()` function will also respect some “unofficial”
83-
**ggplot2** aesthetics, namely `text` (for [customizing the
84-
tooltip](https://plotly-r.com/controlling-tooltips.html#tooltip-text-ggplotly)),
85-
`frame` (for [creating
86-
animations](https://plotly-r.com/animating-views.html)),
87-
and `ids` (for ensuring sensible smooth transitions).
88-
89-
### Using plotly without ggplot2
90-
91-
The `plot_ly()` function provides a more direct interface to plotly.js
92-
so you can leverage more specialized chart types (e.g., [parallel
93-
coordinates](https://plotly.com/r/parallel-coordinates-plot/) or
94-
[maps](https://plotly.com/r/maps/)) or even some visualization that the
95-
ggplot2 API won’t ever support (e.g., surface,
96-
[mesh](https://plotly.com/r/3d-mesh/),
97-
[trisurf](https://plotly.com/r/trisurf/), etc).
98-
99-
``` r
100-
plot_ly(z = ~volcano, type = "surface")
101-
```
102-
103-
![<https://plotly.com/~brnvg/1134>](https://plotly.com/~brnvg/1134.png)
104-
105-
## Learn more
106-
107-
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.
108-
109-
## Contributing
110-
111-
Please read through our [contributing
112-
guidelines](https://github.com/plotly/plotly.R/blob/master/CONTRIBUTING.md).
113-
Included are directions for opening issues, asking questions,
114-
contributing changes to plotly, and our code of
115-
conduct.
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)