Search code examples
htmlr-highcharterjupyter-lab

run highcharter in jupyterlab / jupyternotebooks


I'm trying to render some highcharter charts in jupyterlab

data(diamonds, economics_long, mpg, package = "ggplot2")
library(dplyr)
library(highcharter)
hchart(mpg, "scatter", hcaes(x = displ, y = hwy, group = class))

to get plotlywrapper working you need to install an extension. I can imagine something similar has to be built for highcharter?

error message:

HTML widgets cannot be represented in plain text (need html)

Solution

  • https://blog.ouseful.info/2018/04/26/r-htmlwidgets-in-jupyter-notebooks/

    data(diamonds, economics_long, mpg, package = "ggplot2")
    library(dplyr)
    library(highcharter)
    x=hchart(mpg, "scatter", hcaes(x = displ, y = hwy, group = class)) %>%
    hc_size(width=800, height = 400)
    saveWidget(x, 'demox.html', selfcontained = FALSE)
    display_html('<iframe src="demox.html", width = 900, height = 500 ></iframe>')