repr
repr copied to clipboard
implement custom reprs
one example would be plotly. the following is vastly faster than rendering an htmlwidget
ggplotly <- function(p = ggplot2::last_plot(), width = NULL, height = NULL, tooltip = "all", dynamicTicks = FALSE, layerData = 1, originalData = TRUE, source = "A", ...) {
ggp <- plotly::ggplotly(p, width, height, tooltip, dynamicTicks, layerData, originalData, source, ...)
tree <- jsonlite::fromJSON(plotly::plotly_json(ggp)) # plotly_json does the right unboxing and so on
IRdisplay::publish_mimebundle(list('application/vnd.plotly.v1+json' = tree))
}
see also IRkernel/IRkernel#587