hexjsonwidget: An htmlwidget for rendering hexjson maps using d3-hexjson

Description Usage Arguments Details Value Author(s) Examples

Description

hexjsonwidget() accepts a hexJSON object or path to a hexjson file and render it as an HTMLwidget using d3-hexjson.

Usage

1
2
3
4
5
6
hexjsonwidget(jsondata = NA, jsonpath = NA, jsonbase = NA,
  fromdataframe = NA, data = NA, keyid = "id", colour = "col",
  label = "label", layout = "odd-r", r = "r", q = "q", grid = "off",
  labels = "on", missinglabel = NA, col_gridfill = "#f0f0f0",
  col_hexfill = "#b0e8f0", col_textfill = "#000000", width = NULL,
  height = NULL, elementId = NULL)

Arguments

jsondata

hexJSON object

jsonpath

Path to hexJSON file

jsonbase

Name of bundled hexJSON file

fromdataframe

Dataframe to be used to create a hexJSON file

data

Dataframe containing data to merge with hexjson file

keyid

Name of data column for ID info

colour

Name of the hex attribute used to set the hex colour; set to NA to use the default.

label

Name of the hex attribute used to set the hex label; set to NA to turn labels off.

r

Dataframe column name used to defined a row (hex::r) when using fromdataframe

q

Dataframe column name used to defined a column (hex::q) when using fromdataframe

grid

Display a background grid in whitespace (either on or off (default)).

missinglabel

Value to use for missing label; if set to NA (default), use hex id. If label is set to a non-existing hex atribute, and missinglabel is set to NA, the hex key will be displayed as the label in each hex.

col_gridfill

Default fill colour for grid hex

col_hexfill

Default fill colour for data hex if "col" hex value not set

col_textfill

Default fill colour for hex text label

width

Widget width

height

Widget height

elementId

Widget element ID

Details

If a hexJSON hexobject includes a col attribute, this will be used to colour the hex. If it contains a label attribute, it will be used to label the hex.

Value

an HTMLwidget object

Author(s)

Tony Hirst (@psychemedia)

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
hexjsonwidget( fromJSON('./example.hexjson') )
hexjsonwidget(jsonpath='./example-grid.hexjson')
hexjsonwidget(jj, grid='on', col_gridfill='#113355', col_hexfill='#FF0000')
hexjsonwidget(jj, grid='off', col_textfill="orange")
hexjsonwidget(jj, col_hexfill='#bb3388')
hexjsonwidget(jj, grid='off', col_textfill="orange",colour=NA)

df=data.frame(id=c("Q0R0","Q1R2"),colour=c('orange','#ffddbb'),label=c('','test a'))
hexjsonwidget(jsonbase="example-grid.hexjson",data=df,colour='colour')

jdf=data.frame(id=c("Q0R0","Q1R1","Q1R2"),q=c(0,1,1),
row=c(0,1,2), colour=c('yellow','#ddbb99','green'))
jjx=hexjsonfromdataframe(jdf,r='row', keyid='id')
hexjsonwidget(jjx, colour='colour')

hexjsonwidget(fromdataframe=jdf, r='row', keyid='key',colour='colour')

psychemedia/htmlwidget-hexjson documentation built on May 3, 2019, 5:49 p.m.