---
output: js4shiny::html_document_js
---
```{r htmldeps, echo=FALSE}
library(htmltools)
tagList(
div(id = "chart"),
htmltools::htmlDependency(
name = "frappe-charts",
version = "1.3.0",
package = "frappeCharts",
src = "htmlwidgets/lib/frappe-charts",
script = "frappe-charts.min.iife.js",
all_files = TRUE
)
)
```
```{r data}
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)
)
```
```{js}
let x = document.getElementById('chart-opts')
x = JSON.parse(x.textContent)
const chart = new frappe.Chart("#chart", x)
```