https://twitter.com/emhrt_/status/905941755878563840 asks how to sort sunburstR htmlwidget alphabetically. This is an attempt at providing an answer.
Last active
September 12, 2017 12:14
-
-
Save timelyportfolio/7afb4a361036b1da34c6234c9970ccd2 to your computer and use it in GitHub Desktop.
sort sunburst alphabetically
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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