repr icon indicating copy to clipboard operation
repr copied to clipboard

implement custom reprs

Open flying-sheep opened this issue 7 years ago • 0 comments

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

flying-sheep avatar Nov 09 '18 15:11 flying-sheep