Skip to content

Commit d1eb6ea

Browse files
committed
more sensible defaults in plotly_POST()
1 parent bdb2bcc commit d1eb6ea

File tree

2 files changed

+11
-11
lines changed

2 files changed

+11
-11
lines changed

NEWS

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,13 @@
1-
3.3.2 -- 12 Mar 2016
1+
3.4.0 -- 12 Mar 2016
22

33
NEW FEATURES:
44

55
* geom_map() and geom_hex() are now supported.
66

7+
CHANGES:
8+
9+
* The default value of the fileopt argument was changed from "new" to "overwrite".
10+
711
BUGFIX:
812

913
* Made a number of bugfixes/improvements to hoverinfo & conversion of geom_tile()/geom_point().

R/plotly_POST.R

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -35,17 +35,13 @@
3535
#' plotly_POST(p, filename = "mtcars-bar-plot")
3636
#' }
3737

38-
plotly_POST <- function(x, filename, fileopt = "new",
38+
plotly_POST <- function(x, filename = NULL, fileopt = "overwrite",
3939
sharing = c("public", "private", "secret")) {
4040
x <- plotly_build(x)
41-
x$filename <- if (!missing(filename)) {
42-
filename
43-
} else {
44-
# try our damndest to assign a sensible filename
45-
x$filename %||% as.character(x$layout$title) %||%
41+
# try our damndest to assign a sensible filename
42+
x$filename <- x$filename %||% as.character(x$layout$title) %||%
4643
paste(c(x$layout$xaxis$title, x$layout$yaxis$title, x$layout$zaxis$title),
47-
collapse = " vs. ") %||% "plot from api"
48-
}
44+
collapse = " vs. ") %||% paste("Created at", Sys.time())
4945
if (!is.null(x$fileopt)) {
5046
warning("fileopt was specified in the wrong place.",
5147
"Please specify in plotly_POST()")
@@ -68,8 +64,8 @@ plotly_POST <- function(x, filename, fileopt = "new",
6864
origin = "plot",
6965
platform = "R",
7066
version = as.character(packageVersion("plotly")),
71-
args = to_JSON(x$data),
72-
kwargs = to_JSON(x[get_kwargs()])
67+
args = to_JSON(compact(x$data)),
68+
kwargs = to_JSON(compact(x[get_kwargs()]))
7369
)
7470
base_url <- file.path(get_domain(), "clientresp")
7571
resp <- httr::POST(base_url, body = bod)

0 commit comments

Comments
 (0)