Bladeren bron

Create a demo Rmd

master
Garrick Aden-Buie 6 jaren geleden
bovenliggende
commit
036d454f80
7 gewijzigde bestanden met toevoegingen van 412 en 2 verwijderingen
  1. +1
    -0
      DESCRIPTION
  2. +6
    -2
      NAMESPACE
  3. +46
    -0
      dev/demo/demo.Rmd
  4. +274
    -0
      dev/demo/demo.html
  5. +44
    -0
      dev/dev.Rmd
  6. +30
    -0
      man/frappeChart-shiny.Rd
  7. +11
    -0
      man/frappeChart.Rd

+ 1
- 0
DESCRIPTION Bestand weergeven

@@ -12,3 +12,4 @@ License: MIT + file LICENSE
Encoding: UTF-8
LazyData: true
Roxygen: list(markdown = TRUE)
RoxygenNote: 7.0.2

+ 6
- 2
NAMESPACE Bestand weergeven

@@ -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)

+ 46
- 0
dev/demo/demo.Rmd Bestand weergeven

@@ -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']
})
```

+ 274
- 0
dev/demo/demo.html
Diff onderdrukt omdat het te groot bestand
Bestand weergeven


+ 44
- 0
dev/dev.Rmd Bestand weergeven

@@ -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"
```

+ 30
- 0
man/frappeChart-shiny.Rd Bestand weergeven

@@ -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.
}

+ 11
- 0
man/frappeChart.Rd Bestand weergeven

@@ -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>
}

Laden…
Annuleren
Opslaan