knitr::opts_chunk$set(echo = TRUE)
hexjson
Testlibrary(jsonlite) library(hexjsonwidget) jj=fromJSON('./example.hexjson') hexjsonwidget(jj)
hexjsonwidget(jsonpath='./example-grid.hexjson')
hexjsonwidget(jsonpath='./example-grid.hexjson', grid='on', col_gridfill='#113355', col_hexfill='#FF0000')
jj=hexjsonread('./example-grid.hexjson') hexjsonwidget(jj, grid='off', col_textfill="orange")
hexjsonwidget(jj, grid='off', col_textfill="orange",colour=NA)
hexjsonwidget(jj, col_hexfill='#bb3388')
hexjsonwidget(jj,grid="on", col_hexfill='#bb3388', col_textfill="white")
#List available data files hexjsonbasefiles()
#Use a base datafile hexjsonwidget(jsonbase="example-grid.hexjson", missinglabel='')
#Use a base datafile and diasble labels hexjsonwidget(jsonbase="constituencies.hexjson", label=NA)
df=data.frame(id=c("Q0R0","Q1R2"),colour=c('orange','#ffddbb'), label=c('','test a')) hexjsondatamerge(jj,df)
hexjsonwidget(jsonbase="example-grid.hexjson", data=df,colour='colour')
jdf=data.frame(key=c("Q0R0","Q1R1","Q1R2"), q=c(0,1,1), row=c(0,1,2), colour=c('yellow','#ddbb99','green')) jdf
jjx=hexjsonfromdataframe(jdf, r='row', keyid='key') hexjsonwidget(jjx, colour='colour')
testfn='./testme1.hexjson' hexjsonwrite(jjx, testfn) jjx2=hexjsonread(testfn) hexjsonwidget(jjx2, colour='colour')
hexjsonwidget(fromdataframe=jdf, r='row', keyid='key', colour='colour')
#via https://github.com/timelyportfolio/exportwidget/blob/master/Readme.md library(exportwidget) library(webshot) library(htmltools) library(magrittr) html_print(tagList( hexjsonwidget(jj) , export_widget( ) ), viewer=NULL) %>% webshot( delay = 3 )
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.