Skip to content

Commit 1308282

Browse files
committed
ggplotly() should look for the last _ggplot_ if no plot is provided
1 parent 69a118a commit 1308282

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

R/ggplotly.R

+3-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
#' ggplotly(viz)
2424
#' }
2525
#'
26-
ggplotly <- function(p = last_plot()) {
26+
ggplotly <- function(p = ggplot2::last_plot()) {
2727
l <- gg2list(p)
2828
hash_plot(p$data, l)
2929
}
@@ -948,6 +948,8 @@ gg2list <- function(p) {
948948
# unfortunately, this conflicts when using I() in qplot. For example,
949949
# qplot(1:10, 1:10, size = I(10))
950950
un <- function(x) {
951+
# jsonlite converts NULL to {} and NA to null (plotly prefers null to {})
952+
# https://github.com/jeroenooms/jsonlite/issues/29
951953
if (is.null(x)) return(NA)
952954
if (is.list(x)) lapply(x, un)
953955
else if (inherits(x, "AsIs")) unclass(x)

0 commit comments

Comments
 (0)