data <- list(
  labels = c("Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"),
  datasets = list(
    list(name = "Python", values = runif(8, 0, 50)),
    list(name = "R", values = runif(8, 0, 100))
  )
)

opts <- list(
  title = "My AwesomeR Chart",
  type = "line",
  height = 250,
  colors = c("#466683", "#44bc96"),
  data = data
)

tags$script(
  id = "chart-opts",
  type = "application/json",
  htmlwidgets:::toJSON(opts)
)
let x = document.getElementById('chart-opts')
x = JSON.parse(x.textContent)

const chart = new frappe.Chart("#chart", x)