Skip to content

Hierarchical data representation for sunburst/treemaps/radial tree #207

Description

@barveaditya

Hello,

I have been trying to plot my data using sunburst in a Shiny app, however the example (below) has a manually specified structure, which is not possible for me to code as part of a shiny visualisation. I have to do it programmatically, but even using tidyr::nest does not help as it does not allow the same name to multiple hierarchies. Is there another data format that I could use.

The example is below:

df <- tibble(
  name = c("earth", "mars", "venus"), value = c(30, 40, 30),        # 1st level
  itemStyle = tibble(color = c(NA, 'red', 'blue')),     # embedded styles, optional
  children = list(
    tibble(name = c("land", "ocean"), value = c(10,20),             # 2nd level
           children = list(
             tibble(name = c("forest", "river"), value = c(3,7)),   # 3rd level 
             tibble(name = c("fish", "kelp"), value = c(10,5),
                    children = list(
                      tibble(name = c("shark", "tuna"), value = c(2,6)),  # 4th level 
                      NULL  # kelp
                    ))
           )),
    tibble(name = c("crater", "valley"), value = c(20,20)),
    NULL  # venus
  )
)

for example, how would one convert the following data frame in a data structure accepted by e_sunburst programmatically?

df = data.frame(labels = c("Eve", "Cain", "Seth", "Enos", "Noam", "Abel", "Awan", "Enoch", "Azura"),
                parents = c("", "Eve", "Eve", "Seth", "Seth", "Eve", "Eve", "Awan", "Eve"),
                values = c(10, 14, 12, 10, 2, 6, 6, 4, 4))

This issue is as important as e_sunburst as one cannot use these great visualisations otherwise!

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions