From 86e1e3607d58b3af2cf1c809f71c2536ce20a87d Mon Sep 17 00:00:00 2001 From: nikolai Date: Mon, 30 May 2016 18:42:44 +0200 Subject: [PATCH] No '.embed' extension for Jupyter embedded pages --- R/print.R | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/R/print.R b/R/print.R index 4985fd3e04..bffa7b5f6b 100644 --- a/R/print.R +++ b/R/print.R @@ -103,7 +103,7 @@ knit_print.figure <- function(x, options, ...) { knitr::asis_output(iframe) } -#' Embed a plotly figure as an iframe into a IPython Notebook +#' Embed a plotly figure as an iframe into a Jupyter Notebook #' @param x a plotly object #' @param width attribute of the iframe. If \code{NULL}, the width in #' \code{plot_ly} is used. If that is also \code{NULL}, '100\%' is the default. @@ -128,15 +128,16 @@ embed_notebook <- function(x, width = NULL, height = NULL, htmlwidgets::saveWidget(as.widget(l), file = basename(file)) file } else { - paste0(l$url, ".embed") + l$url } - iframe <- plotly_iframe(src, width %||% l$width, height %||% l$height) + iframe <- plotly_iframe(src, width %||% l$width, height %||% l$height, url_ext = "") get("display_html", envir = asNamespace("IRdisplay"))(iframe) } -plotly_iframe <- function(url = "", width = NULL, height = NULL) { +plotly_iframe <- function(url = "", width = NULL, height = NULL, url_ext = ".embed") { + url <- paste0(url, url_ext) sprintf( - '', + '', url, width %||% "100%", height %||% "400" ) }