Forked from a Mike Bostock example. Click on the bars to drill down into the categories.
-
-
Save chuckpr/0b537efc6b74be88ccc3 to your computer and use it in GitHub Desktop.
responder hierarchical bar chart
This file contains hidden or 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
{ | |
"name": "test", | |
"children": [ | |
{ | |
"name": "13CCPS", | |
"children": [ | |
{ | |
"name": "Actinobacteria", | |
"children": [ | |
{ | |
"name": "Pseudonocardiales", | |
"children": [ | |
{ | |
"name": "Pseudonocardiaceae", | |
"children": [ | |
{ | |
"name": "Lentzea", | |
"children": [ | |
{ | |
"name": "unassigned", | |
"children": [ | |
{ | |
"name": "OTU.257", | |
"size": 1 | |
} | |
] | |
} | |
] | |
}, | |
{ | |
"name": "unassigned", | |
"children": [ | |
{ | |
"name": "unassigned", | |
"children": [ | |
{ | |
"name": "OTU.862", | |
"size": 1 | |
} | |
] | |
} | |
] | |
} | |
] | |
} | |
] | |
}, | |
{ | |
"name": "Streptomycetales", | |
"children": [ | |
{ | |
"name": "Streptomycetaceae", | |
"children": [ | |
{ | |
"name": "Streptomyces", | |
"children": [ | |
{ | |
"name": "unassigned", | |
"children": [ | |
{ | |
"name": "OTU.132", | |
"size": 1 | |
} | |
] | |
} | |
] | |
} | |
] | |
} | |
] | |
} | |
] | |
}, | |
{ | |
"name": "Bacteroidetes", | |
"children": [ | |
{ | |
"name": "Cytophagia", | |
"children": [ | |
{ | |
"name": "Cytophagales", | |
"children": [ | |
{ | |
"name": "Cytophagaceae", | |
"children": [ | |
{ | |
"name": "Adhaeribacter", | |
"children": [ | |
{ | |
"name": "OTU.573", | |
"size": 1 | |
} | |
] | |
}, | |
{ | |
"name": "Flexibacter", | |
"children": [ | |
{ | |
"name": "OTU.465", | |
"size": 1 | |
}, | |
{ | |
"name": "OTU.669", | |
"size": 1 | |
} | |
] | |
}, | |
{ | |
"name": "Sporocytophaga", | |
"children": [ | |
{ | |
"name": "OTU.1094", | |
"size": 1 | |
}, | |
{ | |
"name": "OTU.670", | |
"size": 1 | |
} | |
] | |
} | |
] | |
} | |
] | |
} | |
] | |
} | |
] | |
}, | |
{ | |
"name": "Chloroflexi", | |
"children": [ | |
{ | |
"name": "Anaerolineae", | |
"children": [ | |
{ | |
"name": "Anaerolineales", | |
"children": [ | |
{ | |
"name": "Anaerolineaceae", | |
"children": [ | |
{ | |
"name": "uncultured", | |
"children": [ | |
{ | |
"name": "OTU.971", | |
"size": 1 | |
} | |
] | |
} | |
] | |
} | |
] | |
} | |
] | |
}, | |
{ | |
"name": "Herpetosiphonales", | |
"children": [ | |
{ | |
"name": "Herpetosiphonaceae", | |
"children": [ | |
{ | |
"name": "Herpetosiphon", | |
"children": [ | |
{ | |
"name": "uncultured_Chloroflexi_bacterium", | |
"children": [ | |
{ | |
"name": "OTU.4322", | |
"size": 1 | |
}, | |
{ | |
"name": "OTU.5190", | |
"size": 1 | |
}, | |
{ | |
"name": "OTU.64", | |
"size": 1 | |
}, | |
{ | |
"name": "OTU.98", | |
"size": 1 | |
} | |
] | |
} | |
] | |
} | |
] | |
} | |
] | |
} | |
] | |
}, | |
{ | |
"name": "Cyanobacteria", | |
"children": [ | |
{ | |
"name": "SM1D11", | |
"children": [ | |
{ | |
"name": "uncultured_bacterium", | |
"children": [ | |
{ | |
"name": "unassigned", | |
"children": [ | |
{ | |
"name": "unassigned", | |
"children": [ | |
{ | |
"name": "OTU.120", | |
"size": 1 | |
} | |
] | |
} | |
] | |
} | |
] | |
} | |
] | |
} | |
] | |
}, | |
{ | |
"name": "Planctomycetes", | |
"children": [ | |
{ | |
"name": "Planctomycetacia", | |
"children": [ | |
{ | |
"name": "Planctomycetales", | |
"children": [ | |
{ | |
"name": "Planctomycetaceae", | |
"children": [ | |
{ | |
"name": "Pir4_lineage", | |
"children": [ | |
{ | |
"name": "OTU.285", | |
"size": 1 | |
} | |
] | |
}, | |
{ | |
"name": "Pirellula", | |
"children": [ | |
{ | |
"name": "OTU.351", | |
"size": 1 | |
}, | |
{ | |
"name": "OTU.473", | |
"size": 1 | |
}, | |
{ | |
"name": "OTU.663", | |
"size": 1 | |
} | |
] | |
}, | |
{ | |
"name": "Planctomyces", | |
"children": [ | |
{ | |
"name": "OTU.1204", | |
"size": 1 | |
}, | |
{ | |
"name": "OTU.150", | |
"size": 1 | |
}, | |
{ | |
"name": "OTU.204", | |
"size": 1 | |
}, | |
{ | |
"name": "OTU.600", | |
"size": 1 | |
} | |
] | |
}, | |
{ | |
"name": "Rhodopirellula", | |
"children": [ | |
{ | |
"name": "OTU.1065", | |
"size": 1 | |
}, | |
{ | |
"name": "OTU.484", | |
"size": 1 | |
} | |
] | |
} | |
] | |
} | |
] | |
} | |
] | |
} | |
] | |
}, | |
{ | |
"name": "Proteobacteria", | |
"children": [ | |
{ | |
"name": "Alphaproteobacteria", | |
"children": [ | |
{ | |
"name": "Caulobacterales", | |
"children": [ | |
{ | |
"name": "Caulobacteraceae", | |
"children": [ | |
{ | |
"name": "Asticcacaulis", | |
"children": [ | |
{ | |
"name": "OTU.1754", | |
"size": 1 | |
}, | |
{ | |
"name": "OTU.327", | |
"size": 1 | |
} | |
] | |
}, | |
{ | |
"name": "Brevundimonas", | |
"children": [ | |
{ | |
"name": "OTU.119", | |
"size": 1 | |
}, | |
{ | |
"name": "OTU.900", | |
"size": 1 | |
} | |
] | |
} | |
] | |
} | |
] | |
}, | |
{ | |
"name": "Rhizobiales", | |
"children": [ | |
{ | |
"name": "Hyphomicrobiaceae", | |
"children": [ | |
{ | |
"name": "Devosia", | |
"children": [ | |
{ | |
"name": "OTU.1087", | |
"size": 1 | |
}, | |
{ | |
"name": "OTU.3775", | |
"size": 1 | |
}, | |
{ | |
"name": "OTU.429", | |
"size": 1 | |
}, | |
{ | |
"name": "OTU.5539", | |
"size": 1 | |
}, | |
{ | |
"name": "OTU.766", | |
"size": 1 | |
}, | |
{ | |
"name": "OTU.982", | |
"size": 1 | |
} | |
] | |
} | |
] | |
}, | |
{ | |
"name": "Rhizobiaceae", | |
"children": [ | |
{ | |
"name": "Rhizobium", | |
"children": [ | |
{ | |
"name": "OTU.165", | |
"size": 1 | |
}, | |
{ | |
"name": "OTU.28", | |
"size": 1 | |
} | |
] | |
}, | |
{ | |
"name": "unassigned", | |
"children": [ | |
{ | |
"name": "OTU.19", | |
"size": 1 | |
} | |
] | |
} | |
] | |
} | |
] | |
}, | |
{ | |
"name": "Sphingomonadales", | |
"children": [ | |
{ | |
"name": "Sphingomonadaceae", | |
"children": [ | |
{ | |
"name": "Sphingopyxis", | |
"children": [ | |
{ | |
"name": "OTU.90", | |
"size": 1 | |
} | |
] | |
} | |
] | |
} | |
] | |
} | |
] | |
}, | |
{ | |
"name": "Betaproteobacteria", | |
"children": [ | |
{ | |
"name": "Burkholderiales", | |
"children": [ | |
{ | |
"name": "Comamonadaceae", | |
"children": [ | |
{ | |
"name": "Hydrogenophaga", | |
"children": [ | |
{ | |
"name": "OTU.518", | |
"size": 1 | |
} | |
] | |
}, | |
{ | |
"name": "unassigned", | |
"children": [ | |
{ | |
"name": "OTU.5", | |
"size": 1 | |
} | |
] | |
} | |
] | |
}, | |
{ | |
"name": "Oxalobacteraceae", | |
"children": [ | |
{ | |
"name": "unassigned", | |
"children": [ | |
{ | |
"name": "OTU.114", | |
"size": 1 | |
}, | |
{ | |
"name": "OTU.1312", | |
"size": 1 | |
} | |
] | |
} | |
] | |
} | |
] | |
} | |
] | |
}, | |
{ | |
"name": "Deltaproteobacteria", | |
"children": [ | |
{ | |
"name": "Myxococcales", | |
"children": [ | |
{ | |
"name": "Nannocystineae", | |
"children": [ | |
{ | |
"name": "Nannocystaceae", | |
"children": [ | |
{ | |
"name": "OTU.899", | |
"size": 1 | |
} | |
] | |
} | |
] | |
}, | |
{ | |
"name": "Sorangiineae", | |
"children": [ | |
{ | |
"name": "Polyangiaceae", | |
"children": [ | |
{ | |
"name": "OTU.228", | |
"size": 1 | |
} | |
] | |
}, | |
{ | |
"name": "Sandaracinaceae", | |
"children": [ | |
{ | |
"name": "OTU.32", | |
"size": 1 | |
}, | |
{ | |
"name": "OTU.633", | |
"size": 1 | |
} | |
] | |
}, | |
{ | |
"name": "uncultured", | |
"children": [ | |
{ | |
"name": "OTU.3594", | |
"size": 1 | |
}, | |
{ | |
"name": "OTU.442", | |
"size": 1 | |
} | |
] | |
} | |
] | |
} | |
] | |
} | |
] | |
}, | |
{ | |
"name": "Gammaproteobacteria", | |
"children": [ | |
{ | |
"name": "Pseudomonadales", | |
"children": [ | |
{ | |
"name": "Pseudomonadaceae", | |
"children": [ | |
{ | |
"name": "Cellvibrio", | |
"children": [ | |
{ | |
"name": "OTU.6", | |
"size": 1 | |
} | |
] | |
} | |
] | |
} | |
] | |
}, | |
{ | |
"name": "Xanthomonadales", | |
"children": [ | |
{ | |
"name": "Xanthomonadaceae", | |
"children": [ | |
{ | |
"name": "Dokdonella", | |
"children": [ | |
{ | |
"name": "OTU.6062", | |
"size": 1 | |
} | |
] | |
}, | |
{ | |
"name": "Pseudoxanthomonas", | |
"children": [ | |
{ | |
"name": "OTU.100", | |
"size": 1 | |
}, | |
{ | |
"name": "OTU.154", | |
"size": 1 | |
} | |
] | |
}, | |
{ | |
"name": "Stenotrophomonas", | |
"children": [ | |
{ | |
"name": "OTU.11", | |
"size": 1 | |
} | |
] | |
} | |
] | |
} | |
] | |
} | |
] | |
} | |
] | |
}, | |
{ | |
"name": "Verrucomicrobia", | |
"children": [ | |
{ | |
"name": "Spartobacteria", | |
"children": [ | |
{ | |
"name": "Chthoniobacterales", | |
"children": [ | |
{ | |
"name": "01D2Z36", | |
"children": [ | |
{ | |
"name": "unassigned", | |
"children": [ | |
{ | |
"name": "OTU.1533", | |
"size": 1 | |
} | |
] | |
} | |
] | |
}, | |
{ | |
"name": "Chthoniobacteraceae", | |
"children": [ | |
{ | |
"name": "Chthoniobacter", | |
"children": [ | |
{ | |
"name": "OTU.241", | |
"size": 1 | |
} | |
] | |
} | |
] | |
}, | |
{ | |
"name": "FukuN18_freshwater_group", | |
"children": [ | |
{ | |
"name": "unassigned", | |
"children": [ | |
{ | |
"name": "OTU.185", | |
"size": 1 | |
} | |
] | |
}, | |
{ | |
"name": "uncultured_bacterium", | |
"children": [ | |
{ | |
"name": "OTU.1023", | |
"size": 1 | |
}, | |
{ | |
"name": "OTU.2192", | |
"size": 1 | |
}, | |
{ | |
"name": "OTU.266", | |
"size": 1 | |
} | |
] | |
} | |
] | |
}, | |
{ | |
"name": "LD29", | |
"children": [ | |
{ | |
"name": "unassigned", | |
"children": [ | |
{ | |
"name": "OTU.541", | |
"size": 1 | |
} | |
] | |
} | |
] | |
} | |
] | |
} | |
] | |
}, | |
{ | |
"name": "Verrucomicrobiae", | |
"children": [ | |
{ | |
"name": "Verrucomicrobiales", | |
"children": [ | |
{ | |
"name": "Verrucomicrobiaceae", | |
"children": [ | |
{ | |
"name": "Haloferula", | |
"children": [ | |
{ | |
"name": "OTU.638", | |
"size": 1 | |
} | |
] | |
}, | |
{ | |
"name": "Prosthecobacter", | |
"children": [ | |
{ | |
"name": "OTU.627", | |
"size": 1 | |
} | |
] | |
}, | |
{ | |
"name": "uncultured", | |
"children": [ | |
{ | |
"name": "OTU.83", | |
"size": 1 | |
} | |
] | |
} | |
] | |
} | |
] | |
} | |
] | |
} | |
] | |
} | |
] | |
}, | |
{ | |
"name": "13CXPS", | |
"children": [ | |
{ | |
"name": "Actinobacteria", | |
"children": [ | |
{ | |
"name": "Frankiales", | |
"children": [ | |
{ | |
"name": "Nakamurellaceae", | |
"children": [ | |
{ | |
"name": "Humicoccus", | |
"children": [ | |
{ | |
"name": "unassigned", | |
"children": [ | |
{ | |
"name": "OTU.62", | |
"size": 1 | |
} | |
] | |
} | |
] | |
}, | |
{ | |
"name": "Nakamurella", | |
"children": [ | |
{ | |
"name": "unassigned", | |
"children": [ | |
{ | |
"name": "OTU.4446", | |
"size": 1 | |
} | |
] | |
} | |
] | |
} | |
] | |
} | |
] | |
}, | |
{ | |
"name": "Micrococcales", | |
"children": [ | |
{ | |
"name": "Cellulomonadaceae", | |
"children": [ | |
{ | |
"name": "Cellulomonas", | |
"children": [ | |
{ | |
"name": "unassigned", | |
"children": [ | |
{ | |
"name": "OTU.24", | |
"size": 1 | |
} | |
] | |
} | |
] | |
} | |
] | |
}, | |
{ | |
"name": "Microbacteriaceae", | |
"children": [ | |
{ | |
"name": "Agromyces", | |
"children": [ | |
{ | |
"name": "unassigned", | |
"children": [ | |
{ | |
"name": "OTU.4", | |
"size": 1 | |
} | |
] | |
} | |
] | |
}, | |
{ | |
"name": "unassigned", | |
"children": [ | |
{ | |
"name": "unassigned", | |
"children": [ | |
{ | |
"name": "OTU.37", | |
"size": 1 | |
} | |
] | |
} | |
] | |
} | |
] | |
}, | |
{ | |
"name": "Promicromonosporaceae", | |
"children": [ | |
{ | |
"name": "Cellulosimicrobium_", | |
"children": [ | |
{ | |
"name": "unassigned", | |
"children": [ | |
{ | |
"name": "OTU.244", | |
"size": 1 | |
} | |
] | |
} | |
] | |
}, | |
{ | |
"name": "Isoptericola", | |
"children": [ | |
{ | |
"name": "unassigned", | |
"children": [ | |
{ | |
"name": "OTU.5284", | |
"size": 1 | |
} | |
] | |
} | |
] | |
}, | |
{ | |
"name": "Promicromonospora", | |
"children": [ | |
{ | |
"name": "unassigned", | |
"children": [ | |
{ | |
"name": "OTU.252", | |
"size": 1 | |
} | |
] | |
} | |
] | |
} | |
] | |
} | |
] | |
} | |
] | |
}, | |
{ | |
"name": "Bacteroidetes", | |
"children": [ | |
{ | |
"name": "Cytophagia", | |
"children": [ | |
{ | |
"name": "Cytophagales", | |
"children": [ | |
{ | |
"name": "Cytophagaceae", | |
"children": [ | |
{ | |
"name": "Dyadobacter", | |
"children": [ | |
{ | |
"name": "OTU.760", | |
"size": 1 | |
} | |
] | |
} | |
] | |
} | |
] | |
} | |
] | |
}, | |
{ | |
"name": "Flavobacteria", | |
"children": [ | |
{ | |
"name": "Flavobacteriales", | |
"children": [ | |
{ | |
"name": "Flavobacteriaceae", | |
"children": [ | |
{ | |
"name": "Flavobacterium", | |
"children": [ | |
{ | |
"name": "OTU.107", | |
"size": 1 | |
}, | |
{ | |
"name": "OTU.131", | |
"size": 1 | |
}, | |
{ | |
"name": "OTU.14", | |
"size": 1 | |
}, | |
{ | |
"name": "OTU.159", | |
"size": 1 | |
}, | |
{ | |
"name": "OTU.2379", | |
"size": 1 | |
}, | |
{ | |
"name": "OTU.3540", | |
"size": 1 | |
}, | |
{ | |
"name": "OTU.6203", | |
"size": 1 | |
} | |
] | |
} | |
] | |
} | |
] | |
} | |
] | |
}, | |
{ | |
"name": "Sphingobacteriia", | |
"children": [ | |
{ | |
"name": "Sphingobacteriales", | |
"children": [ | |
{ | |
"name": "Chitinophagaceae", | |
"children": [ | |
{ | |
"name": "Chitinophaga", | |
"children": [ | |
{ | |
"name": "OTU.183", | |
"size": 1 | |
} | |
] | |
}, | |
{ | |
"name": "Ferruginibacter", | |
"children": [ | |
{ | |
"name": "OTU.5906", | |
"size": 1 | |
} | |
] | |
}, | |
{ | |
"name": "Flavisolibacter", | |
"children": [ | |
{ | |
"name": "OTU.360", | |
"size": 1 | |
} | |
] | |
}, | |
{ | |
"name": "uncultured", | |
"children": [ | |
{ | |
"name": "OTU.277", | |
"size": 1 | |
} | |
] | |
} | |
] | |
} | |
] | |
} | |
] | |
} | |
] | |
}, | |
{ | |
"name": "Firmicutes", | |
"children": [ | |
{ | |
"name": "Bacilli", | |
"children": [ | |
{ | |
"name": "Bacillales", | |
"children": [ | |
{ | |
"name": "Bacillaceae", | |
"children": [ | |
{ | |
"name": "Bacillus", | |
"children": [ | |
{ | |
"name": "OTU.3507", | |
"size": 1 | |
} | |
] | |
}, | |
{ | |
"name": "unassigned", | |
"children": [ | |
{ | |
"name": "OTU.9", | |
"size": 1 | |
} | |
] | |
} | |
] | |
}, | |
{ | |
"name": "Paenibacillaceae", | |
"children": [ | |
{ | |
"name": "Paenibacillus", | |
"children": [ | |
{ | |
"name": "OTU.1040", | |
"size": 1 | |
}, | |
{ | |
"name": "OTU.1069", | |
"size": 1 | |
}, | |
{ | |
"name": "OTU.2040", | |
"size": 1 | |
}, | |
{ | |
"name": "OTU.267", | |
"size": 1 | |
}, | |
{ | |
"name": "OTU.319", | |
"size": 1 | |
}, | |
{ | |
"name": "OTU.335", | |
"size": 1 | |
}, | |
{ | |
"name": "OTU.369", | |
"size": 1 | |
}, | |
{ | |
"name": "OTU.394", | |
"size": 1 | |
}, | |
{ | |
"name": "OTU.5603", | |
"size": 1 | |
}, | |
{ | |
"name": "OTU.57", | |
"size": 1 | |
}, | |
{ | |
"name": "OTU.843", | |
"size": 1 | |
} | |
] | |
} | |
] | |
}, | |
{ | |
"name": "Planococcaceae", | |
"children": [ | |
{ | |
"name": "Sporosarcina", | |
"children": [ | |
{ | |
"name": "OTU.8", | |
"size": 1 | |
} | |
] | |
}, | |
{ | |
"name": "unassigned", | |
"children": [ | |
{ | |
"name": "OTU.4743", | |
"size": 1 | |
} | |
] | |
} | |
] | |
}, | |
{ | |
"name": "unassigned", | |
"children": [ | |
{ | |
"name": "unassigned", | |
"children": [ | |
{ | |
"name": "OTU.3", | |
"size": 1 | |
} | |
] | |
} | |
] | |
} | |
] | |
} | |
] | |
} | |
] | |
}, | |
{ | |
"name": "Planctomycetes", | |
"children": [ | |
{ | |
"name": "Planctomycetacia", | |
"children": [ | |
{ | |
"name": "Planctomycetales", | |
"children": [ | |
{ | |
"name": "Planctomycetaceae", | |
"children": [ | |
{ | |
"name": "Planctomyces", | |
"children": [ | |
{ | |
"name": "OTU.150", | |
"size": 1 | |
} | |
] | |
} | |
] | |
} | |
] | |
} | |
] | |
} | |
] | |
}, | |
{ | |
"name": "Proteobacteria", | |
"children": [ | |
{ | |
"name": "Alphaproteobacteria", | |
"children": [ | |
{ | |
"name": "Rhizobiales", | |
"children": [ | |
{ | |
"name": "Rhizobiaceae", | |
"children": [ | |
{ | |
"name": "Rhizobium", | |
"children": [ | |
{ | |
"name": "OTU.165", | |
"size": 1 | |
} | |
] | |
}, | |
{ | |
"name": "unassigned", | |
"children": [ | |
{ | |
"name": "OTU.19", | |
"size": 1 | |
} | |
] | |
} | |
] | |
} | |
] | |
}, | |
{ | |
"name": "Rhodobacterales", | |
"children": [ | |
{ | |
"name": "Rhodobacteraceae", | |
"children": [ | |
{ | |
"name": "unassigned", | |
"children": [ | |
{ | |
"name": "OTU.22", | |
"size": 1 | |
} | |
] | |
} | |
] | |
} | |
] | |
} | |
] | |
}, | |
{ | |
"name": "Betaproteobacteria", | |
"children": [ | |
{ | |
"name": "Burkholderiales", | |
"children": [ | |
{ | |
"name": "Comamonadaceae", | |
"children": [ | |
{ | |
"name": "unassigned", | |
"children": [ | |
{ | |
"name": "OTU.5", | |
"size": 1 | |
} | |
] | |
} | |
] | |
}, | |
{ | |
"name": "Oxalobacteraceae", | |
"children": [ | |
{ | |
"name": "unassigned", | |
"children": [ | |
{ | |
"name": "OTU.346", | |
"size": 1 | |
} | |
] | |
} | |
] | |
} | |
] | |
} | |
] | |
}, | |
{ | |
"name": "Deltaproteobacteria", | |
"children": [ | |
{ | |
"name": "Myxococcales", | |
"children": [ | |
{ | |
"name": "Sorangiineae", | |
"children": [ | |
{ | |
"name": "Sandaracinaceae", | |
"children": [ | |
{ | |
"name": "OTU.32", | |
"size": 1 | |
} | |
] | |
} | |
] | |
} | |
] | |
} | |
] | |
}, | |
{ | |
"name": "Gammaproteobacteria", | |
"children": [ | |
{ | |
"name": "aaa34a10", | |
"children": [ | |
{ | |
"name": "uncultured_bacterium", | |
"children": [ | |
{ | |
"name": "unassigned", | |
"children": [ | |
{ | |
"name": "OTU.48", | |
"size": 1 | |
} | |
] | |
} | |
] | |
} | |
] | |
}, | |
{ | |
"name": "Enterobacteriales", | |
"children": [ | |
{ | |
"name": "Enterobacteriaceae", | |
"children": [ | |
{ | |
"name": "Enterobacter", | |
"children": [ | |
{ | |
"name": "OTU.290", | |
"size": 1 | |
} | |
] | |
}, | |
{ | |
"name": "unassigned", | |
"children": [ | |
{ | |
"name": "OTU.68", | |
"size": 1 | |
} | |
] | |
} | |
] | |
} | |
] | |
}, | |
{ | |
"name": "Pseudomonadales", | |
"children": [ | |
{ | |
"name": "Pseudomonadaceae", | |
"children": [ | |
{ | |
"name": "Cellvibrio", | |
"children": [ | |
{ | |
"name": "OTU.6", | |
"size": 1 | |
} | |
] | |
} | |
] | |
} | |
] | |
}, | |
{ | |
"name": "Xanthomonadales", | |
"children": [ | |
{ | |
"name": "Xanthomonadaceae", | |
"children": [ | |
{ | |
"name": "Stenotrophomonas", | |
"children": [ | |
{ | |
"name": "OTU.11", | |
"size": 1 | |
} | |
] | |
} | |
] | |
} | |
] | |
} | |
] | |
} | |
] | |
}, | |
{ | |
"name": "Verrucomicrobia", | |
"children": [ | |
{ | |
"name": "Spartobacteria", | |
"children": [ | |
{ | |
"name": "Chthoniobacterales", | |
"children": [ | |
{ | |
"name": "Chthoniobacteraceae", | |
"children": [ | |
{ | |
"name": "Chthoniobacter", | |
"children": [ | |
{ | |
"name": "OTU.241", | |
"size": 1 | |
} | |
] | |
} | |
] | |
} | |
] | |
} | |
] | |
} | |
] | |
} | |
] | |
} | |
] | |
} |
This file contains hidden or 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
<!DOCTYPE html> | |
<meta charset="utf-8"> | |
<style> | |
text { | |
font: 20px sans-serif; | |
} | |
rect.background { | |
fill: white; | |
} | |
.axis { | |
shape-rendering: crispEdges; | |
} | |
.axis path, | |
.axis line { | |
fill: none; | |
stroke: #000; | |
} | |
</style> | |
<body> | |
<script src="http://d3js.org/d3.v3.min.js"></script> | |
<script> | |
var margin = {top: 30, right: 120, bottom: 0, left: 240}, | |
width = 960 - margin.left - margin.right, | |
height = 500 - margin.top - margin.bottom; | |
var x = d3.scale.linear() | |
.range([0, width]); | |
var barHeight = 40; | |
var color = d3.scale.ordinal() | |
.range(["steelblue", "#ccc"]); | |
var duration = 750, | |
delay = 25; | |
var partition = d3.layout.partition() | |
.value(function(d) { return d.size; }); | |
var xAxis = d3.svg.axis() | |
.scale(x) | |
.orient("top"); | |
var svg = d3.select("body").append("svg") | |
.attr("width", width + margin.left + margin.right) | |
.attr("height", height + margin.top + margin.bottom) | |
.append("g") | |
.attr("transform", "translate(" + margin.left + "," + margin.top + ")"); | |
svg.append("rect") | |
.attr("class", "background") | |
.attr("width", width) | |
.attr("height", height) | |
.on("click", up); | |
svg.append("g") | |
.attr("class", "x axis"); | |
svg.append("g") | |
.attr("class", "y axis") | |
.append("line") | |
.attr("y1", "100%"); | |
d3.json("readme.json", function(error, root) { | |
partition.nodes(root); | |
x.domain([0, root.value]).nice(); | |
down(root, 0); | |
}); | |
function down(d, i) { | |
if (!d.children || this.__transition__) return; | |
var end = duration + d.children.length * delay; | |
// Mark any currently-displayed bars as exiting. | |
var exit = svg.selectAll(".enter") | |
.attr("class", "exit"); | |
// Entering nodes immediately obscure the clicked-on bar, so hide it. | |
exit.selectAll("rect").filter(function(p) { return p === d; }) | |
.style("fill-opacity", 1e-6); | |
// Enter the new bars for the clicked-on data. | |
// Per above, entering bars are immediately visible. | |
var enter = bar(d) | |
.attr("transform", stack(i)) | |
.style("opacity", 1); | |
// Have the text fade-in, even though the bars are visible. | |
// Color the bars as parents; they will fade to children if appropriate. | |
enter.select("text").style("fill-opacity", 1e-6); | |
enter.select("rect").style("fill", color(true)); | |
// Update the x-scale domain. | |
x.domain([0, d3.max(d.children, function(d) { return d.value; })]).nice(); | |
// Update the x-axis. | |
svg.selectAll(".x.axis").transition() | |
.duration(duration) | |
.call(xAxis); | |
// Transition entering bars to their new position. | |
var enterTransition = enter.transition() | |
.duration(duration) | |
.delay(function(d, i) { return i * delay; }) | |
.attr("transform", function(d, i) { return "translate(0," + barHeight * i * 1.2 + ")"; }); | |
// Transition entering text. | |
enterTransition.select("text") | |
.style("fill-opacity", 1); | |
// Transition entering rects to the new x-scale. | |
enterTransition.select("rect") | |
.attr("width", function(d) { return x(d.value); }) | |
.style("fill", function(d) { return color(!!d.children); }); | |
// Transition exiting bars to fade out. | |
var exitTransition = exit.transition() | |
.duration(duration) | |
.style("opacity", 1e-6) | |
.remove(); | |
// Transition exiting bars to the new x-scale. | |
exitTransition.selectAll("rect") | |
.attr("width", function(d) { return x(d.value); }); | |
// Rebind the current node to the background. | |
svg.select(".background") | |
.datum(d) | |
.transition() | |
.duration(end); | |
d.index = i; | |
} | |
function up(d) { | |
if (!d.parent || this.__transition__) return; | |
var end = duration + d.children.length * delay; | |
// Mark any currently-displayed bars as exiting. | |
var exit = svg.selectAll(".enter") | |
.attr("class", "exit"); | |
// Enter the new bars for the clicked-on data's parent. | |
var enter = bar(d.parent) | |
.attr("transform", function(d, i) { return "translate(0," + barHeight * i * 1.2 + ")"; }) | |
.style("opacity", 1e-6); | |
// Color the bars as appropriate. | |
// Exiting nodes will obscure the parent bar, so hide it. | |
enter.select("rect") | |
.style("fill", function(d) { return color(!!d.children); }) | |
.filter(function(p) { return p === d; }) | |
.style("fill-opacity", 1e-6); | |
// Update the x-scale domain. | |
x.domain([0, d3.max(d.parent.children, function(d) { return d.value; })]).nice(); | |
// Update the x-axis. | |
svg.selectAll(".x.axis").transition() | |
.duration(duration) | |
.call(xAxis); | |
// Transition entering bars to fade in over the full duration. | |
var enterTransition = enter.transition() | |
.duration(end) | |
.style("opacity", 1); | |
// Transition entering rects to the new x-scale. | |
// When the entering parent rect is done, make it visible! | |
enterTransition.select("rect") | |
.attr("width", function(d) { return x(d.value); }) | |
.each("end", function(p) { if (p === d) d3.select(this).style("fill-opacity", null); }); | |
// Transition exiting bars to the parent's position. | |
var exitTransition = exit.selectAll("g").transition() | |
.duration(duration) | |
.delay(function(d, i) { return i * delay; }) | |
.attr("transform", stack(d.index)); | |
// Transition exiting text to fade out. | |
exitTransition.select("text") | |
.style("fill-opacity", 1e-6); | |
// Transition exiting rects to the new scale and fade to parent color. | |
exitTransition.select("rect") | |
.attr("width", function(d) { return x(d.value); }) | |
.style("fill", color(true)); | |
// Remove exiting nodes when the last child has finished transitioning. | |
exit.transition() | |
.duration(end) | |
.remove(); | |
// Rebind the current parent to the background. | |
svg.select(".background") | |
.datum(d.parent) | |
.transition() | |
.duration(end); | |
} | |
// Creates a set of bars for the given data node, at the specified index. | |
function bar(d) { | |
var bar = svg.insert("g", ".y.axis") | |
.attr("class", "enter") | |
.attr("transform", "translate(0,5)") | |
.selectAll("g") | |
.data(d.children) | |
.enter().append("g") | |
.style("cursor", function(d) { return !d.children ? null : "pointer"; }) | |
.on("click", down); | |
bar.append("text") | |
.attr("x", -6) | |
.attr("y", barHeight / 2) | |
.attr("dy", ".35em") | |
.style("text-anchor", "end") | |
.text(function(d) { return d.name; }); | |
bar.append("rect") | |
.attr("width", function(d) { return x(d.value); }) | |
.attr("height", barHeight); | |
return bar; | |
} | |
// A stateful closure for stacking bars horizontally. | |
function stack(i) { | |
var x0 = 0; | |
return function(d) { | |
var tx = "translate(" + x0 + "," + barHeight * i * 1.2 + ")"; | |
x0 += x(d.value); | |
return tx; | |
}; | |
} | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment