Skip to content

Instantly share code, notes, and snippets.

@timelyportfolio
Last active September 12, 2017 12:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save timelyportfolio/7afb4a361036b1da34c6234c9970ccd2 to your computer and use it in GitHub Desktop.
Save timelyportfolio/7afb4a361036b1da34c6234c9970ccd2 to your computer and use it in GitHub Desktop.
sort sunburst alphabetically
library(sunburstR)
sequence_json <- jsonlite::fromJSON(
system.file("examples/visit-sequences.json",package="sunburstR"),
simplifyDataFrame = FALSE
)
sunburst(
sequence_json,
sortFunction = htmlwidgets::JS(
"
// https://stackoverflow.com/questions/37064650/how-to-get-d3-js-tree-layout-to-sort-nodes-alphabetically
function(a,b) {
return a.data.name.toLowerCase().localeCompare(b.data.name.toLowerCase());
}
"
)
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment