Skip to content

Commit b610dcf

Browse files
committed
Merge pull request #226 from ropensci/carson-dsl
Version 1.0
2 parents 6ff8831 + 27c7ac4 commit b610dcf

File tree

135 files changed

+15512
-1177
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

135 files changed

+15512
-1177
lines changed

.Rbuildignore

+4-1
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,8 @@ Karthik_local.R
33
Makefile
44
man-roxygen
55
man-roxygen/^.*\.Rproj$
6+
^.*\.Rproj$
67
^\.Rproj\.user$
7-
vignettes/margins.sty
8+
^data-raw$
9+
vignettes/margins.sty
10+
CONDUCT.md

.travis.yml

+29-12
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,35 @@
1-
language: r
1+
language: c
22

3-
env:
4-
global:
5-
- secure: "cJ1bDRrAdIRjG+JnsQI9CdA4wQJhJJ2DdCNQ3frl8dotk69z61EiGCFW1Ir1cAY5V/NbHvFHp91HDiSo28ggwqRkEPBOGE44ico5gtVaELu3M/EnkWc2ZwQoN1273Vfdm26QYidqrvWrpLZ0XkFl7Q8xgvBswx30MF7y61+0Hv4="
3+
before_install:
4+
- curl -OL http://raw.github.com/craigcitro/r-travis/master/scripts/travis-tool.sh
5+
- chmod 755 ./travis-tool.sh
6+
- ./travis-tool.sh bootstrap
7+
# password is encrypted below
8+
- echo "Sys.setenv('plotly_username' = 'dfvd')" > ~/.Rprofile
69

7-
r_packages:
8-
- RCurl
9-
- RJSONIO
10-
- lattice
11-
- xtable
12-
- httr
10+
install:
11+
- ./travis-tool.sh install_deps
1312

1413
before_script:
15-
- chmod 755 inst/testscripts/.push_test_table.sh
14+
- git config --global user.name "cpsievert"
15+
- git config --global user.email "[email protected]"
16+
- git clone https://github.com/cpsievert/plotly-test-table.git ../plotly-test-table
17+
18+
script:
19+
- Rscript -e "devtools::install(); source('tests/testthat.R', chdir = TRUE)"
1620

1721
after_success:
18-
- inst/testscripts/.push_test_table.sh
22+
- cd ../plotly-test-table
23+
- ls -R
24+
- Rscript ../plotly/inst/build-push-comment.R
25+
26+
env:
27+
global:
28+
# plotly_api_key (for posting to plot.ly)
29+
- secure: "eHO4OUmgLusU9i4xSvr3daZxnsMZw3x4FH8BYVEC8Ja+Ey6kkAFFSh2iAC/CqewEYJ7I/M8aIJYqlyTMGRYUgy36WU7iWHAGgaZOU8fIB5dWzMwHbIvS4Naq2sdU7lRT7sxkS+40K1+rplpWDoLF2yt8vSRWo9rjNzp+yc8PjXM="
30+
# GITHUB_PAT (for pushing to plotly-test-table)
31+
- secure: "LHJONgWOo+98vNeFLI7LSJU3RtbMVszlI79GB8CcXmc2mlgM/UtZ5b6RnkNlhmg3Gj1/uObfm/rIybVTwuS1yNpeKv73+gsZOYhobVXiUGVxdRFG/mg5mbqwyWkkuofjPGFlMZCEMgHim37eZzgjSibwVH1LClRDsCoFMCgvgV0="
32+
# plotlyjs_full (link to the full offline bundle)
33+
- secure: "ivxfqGwbzpBpVJe+jVcOBktcmLrT38W/ZapAk/FNDu+yaBhag1eCYErAPPx6Snc4GzwatMt22v4SxAqXQF4SAhTRtmrWVaWnbhzuNqpTkiS6IKEd6EqaoyUZvUTgXh1ruyik00zl3ET9898O3vFfqafodljE0lCLVICHq6ANo68="
34+
# plotlyjs_no_jq (link to the offline bundle w/o jQuery)
35+
- secure: "i5cYEs2lCFSYgrSTHMmzzs8hRwAwiz89GpgM16fqUDQz8T1QMWofNugQInS7fIfKL36FoTz8BaiLs2D98/2kDkkZ0LTHnfrdrY9PO+7D+CmL8QeLLp4atBT0i682nwy8RzEqlvB8yAVQo/i0Eh8tmT97pppddsxttZKoUidfOeA="

CONDUCT.md

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# Contributor Code of Conduct
2+
3+
As contributors and maintainers of this project, we pledge to respect all people who
4+
contribute through reporting issues, posting feature requests, updating documentation,
5+
submitting pull requests or patches, and other activities.
6+
7+
We are committed to making participation in this project a harassment-free experience for
8+
everyone, regardless of level of experience, gender, gender identity and expression,
9+
sexual orientation, disability, personal appearance, body size, race, ethnicity, age, or religion.
10+
11+
Examples of unacceptable behavior by participants include the use of sexual language or
12+
imagery, derogatory comments or personal attacks, trolling, public or private harassment,
13+
insults, or other unprofessional conduct.
14+
15+
Project maintainers have the right and responsibility to remove, edit, or reject comments,
16+
commits, code, wiki edits, issues, and other contributions that are not aligned to this
17+
Code of Conduct. Project maintainers who do not follow the Code of Conduct may be removed
18+
from the project team.
19+
20+
Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by
21+
opening an issue or contacting one or more of the project maintainers.
22+
23+
This Code of Conduct is adapted from the Contributor Covenant
24+
(http:contributor-covenant.org), version 1.0.0, available at
25+
http://contributor-covenant.org/version/1/0/0/

DESCRIPTION

+29-24
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,43 @@
11
Package: plotly
2-
Type: Package
3-
Title: Interactive, publication-quality graphs online.
4-
Version: 0.6.3
5-
Authors@R: c(person("Chris", "Parmer", role = c("aut", "cre"),
2+
Title: Create interactive web-based graphs via plotly's API
3+
Version: 1.0.0
4+
Authors@R: c(person("Chris", "Parmer", role = c("aut", "cph"),
65
email = "[email protected]"),
76
person("Scott", "Chamberlain", role = "aut",
87
email = "[email protected]"),
98
person("Karthik", "Ram", role = "aut",
109
email = "[email protected]"),
11-
person("Toby", "Hocking", role="aut",
12-
13-
person("Marianne", "Corvellec", role="aut",
14-
15-
person("Pedro", "Despouy", role="aut",
16-
17-
person("Carson", "Sievert", role="aut",
18-
19-
Author: Chris Parmer
20-
Maintainer: Marianne Corvellec <[email protected]>
10+
person("Toby", "Hocking", role = "aut",
11+
email = "[email protected]"),
12+
person("Marianne", "Corvellec", role = "aut",
13+
email = "[email protected]"),
14+
person("Pedro", "Despouy", role = "aut",
15+
email = "[email protected]"),
16+
person("Carson", "Sievert", role = c("aut", "cre"),
17+
email = "[email protected]"))
2118
License: MIT + file LICENSE
22-
Description: An interface to plotly's online graphing tools with desktop R
23-
environments. Send data to a plotly account and view the graphs in a web
24-
browser. Style the graphs with code or with plotly's online interface;
25-
share data and graphs publicly with a url or privately among other plotly
26-
members; access your graphs from anywhere. Example graph:
27-
https://plot.ly/~chris/1638/
19+
Description: Create interactive web-based graphs via plotly's API.
20+
Easily translate ggplot2 plots to plotly and/or create custom plotly graphs.
21+
Once uploaded to a plotly account, plotly graphs (and the data behind them)
22+
can be viewed and modified in a web browser.
2823
URL: https://github.com/ropensci/plotly
2924
BugReports: https://github.com/ropensci/plotly/issues
3025
Depends:
31-
RCurl,
32-
RJSONIO,
3326
ggplot2
3427
Imports:
35-
knitr
28+
scales,
29+
httr,
30+
jsonlite,
31+
magrittr,
32+
digest,
33+
viridis
3634
Suggests:
35+
dplyr,
3736
maps,
38-
testthat
37+
testthat,
38+
knitr,
39+
devtools,
40+
shiny,
41+
rmarkdown,
42+
RColorBrewer
43+
LazyData: true

NAMESPACE

+23-7
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,34 @@
11
# Generated by roxygen2 (4.1.1): do not edit by hand
22

3+
S3method(print,offline)
4+
S3method(print,plotly)
5+
export("%>%")
6+
export(add_trace)
7+
export(embed_notebook)
8+
export(get_figure)
39
export(gg2list)
410
export(ggplot_build2)
11+
export(ggplotly)
512
export(group2NA)
13+
export(knit_print.offline)
14+
export(knit_print.plotly)
15+
export(last_plot)
616
export(layer2traces)
17+
export(layout)
18+
export(offline)
719
export(paramORdefault)
20+
export(plot_ly)
821
export(plotly)
9-
export(set_config_file)
10-
export(set_credentials_file)
11-
export(show_config_file)
12-
export(show_credentials_file)
22+
export(plotlyOutput)
23+
export(plotly_POST)
24+
export(plotly_build)
25+
export(plotly_empty)
26+
export(renderPlotly)
1327
export(signup)
28+
export(style)
29+
export(subplot)
1430
export(toRGB)
15-
import(RCurl)
16-
import(RJSONIO)
1731
import(ggplot2)
18-
import(knitr)
32+
import(httr)
33+
import(jsonlite)
34+
importFrom(magrittr,"%>%")

NEWS

+14
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,17 @@
1+
1.0.0 -- 31 July 2015
2+
3+
A major reworking of package internals which includes a few backwards incompatible changes.
4+
5+
Major changes include:
6+
7+
(1) New high-level grammar for expressing Plotly graphs from R (see the `plot_ly()`, `add_trace()`, `layout()`, and `style()` functions).
8+
(2) New print methods which make it easier to create, modify, and embed Plotly graphs.
9+
(3) Added a `subplot()` function for putting several graphs on a single page.
10+
(4) Added the `renderPlotly()` and `plotlyOutput()` functions for embedding plotly graphs in shiny applications.
11+
(5) Added `offline()` function for creating standalone HTML pages via Plotly Offline (see http://purchasing.plot.ly/)
12+
13+
For more details, see the new vignettes with `browseVignettes(package = "plotly")` and/or the pull request -> https://github.com/ropensci/plotly/pull/226
14+
115
0.6.3 -- 2 June 2015
216

317
Add new tests inspired by the R Cookbook distributions #214

R/data.R

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
#' Wind data
2+
#'
3+
#' Description TBD.
4+
#'
5+
#' @format A data frame with three variables: \code{r}, \code{t},
6+
#' \code{nms}.
7+
"wind"
8+
9+
#' Mic data
10+
#'
11+
#' Description TBD.
12+
#'
13+
#' @format A data frame with three variables: \code{r}, \code{t},
14+
#' \code{nms}.
15+
"mic"
16+
17+
#' Hobbs data
18+
#'
19+
#' Description TBD.
20+
#'
21+
#' @format A data frame with three variables: \code{r}, \code{t},
22+
#' \code{nms}.
23+
"hobbs"

R/figure.R

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
#' Request a figure object
2+
#'
3+
#' Figure objects work in the same way as plotly objects, but when printed,
4+
#' they overwrite the already existing plotly object
5+
#' (instead of creating a new plotly).
6+
#'
7+
#' @param username corresponding username for the figure.
8+
#' @param id of the Plotly figure.
9+
#' @export
10+
#' @references https://plot.ly/rest/
11+
#' @examples
12+
#' \dontrun{
13+
#' # Anyone can obtain the information for a particular plot
14+
#' fig <- get_figure("cpsievert", "559")
15+
#' # If you have proper credentials, you can easily modify
16+
#' layout(fig, title = paste("Modified on ", Sys.time()))
17+
#' }
18+
get_figure <- function(username, id) {
19+
if (missing(username)) username <- verify("username")
20+
if (missing(id)) stop("Please provide a figure id number")
21+
base_url <- file.path(get_domain(), "apigetfile", username, id)
22+
resp <- httr::GET(base_url, plotly_headers(), httr::config(ssl_verifypeer=FALSE))
23+
process(struct(resp, "figure"))
24+
}

R/ggplotly.R

+47-4
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,37 @@
1+
#' Create plotly graphs using ggplot2 syntax
2+
#'
3+
#' See up-to-date documentation and examples at
4+
#' \url{https://plot.ly/ggplot2}
5+
#'
6+
#' @param p a ggplot object.
7+
#' @seealso \link{signup}, \link{plot_ly}
8+
#' @import httr jsonlite
9+
#' @export
10+
#' @author Carson Sievert
11+
#' @examples \dontrun{
12+
#' # simple example
13+
#' ggiris <- qplot(Petal.Width, Sepal.Length, data = iris, color = Species)
14+
#' ggplotly(ggiris)
15+
#'
16+
#' # maps!!
17+
#' data(canada.cities, package = "maps")
18+
#' viz <- ggplot(canada.cities, aes(long, lat)) +
19+
#' borders(regions = "canada", name = "borders") +
20+
#' coord_equal() +
21+
#' geom_point(aes(text = name, size = pop), colour = "red",
22+
#' alpha = 1/2, name = "cities")
23+
#' ggplotly(viz)
24+
#' }
25+
#'
26+
ggplotly <- function(p = last_plot()) {
27+
l <- gg2list(p)
28+
hash_plot(p$data, l)
29+
}
30+
31+
# ----------------------------------------------------------------------------
32+
# Objects accessed inside gg2list()
33+
# ----------------------------------------------------------------------------
34+
135
# calc. the epoch
236
now <- Sys.time()
337
the.epoch <- now - as.numeric(now)
@@ -907,8 +941,17 @@ gg2list <- function(p) {
907941
flipped.layout[["yaxis"]] <- x
908942
}
909943

910-
fig <- list(data=flipped.traces, layout=flipped.layout)
911-
912-
fig
913-
944+
l <- list(data = flipped.traces, layout = flipped.layout)
945+
# When auto_unbox is T in jsonlite::toJSON() it doesn't unbox objects of
946+
# class AsIs. We use this in plotly::to_JSON() and tag special fields such as
947+
# x/y/etc so that they don't get unboxed when they are of length 1.
948+
# unfortunately, this conflicts when using I() in qplot. For example,
949+
# qplot(1:10, 1:10, size = I(10))
950+
un <- function(x) {
951+
if (is.null(x)) return(NA)
952+
if (is.list(x)) lapply(x, un)
953+
else if (inherits(x, "AsIs")) unclass(x)
954+
else x
955+
}
956+
lapply(l, un)
914957
}

0 commit comments

Comments
 (0)