Demonstrates adapting a React-based library (react-sparklines) into an htmlwidget
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.vscode
R
inst/htmlwidgets
man
srcjs
.Rbuildignore
.gitignore
DESCRIPTION
NAMESPACE
README.md
app.R
package.json
sparklines.Rproj
webpack.config.js
yarn.lock

README.md

sparklines HTMLWidget

This example demonstrates creating an htmlwidget wrapper around the react-sparklines library.

Building

Because this package includes Javascript source code that requires a compilation step, package installation is in two phases: Javascript tools build the Javascript, and R tools build and install the package. The R package includes the built Javascript files in the inst/ directory.

Javascript Build Requirements

Building Javascript should work on macOS, Linux, and Windows. The following tools are necessary regardless of your platform:

R Build Requirements

You should install the reactR package if you haven't, as this widget depends on it.

Development Workflow

After you've installed Node.js and Yarn, run the following command to resolve and download dependencies:

yarn install

Now, run yarn to build inst/htmlwidgets/sparklineswidget.js:

yarn run webpack --mode=development

To run yarn webpack automatically whenever sources change, use the command yarn run webpack --mode=development --watch

Now that the Javascript is built, you can install the R package:

devtools::document()
devtools::install()

Next, install the colourpicker and shinySignals packages, as they are used in the example app:

install.packages("colourpicker")
devtools::install_github("shinySignals")

Finally you can try the example app by running app.R.