Thank you for considering to contribute to g2r!


Please go through this checklist before submitting a PR.

Ran make build

Added tests

Updated documentation (roxygen2)

Added, or changed the vignettes


Ran make site


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


Using make is probably the easiest way.


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.


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.


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


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


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.


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.


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 file with the changes you have made.


Add tests for the functionalities you propose.