Skip to content

Commit ecdd0ef

Browse files
committed
have to define knit_print
1 parent a8ea024 commit ecdd0ef

3 files changed

Lines changed: 34 additions & 0 deletions

File tree

NAMESPACE

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ export(gg2list)
99
export(ggplot_build2)
1010
export(ggplotly)
1111
export(group2NA)
12+
export(knit_print.plotly)
1213
export(last_plot)
1314
export(layer2traces)
1415
export(layout)

R/print.R

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,22 @@ print.plotly <- function(x, ...) {
1717
get("print.htmlwidget", envir = asNamespace("htmlwidgets"))(w)
1818
}
1919

20+
#' Print a plotly object in a knitr doc
21+
#'
22+
#' @param x a plotly object
23+
#' @param ... additional arguments (currently ignored)
24+
#' @export
25+
knit_print.plotly <- function(x, ...) {
26+
w <- htmlwidgets::createWidget(
27+
name = "plotly",
28+
x = plotly_build(x),
29+
width = x$width,
30+
height = x$height,
31+
htmlwidgets::sizingPolicy(viewer.padding = 10, browser.fill = TRUE)
32+
)
33+
get("knit_print.htmlwidget", envir = asNamespace("htmlwidgets"))(w)
34+
}
35+
2036

2137
#' Embed a plotly iframe into a IPython Notebook
2238
#' @param x a plotly object

man/knit_print.plotly.Rd

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
% Generated by roxygen2 (4.1.1): do not edit by hand
2+
% Please edit documentation in R/print.R
3+
\name{knit_print.plotly}
4+
\alias{knit_print.plotly}
5+
\title{Print a plotly object in a knitr doc}
6+
\usage{
7+
knit_print.plotly(x, ...)
8+
}
9+
\arguments{
10+
\item{x}{a plotly object}
11+
12+
\item{...}{additional arguments (currently ignored)}
13+
}
14+
\description{
15+
Print a plotly object in a knitr doc
16+
}
17+

0 commit comments

Comments
 (0)