/hierarchical_bubble_r_html_widget

An HTML widget for R that displays hierarchical data in a nested bubble chart

Primary LanguageJavaScriptOtherNOASSERTION

Hierarchical bubble

A zoomable, pannable hierarchical bubble chart HTML Widget for R implemented in d3v4.

This is work in progress, but you can find a working example of a Shiny app within the repo.

Instructions

The widget expects data in the following format (showing first few rows only):

id parent text value
1 NA Total 8804.544
2 1 category a 8804.544
3 2 category d 8804.544
4 3 category g 5921.133
5 4 category k 5921.133
6 3 category i 2883.411
7 6 category l 2883.411

However, you're more likely to have data that looks like this (first few rows only):

cat_1 cat_2 cat_3 cat_4 val
category c category e category g category k 6760.6001
category b category e category g category j 4690.3694
category a category f category i category j 445.0382

So a convenience function is provided that converts between the two:

df <- hierarchicalbubble::generate_test_data()[1:5,]
names <- paste0("cat_", 1:4)

df_l <- hierarchicalbubble::wide_to_long_hierarchy(df,names, "val")

To see your visualisation use

hierarchicalbubble::hierarchical_bubble(df_l)

Here's a screenshot of the widget embedded in a Shiny app: Screenshot