Description Usage Arguments Note References Examples
Function to generate an htmlwidget with a voronoi treemap
1 2 3 4 5 6 |
data |
a correct json data object |
elementId |
optional a custom elementId to be returned |
width |
width of the widget |
height |
height of the widget |
seed |
if defined, the plot is fixed |
title |
NULL or a string for the title |
legend |
TRUE/FALSE if a legend should be printed |
legend_title |
NULL or a string for the title of the legend |
footer |
NULL or a string for the footer text |
label |
TRUE/FALSE if the labels should be printed |
color_circle |
color for the outer circle |
color_border |
color for the inner lines |
color_label |
color for the label in the plot |
size_border |
thickness of the borders in css style, e.g. '1px' |
size_border_hover |
thickness of the borders when hovering in css style, e.g. '3px' |
size_circle |
thickness of the circle in css style, e.g. '2px' |
The JavaScript library d3-voronoi treemap can be found here https://github.com/Kcnarf/d3-voronoi-treemap and the example is based on the remake of HowMuch.net's article 'The Global Economy by GDP' by _Kcnarf https://bl.ocks.org/Kcnarf/fa95aa7b076f537c00aed614c29bb568.
Arlind Nocaj and Ulrik Brandes. (2012). Computing Voronoi Treempas: Faster, Simpler and Resolution-independent. Computer Graphics Forum. Vol.31. 855-864.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | vt_d3(vt_export_json(vt_testdata()))
data(ExampleGDP)
gdp_json <- vt_export_json(vt_input_from_df(ExampleGDP))
vt_d3(gdp_json)
data(canada)
canada$codes <- canada$h3
canada <- canada[canada$h1=="Canada",]
canadaH <- vt_input_from_df(canada,scaleToPerc = FALSE)
vt_d3(vt_export_json(canadaH))
#without label
vt_d3(vt_export_json(canadaH), label=FALSE)
#Example with coloring from scales package
library(scales)
canada$color <- seq_gradient_pal()(exp(canada$weight)/500)
canadaH <- vt_input_from_df(canada,scaleToPerc = FALSE)
vt_d3(vt_export_json(canadaH))
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.