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
Updated NEWs.md
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.
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.
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.
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.
Make sure document your functions with roxygen2 with examples, etc. Optionally, add something to the pkgdown site.