Comments (7)
ok, @kippjohnson I think I remember this, but maybe I learned something new. It looks like the expected order is deepest first, so this works for me. If you specify -end
for each complete path, then I think you can avoid this step, but for me just changing the order seems easier.
library(sunburstR)
# read the csv data downloaded from the Google Fusion Table linked in the article
data_ex <- read.csv(
"./inst/examples/example2.csv",
header = FALSE,
stringsAsFactors = FALSE
)
# fails
sunburst(data_ex)
library(dplyr)
data_ex$depth <- unlist(lapply(strsplit(data_ex$V1,"-"),length))
data_ex %>%
arrange(desc(depth), V1) %>%
sunburst()
from sunburstr.
@kippjohnson looking now; it fails in JavaScript at row 14. Have not looked at these hierarchies in a while so just need to refamiliarize myself.
from sunburstr.
Thanks a lot for looking at this @timelyportfolio
Reordering the dataset as you suggest gets me 90% of the way there, but there is still a small problem (see the two attached example photos):
As you can see, there are now two distinct 1st level tracks for each of the drugs (Glipizide here). The first level % should be the sum of each of these two percentages. Terminating each string with "End" as you suggest works but isn't quite the plot that I was attempting to make because it's sort of noisy to look at statically. Is there an easy fix for this? I have considered just labeling the "END" color as white.
Anyway, I appreciate you taking the time to work on this.
from sunburstr.
I think the answer is no, but can you just add the -end
to the 1st level tracks that end at the first level?
data_ex %>%
mutate(V1 = ifelse(depth==1,paste0(V1,"-end"),V1)) %>%
arrange(desc(depth), V1) %>%
sunburst()
Maybe, this is what you have already done.
from sunburstr.
Yeah, that works.
from sunburstr.
@kippjohnson I think I understand better now. Here is a hacky way to accomplish an invisible end without having to specify an entire color map.
data_ex %>%
mutate(V1 = ifelse(depth==1,paste0(V1,"-end"),V1)) %>%
arrange(desc(depth), V1) %>%
sunburst() %>%
htmlwidgets::onRender(
htmlwidgets::JS(
"
function(el,x){
var endpaths = d3.select(el)
.selectAll('path')[0]
.filter(function(d){
return d3.select(d).datum().name === 'end'
});
d3.selectAll(endpaths).style('fill','none');
}
"
)
)
I should probably make this a function.
from sunburstr.
This is perfect! Thanks a lot
from sunburstr.
Related Issues (20)
- sund2b rootLabel malfunction when tooltip option used HOT 2
- no output HOT 4
- sunburst d2b & d3tree treemap fail to render together in shiny HOT 3
- Export sunburst plot as static vector image
- Have the legend open by default HOT 1
- Sizing problems of sund2b output in shiny window or browser with fluidPage HOT 2
- Radial color gradients within arcs HOT 3
- csv_to_hier not working as expected when only one element is spitted out by str_split HOT 18
- Sunburst function examples all fail "Error: Argument 1 must have names" HOT 6
- legend font HOT 1
- crosstalk support HOT 5
- sund2b - display root label on top, centered, and horizontal?
- Solution for manually coloring each leaf? HOT 7
- sunburst example is not working HOT 3
- rootLabel in sund2b is not working HOT 1
- warning when using sunburstOutput with shiny 1.7.4 (latest CRAN) HOT 3
- sunburst plot is rounding when it shouldn't v2.1.8 HOT 3
- custom sund2bBreadcrumb outputs text in all upper case HOT 1
- Modify sund2b breadcrumb size HOT 2
- Error when exporting HTML-plot
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from sunburstr.