Thank you for considering to contribute to g2r!

Checklist

Please go through this checklist before submitting a PR.

Ran make build

Added tests

Updated documentation (roxygen2)

Added, or changed the vignettes

Updated NEWs.md

Ran make site

Setup

g2r is an htmlwidgets build with packer so it can make use of the @antv/g2 NPM package and webpack to modularise the code.

Make

Using make is probably the easiest way.

Manual

First, make sure you have packer installed: install.packages("packer").

Then, clone the project.

As mentioned, packer is used to manage webpack and NPM with R: run the function below install the dependencies.

packer::npm_install()

All the JavaScript code is placed in the srcjs directory. The core htmlwidget file is placed in the srcjs/widget directory, it makes use of various modules in the srcjs/modules directory.

Development

Make changes or additions to those file then bundle them with packer.

packer::bundle_dev()

The above bundles the JavaScript with inline sourcemap for debugging. This, however, creates a large .js file which breaks R CMD Check, etc. Only use it as you develop and do not submit PR with the sourcemap, do not build pkgdown site with this large JavaScript file either.

Make sure you bundle for prod which performs all required optimisations (tree-shaking, minification, etc.).

packer::bundle_prod()

It is advised to make use of the makefile to ensure one does not miss any of the required steps.

Figures & Alter

G2.js figures are all handled in the primitives.R file; if adding a figure please place it in with other such custom figures in figures.R.

Do not change “primitives” (unless fixing a bug). There should remain a simple, straightforward 1:1 mapping to the G2.js geoms.

Many figures internally use the alter package which interfaces the @antv/data-set package.

Tests

Any additions, fixes, etc. must be accompanied by tests.

Man & Docs

Make sure document your functions with roxygen2 with examples, etc. Optionally, add something to the pkgdown site.

Dependencies

Do not introduce new dependencies unless absolutely necessary. If needed them to Suggests and use the internal check_package to check whether said package is installed.

## News

Update the NEWS.md file with the changes you have made.

Tests

Add tests for the functionalities you propose.