HexJSON HTMLWidget for R, Part 2
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.
In my previous post – HexJSON HTMLWidget for R, Part 1 – I described a first attempt at an HTMLwidget for displaying hexJSON maps using d3-hexJSON
.
I had another play today and added a few extra features, including the ability to:
- add a grid (as demonstrated in the original
d3-hexJSON
examples), - modify the default colour of data and grid hexes,
- set the data hex colour via a
col
attribute defined on a hexJSON hex, and - set the data hex label via a
label
attribute defined on a hexJSON hex.
We can now also pass in the path to a hexJSON file, rather than just the hexJSON object:
Here’s the example hexJSON file:
And here’s an example of the default grid colour and a custom text colour :
I’ve also tried to separate out the code changes as separate commits for each feature update: code checkins. For example, here’s where I added the original colour handling.
I’ve also had a go at putting some docs in place, generated using roxygen2
called from inside the widget code folder with devtools::document()
. (The widget itself gets rebuilt by running the command devtools::install()
.)
Next up – some routines to annotate a base hexJSON file with data to colour and label the hexes. (I’m also wondering if I should support the ability to specify arbitrary hexJSON hex attribute names for label text (label
) and hex colour (col
), or whether to keep those names as a fixed requirement?)
R-bloggers.com offers daily e-mail updates about R news and tutorials about learning R and many other topics. Click here if you're looking to post or find an R/data-science job.
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.