-
-
Notifications
You must be signed in to change notification settings - Fork 81
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Hierarchical data representation for sunburst/treemaps/radial tree #207
Comments
I know, it's an absolute pain. In a previous version it accepted a Ideally we'd have a recursive function go over the |
Hi John, Thank you for the reply. 👍 I have posted the question on stackoverflow [https://stackoverflow.com/questions/64240732/is-there-a-programmatic-way-to-create-in-r-create-a-nested-list-of-tibbles |
@barveaditya - try this with library data.tree library(echarts4r)
df <- data.frame(parents = c("","earth", "earth", "mars", "mars", "land", "land", "ocean", "ocean", "fish", "fish", "Everything", "Everything", "Everything"),
labels = c("Everything", "land", "ocean", "valley", "crater", "forest", "river", "kelp", "fish", "shark", "tuna", "venus","earth", "mars"),
value = c(0, 30, 40, 10, 10, 20, 10, 20, 20, 8, 12, 10, 70, 20))
library(data.tree)
universe <- FromDataFrameNetwork(df)
jsonl <- ToListExplicit(universe, unname=TRUE)
jsonl$children[[1]]$children %>% e_charts() %>% e_sunburst() |
Thanks @helgasoft, I'll see if I can bring support for this in the package (passing {data.tree} |
oh this is brilliant @helgasoft Fantastic. I am very happy! :) @JohnCoene - thanks in advance for bringing in support. |
I just pushed a change to the df <- data.frame(parents = c("","earth", "earth", "mars", "mars", "land", "land", "ocean", "ocean", "fish", "fish", "Everything", "Everything", "Everything"),
labels = c("Everything", "land", "ocean", "valley", "crater", "forest", "river", "kelp", "fish", "shark", "tuna", "venus","earth", "mars"),
value = c(0, 30, 40, 10, 10, 20, 10, 20, 20, 8, 12, 10, 70, 20))
# create a tree object
universe <- data.tree::FromDataFrameNetwork(df)
# use it in echarts4r
universe %>%
e_charts() %>%
e_sunburst() |
Brilliant. I tested it too. All good. Thank you for making this simpler @JohnCoene @helgasoft |
@JohnCoene while you fixed the above for e_sunburst, the same doesn't work for e_tree universe %>% e_charts() %>% e_tree() just shows me venus. Any ideas? |
Yes, e_tree is a little different library(echarts4r)
library(data.tree)
df <- data.frame(parents = c("","earth", "earth", "mars", "mars", "land", "land", "ocean", "ocean", "fish", "fish", "Everything", "Everything", "Everything"),
labels = c("Everything", "land", "ocean", "valley", "crater", "forest", "river", "kelp", "fish", "shark", "tuna", "venus","earth", "mars"),
value = c(0, 30, 40, 10, 10, 20, 10, 20, 20, 8, 12, 10, 70, 20))
universe <- FromDataFrameNetwork(df)
jsonl <- ToListExplicit(universe, unname=TRUE)
jsonl$children %>% e_charts() %>% e_tree() |
Did you check the help '?e_tree' e_tree(label = list(offset = c(0, -11))) # works |
@helgasoft Yes, unfortunately right after I put it in here. :) which is why I deleted it, but I guess you already got an email! :) Thank you for getting back nonetheless. I am trying to look at echarts doc to enable some very cool looking features. :) |
jsonl$children %>% e_charts() %>% e_tree(
label = list(offset = c(0, -12)),
symbolSize = htmlwidgets::JS("function(d) { return d; }")) |
I'm trying to apply the solutions proposed here but I still have problems : With this, I get no graph (because : no "value" in acme data ??):
With this I get only a partial graph of the first subnode :
NB : I first posted a question on stackoverflow (edited since then) before finding the current page : |
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:
for example, how would one convert the following data frame in a data structure accepted by e_sunburst programmatically?
This issue is as important as e_sunburst as one cannot use these great visualisations otherwise!
The text was updated successfully, but these errors were encountered: