@@ -18,7 +18,10 @@ is.offline <- function(x) inherits(x, "offline")
18
18
# set a default for the offline bundle directory
19
19
if (Sys.getenv(" plotly_offline" ) == " " ) {
20
20
Sys.setenv(" plotly_offline" = " ~/.plotly/plotlyjs" )
21
- # maybe rely a message if bundle is (or isn't) found?
21
+ # iframes won't work in RStudio viewer, so we override
22
+ # shiny's browser launch method
23
+ if (! has_offline())
24
+ options(" shiny.launch.browser" = function (url ) { browseURL(url ) })
22
25
}
23
26
invisible (NULL )
24
27
}
@@ -61,13 +64,16 @@ get_plot <- function(data = NULL, last = FALSE) {
61
64
}
62
65
}
63
66
64
- # ' Retrive last plotly to be modified or created
67
+ # ' Retrive and create the last plotly ( or ggplot).
65
68
# '
66
69
# ' @seealso \link{plotly_build}
70
+ # ' @param data (optional) a data frame with a class of plotly (and a plotly_hash attribute).
67
71
# ' @export
68
72
# '
69
- last_plot <- function (... ) {
70
- p <- get_plot(... , last = TRUE )
73
+ last_plot <- function (data = NULL ) {
74
+ p <- try(get_plot(data , last = TRUE ), silent = TRUE )
75
+ if (inherits(p , " try-error" )) p <- try(ggplotly(), silent = TRUE )
76
+ if (inherits(p , " try-error" )) stop(" The last plot doesn't exist" )
71
77
structure(
72
78
p ,
73
79
class = unique(c(" plotly" , class(p )))
@@ -143,8 +149,7 @@ get_domain <- function(type = "main") {
143
149
144
150
# plotly's special keyword arguments in POST body
145
151
get_kwargs <- function () {
146
- c(" filename" , " fileopt" , " style" , " traces" , " layout" ,
147
- " world_readable" , " kwarg_example" )
152
+ c(" filename" , " fileopt" , " style" , " traces" , " layout" , " world_readable" )
148
153
}
149
154
150
155
# POST header fields
0 commit comments