31
31
# ' }
32
32
# '
33
33
ggplotly <- function (p = ggplot2 :: last_plot(), width = NULL , height = NULL ,
34
- tooltip = " all" , source = " A" ) {
34
+ tooltip = " all" , source = " A" , ... ) {
35
35
UseMethod(" ggplotly" , p )
36
36
}
37
37
38
38
# ' @export
39
39
ggplotly.ggmatrix <- function (p = ggplot2 :: last_plot(), width = NULL ,
40
- height = NULL , tooltip = " all" , source = " A" ) {
40
+ height = NULL , tooltip = " all" , source = " A" , ... ) {
41
41
plotList <- list ()
42
42
for (i in seq_len(p $ nrow )) {
43
43
for (j in seq_len(p $ ncol )) {
@@ -47,14 +47,14 @@ ggplotly.ggmatrix <- function(p = ggplot2::last_plot(), width = NULL,
47
47
# TODO:
48
48
# (1) how to show x/y titles? Should these be arguments in subplot?
49
49
# (2) it only makes since to share axes on the lower diagonal
50
- l <- get_plot(do.call(subplot , c(plotList , list (nrows = p $ nrow ))))
50
+ l <- get_plot(do.call(subplot , c(plotList , list (nrows = p $ nrow , ... ))))
51
51
l $ layout $ title <- p $ title
52
52
hash_plot(p $ data , l )
53
53
}
54
54
55
55
# ' @export
56
56
ggplotly.ggplot <- function (p = ggplot2 :: last_plot(), width = NULL ,
57
- height = NULL , tooltip = " all" , source = " A" ) {
57
+ height = NULL , tooltip = " all" , source = " A" , ... ) {
58
58
l <- gg2list(p , width = width , height = height , tooltip = tooltip , source = source )
59
59
hash_plot(p $ data , l )
60
60
}
@@ -67,9 +67,10 @@ ggplotly.ggplot <- function(p = ggplot2::last_plot(), width = NULL,
67
67
# ' tooltip. The default, "all", means show all the aesthetic tooltips
68
68
# ' (including the unofficial "text" aesthetic).
69
69
# ' @param source Only relevant for \link{event_data}.
70
+ # ' @param ... currently not used
70
71
# ' @return a 'built' plotly object (list with names "data" and "layout").
71
72
# ' @export
72
- gg2list <- function (p , width = NULL , height = NULL , tooltip = " all" , source = " A" ) {
73
+ gg2list <- function (p , width = NULL , height = NULL , tooltip = " all" , source = " A" , ... ) {
73
74
# ------------------------------------------------------------------------
74
75
# Our internal version of ggplot2::ggplot_build(). Modified from
75
76
# https://github.com/hadley/ggplot2/blob/0cd0ba/R/plot-build.r#L18-L92
@@ -469,6 +470,8 @@ gg2list <- function(p, width = NULL, height = NULL, tooltip = "all", source = "A
469
470
col_txt <- paste(
470
471
p $ facet $ labeller(lay [names(p $ facet [[col_vars ]])]), collapse = " , "
471
472
)
473
+ if (is_blank(theme [[" strip.text.x" ]])) col_txt <- " "
474
+ if (inherits(p $ facet , " grid" ) && lay $ ROW != 1 ) col_txt <- " "
472
475
if (nchar(col_txt ) > 0 ) {
473
476
col_lab <- make_label(
474
477
col_txt , x = mean(xdom ), y = max(ydom ),
@@ -482,6 +485,8 @@ gg2list <- function(p, width = NULL, height = NULL, tooltip = "all", source = "A
482
485
row_txt <- paste(
483
486
p $ facet $ labeller(lay [names(p $ facet $ rows )]), collapse = " , "
484
487
)
488
+ if (is_blank(theme [[" strip.text.y" ]])) row_txt <- " "
489
+ if (inherits(p $ facet , " grid" ) && lay $ COL != nCols ) row_txt <- " "
485
490
if (nchar(row_txt ) > 0 ) {
486
491
row_lab <- make_label(
487
492
row_txt , x = max(xdom ), y = mean(ydom ),
0 commit comments