Skip to content

Commit

Permalink
No '.embed' extension for Jupyter embedded pages
Browse files Browse the repository at this point in the history
  • Loading branch information
Nikolai-Hlubek committed May 30, 2016
1 parent cf60510 commit 86e1e36
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions R/print.R
Expand Up @@ -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.
Expand All @@ -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(
'<iframe src="%s.embed" width="%s" height="%s" id="igraph" scrolling="no" seamless="seamless" frameBorder="0"> </iframe>',
'<iframe src="%s" width="%s" height="%s" id="igraph" scrolling="no" seamless="seamless" frameBorder="0"> </iframe>',
url, width %||% "100%", height %||% "400"
)
}

0 comments on commit 86e1e36

Please sign in to comment.