Skip to content

Commit 734f672

Browse files
committed
ggplotly(NULL, 'msg') and plotly_build(NULL, 'msg') now return an div('msg') rather than error, fixes #1116
1 parent 1e689ef commit 734f672

File tree

5 files changed

+15
-3
lines changed

5 files changed

+15
-3
lines changed

DESCRIPTION

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,7 @@ Suggests:
6666
png,
6767
IRdisplay
6868
Remotes:
69-
tidyverse/ggplot2,
70-
r-spatial/sf
69+
tidyverse/ggplot2
7170
LazyData: true
7271
RoxygenNote: 6.0.1
7372
Roxygen: list(markdown = TRUE)

NAMESPACE

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ S3method(geom2trace,GeomText)
2121
S3method(geom2trace,GeomTile)
2222
S3method(geom2trace,default)
2323
S3method(ggplot,plotly)
24+
S3method(ggplotly,"NULL")
2425
S3method(ggplotly,ggmatrix)
2526
S3method(ggplotly,ggplot)
2627
S3method(ggplotly,plotly)
@@ -30,6 +31,7 @@ S3method(layout,matrix)
3031
S3method(layout,plotly)
3132
S3method(layout,shiny.tag.list)
3233
S3method(mutate_,plotly)
34+
S3method(plotly_build,"NULL")
3335
S3method(plotly_build,gg)
3436
S3method(plotly_build,list)
3537
S3method(plotly_build,plotly)
@@ -229,6 +231,7 @@ importFrom(grDevices,extendrange)
229231
importFrom(grDevices,rgb)
230232
importFrom(graphics,layout)
231233
importFrom(htmltools,browsable)
234+
importFrom(htmltools,div)
232235
importFrom(htmltools,tagList)
233236
importFrom(htmltools,tags)
234237
importFrom(htmlwidgets,createWidget)

R/ggplotly.R

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,11 @@ ggplotly <- function(p = ggplot2::last_plot(), width = NULL, height = NULL,
6868
UseMethod("ggplotly", p)
6969
}
7070

71+
#' @export
72+
ggplotly.NULL <- function(...) {
73+
htmltools::browsable(htmltools::div(...))
74+
}
75+
7176
#' @export
7277
ggplotly.plotly <- function(p = ggplot2::last_plot(), width = NULL, height = NULL,
7378
tooltip = "all", dynamicTicks = FALSE,

R/imports.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
#' @importFrom htmlwidgets createWidget sizingPolicy saveWidget onRender prependContent
1111
#' @importFrom lazyeval f_eval is_formula all_dots is_lang f_new
1212
#' @importFrom tibble as_tibble
13-
#' @importFrom htmltools browsable tagList tags
13+
#' @importFrom htmltools browsable tagList tags div
1414
#' @importFrom purrr transpose
1515
#' @importFrom tools file_ext file_path_sans_ext
1616
#' @importFrom data.table as.data.table setorderv

R/plotly_build.R

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,11 @@ plotly_build <- function(p, registerFrames = TRUE) {
2020
UseMethod("plotly_build")
2121
}
2222

23+
#' @export
24+
plotly_build.NULL <- function(...) {
25+
htmltools::browsable(htmltools::div(...))
26+
}
27+
2328
#' @export
2429
plotly_build.list <- function(p, registerFrames = TRUE) {
2530
plotly_build(as_widget(p))

0 commit comments

Comments
 (0)