@@ -85,13 +85,15 @@ knit_print.figure <- function(x, options, ...) {
85
85
86
86
# ' Embed a plotly figure as an iframe into a IPython Notebook
87
87
# ' @param x a plotly object
88
- # ' @param width attribute of the iframe
89
- # ' @param height attribute of the iframe
88
+ # ' @param width attribute of the iframe. If \code{NULL}, the width in
89
+ # ' \code{plot_ly} is used. If that is also \code{NULL}, '100\%' is the default.
90
+ # ' @param height attribute of the iframe. If \code{NULL}, the height in
91
+ # ' \code{plot_ly} is used. If that is also \code{NULL}, '400px' is the default.
90
92
# ' @param dir a directory for placing
91
93
# ' @param file a filename for saving the standalone HTML
92
94
# ' (only used if x is a non-figure object)
93
95
# ' @export
94
- embed_notebook <- function (x , width = " 100% " , height = " 400 " ,
96
+ embed_notebook <- function (x , width = NULL , height = NULL ,
95
97
file = paste0(" plotlyJupyterHTML/" , digest :: digest(Sys.time()), " .html" )) {
96
98
if (system.file(package = " IRdisplay" ) == " " ) {
97
99
warning(" You need the IRdisplay package to use this function: \n " ,
@@ -109,13 +111,13 @@ embed_notebook <- function(x, width = "100%", height = "400",
109
111
} else {
110
112
paste0(l $ url , " .embed" )
111
113
}
112
- iframe <- plotly_iframe(src , width , height )
114
+ iframe <- plotly_iframe(src , width % || % l $ width , height % || % l $ height )
113
115
get(" display_html" , envir = asNamespace(" IRdisplay" ))(iframe )
114
116
}
115
117
116
- plotly_iframe <- function (url , width , height ) {
118
+ plotly_iframe <- function (url = " " , width = NULL , height = NULL ) {
117
119
sprintf(
118
120
' <iframe src="%s" width="%s" height="%s" id="igraph" scrolling="no" seamless="seamless" frameBorder="0"> </iframe>' ,
119
- url , width , height
121
+ url , width % || % " 100% " , height % || % " 400 "
120
122
)
121
123
}
0 commit comments