| @@ -12,3 +12,4 @@ License: MIT + file LICENSE | |||
| Encoding: UTF-8 | |||
| LazyData: true | |||
| Roxygen: list(markdown = TRUE) | |||
| RoxygenNote: 7.0.2 | |||
| @@ -1,2 +1,6 @@ | |||
| # Generated by roxygen2: fake comment so roxygen2 overwrites silently. | |||
| exportPattern("^[^\\.]") | |||
| # Generated by roxygen2: do not edit by hand | |||
| export(frappeChart) | |||
| export(frappeChartOutput) | |||
| export(renderFrappeChart) | |||
| import(htmlwidgets) | |||
| @@ -0,0 +1,46 @@ | |||
| --- | |||
| output: js4shiny::html_document_plain | |||
| --- | |||
| ```{r htmldeps} | |||
| 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 | |||
| ) | |||
| ) | |||
| ``` | |||
| ```{js} | |||
| const data = { | |||
| labels: ["12am-3am", "3am-6pm", "6am-9am", "9am-12am", | |||
| "12pm-3pm", "3pm-6pm", "6pm-9pm", "9am-12am" | |||
| ], | |||
| datasets: [ | |||
| { | |||
| name: "Some Data", type: "bar", | |||
| values: [25, 40, 30, 35, 8, 52, 17, -4] | |||
| }, | |||
| { | |||
| name: "Another Set", type: "line", | |||
| values: [25, 50, -10, 15, 18, 32, 27, 14] | |||
| } | |||
| ] | |||
| } | |||
| const chart = new frappe.Chart("#chart", { // or a DOM element, | |||
| // new Chart() in case of ES6 module with above usage | |||
| title: "My Awesome Chart", | |||
| data: data, | |||
| type: 'axis-mixed', // or 'bar', 'line', 'scatter', 'pie', 'percentage' | |||
| height: 250, | |||
| colors: ['#7cd6fd', '#743ee2'] | |||
| }) | |||
| ``` | |||
| @@ -135,3 +135,47 @@ and then edit `package.json` to add copy tasks | |||
| "build": "npm run copy-js" | |||
| } | |||
| ``` | |||
| ## Create a demo html_document_plain() | |||
| ```{r create-demo-html} | |||
| dir.create("dev/demo") | |||
| js4shiny::js4shiny_rmd(path = "dev/demo/demo.Rmd") | |||
| ``` | |||
| Use the example in the [Frappe Charts Docs](https://frappe.io/charts/docs). | |||
| ```{r} | |||
| 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 | |||
| ) | |||
| ) | |||
| ``` | |||
| And copy the JS into a javascript chunk. | |||
| `r emo::ji("warning")` The dependencies won't be found until you build/install. | |||
| ```{r build-install} | |||
| devtools::document() | |||
| devtools::install() | |||
| ``` | |||
| If you get a path not found error | |||
| ``` | |||
| Error: path for html_dependency not found: inst/htmlwidgets/lib/frappe-charts | |||
| ``` | |||
| it's most likely because | |||
| ``` | |||
| src = "inst/htmlwidgets/lib/frappe-charts" | |||
| ``` | |||
| @@ -0,0 +1,30 @@ | |||
| % Generated by roxygen2: do not edit by hand | |||
| % Please edit documentation in R/frappeChart.R | |||
| \name{frappeChart-shiny} | |||
| \alias{frappeChart-shiny} | |||
| \alias{frappeChartOutput} | |||
| \alias{renderFrappeChart} | |||
| \title{Shiny bindings for frappeChart} | |||
| \usage{ | |||
| frappeChartOutput(outputId, width = "100\%", height = "400px") | |||
| renderFrappeChart(expr, env = parent.frame(), quoted = FALSE) | |||
| } | |||
| \arguments{ | |||
| \item{outputId}{output variable to read from} | |||
| \item{width, height}{Must be a valid CSS unit (like \code{'100\%'}, | |||
| \code{'400px'}, \code{'auto'}) or a number, which will be coerced to a | |||
| string and have \code{'px'} appended.} | |||
| \item{expr}{An expression that generates a frappeChart} | |||
| \item{env}{The environment in which to evaluate \code{expr}.} | |||
| \item{quoted}{Is \code{expr} a quoted expression (with \code{quote()})? This | |||
| is useful if you want to save an expression in a variable.} | |||
| } | |||
| \description{ | |||
| Output and render functions for using frappeChart within Shiny | |||
| applications and interactive Rmd documents. | |||
| } | |||
| @@ -0,0 +1,11 @@ | |||
| % Generated by roxygen2: do not edit by hand | |||
| % Please edit documentation in R/frappeChart.R | |||
| \name{frappeChart} | |||
| \alias{frappeChart} | |||
| \title{<Add Title>} | |||
| \usage{ | |||
| frappeChart(message, width = NULL, height = NULL, elementId = NULL) | |||
| } | |||
| \description{ | |||
| <Add Description> | |||
| } | |||