diff --git a/NAMESPACE b/NAMESPACE index 52e5c59f5e..1735b96da3 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -12,7 +12,7 @@ S3method(geom2trace,GeomText) S3method(geom2trace,GeomTile) S3method(geom2trace,default) S3method(print,figure) -S3method(print,plotly) +S3method(print,plotly_hash) S3method(to_basic,GeomAbline) S3method(to_basic,GeomArea) S3method(to_basic,GeomBoxplot) @@ -49,7 +49,7 @@ export(get_figure) export(gg2list) export(ggplotly) export(knit_print.figure) -export(knit_print.plotly) +export(knit_print.plotly_hash) export(last_plot) export(layout) export(offline) diff --git a/R/print.R b/R/print.R index aace37719a..c21a2743c2 100644 --- a/R/print.R +++ b/R/print.R @@ -5,9 +5,9 @@ #' @export #' @importFrom htmlwidgets createWidget #' @importFrom htmlwidgets sizingPolicy -print.plotly <- function(x, ...) { - if (!inherits(x, "htmlwidget")) x <- as.widget(x) - get("print.htmlwidget", envir = asNamespace("htmlwidgets"))(x, ...) +print.plotly_hash <- function(x, ...) { + x <- as.widget(x) + print(x, ...) } #' Print a plotly object in a knitr doc @@ -16,9 +16,9 @@ print.plotly <- function(x, ...) { #' @param options knitr options. #' @param ... additional arguments #' @export -knit_print.plotly <- function(x, options, ...) { - if (!inherits(x, "htmlwidget")) x <- as.widget(x) - get("knit_print.htmlwidget", envir = asNamespace("htmlwidgets"))(x, options = options, ...) +knit_print.plotly_hash <- function(x, options, ...) { + x <- as.widget(x) + knitr::knit_print(x, options, ...) } #' Convert a plotly object to an htmlwidget object diff --git a/R/utils.R b/R/utils.R index 82c8ad4737..53bd291594 100644 --- a/R/utils.R +++ b/R/utils.R @@ -36,7 +36,7 @@ hash_plot <- function(df, p) { assign(hash, p, envir = plotlyEnv) attr(df, "plotly_hash") <- hash # add plotly class mainly for printing method - class(df) <- unique(c("plotly", class(df))) + class(df) <- unique(c("plotly_hash", class(df))) # return a data frame to be compatible with things like dplyr df } diff --git a/man/knit_print.plotly.Rd b/man/knit_print.plotly_hash.Rd similarity index 74% rename from man/knit_print.plotly.Rd rename to man/knit_print.plotly_hash.Rd index 4d500af9c3..733c731c20 100644 --- a/man/knit_print.plotly.Rd +++ b/man/knit_print.plotly_hash.Rd @@ -1,10 +1,10 @@ % Generated by roxygen2: do not edit by hand % Please edit documentation in R/print.R -\name{knit_print.plotly} -\alias{knit_print.plotly} +\name{knit_print.plotly_hash} +\alias{knit_print.plotly_hash} \title{Print a plotly object in a knitr doc} \usage{ -knit_print.plotly(x, options, ...) +knit_print.plotly_hash(x, options, ...) } \arguments{ \item{x}{a plotly object} diff --git a/man/print.plotly.Rd b/man/print.plotly_hash.Rd similarity index 73% rename from man/print.plotly.Rd rename to man/print.plotly_hash.Rd index 8cde8d2188..b595b37c34 100644 --- a/man/print.plotly.Rd +++ b/man/print.plotly_hash.Rd @@ -1,10 +1,10 @@ % Generated by roxygen2: do not edit by hand % Please edit documentation in R/print.R -\name{print.plotly} -\alias{print.plotly} +\name{print.plotly_hash} +\alias{print.plotly_hash} \title{Print a plotly object} \usage{ -\method{print}{plotly}(x, ...) +\method{print}{plotly_hash}(x, ...) } \arguments{ \item{x}{a plotly object}