Converts taxonomy data (csv/txt) to multilevel flare.json data for D3.js
visualizations
This program converts text/csv categorical data into the flare
class hierarchy JSON format accepted by many popular D3.js
visualizations
(i.e. collapsible tree).
Dependencies include the json-simple java library.
Usage is through the command line; run the program similar to any other java
application with command line arguments:
java D3Taxonomy <input file> <delimiter>
.
(assuming all required files are in the same working directory)
$ javac -cp json-simple-1.1.1.jar D3Taxonomy.java
$ java -cp json-simple-1.1.1.jar: D3Taxonomy taxonomy_en-US.txt " > "
Program will both print final JSON string to the console as well as save it in file "flare.json" in the present working directory. The source may be modified as necesary for special use cases.
Any text delimiter is compatible, examples include ,
(commas) for comma
separated values, or >
for plain text files.
NOTE: please pay close attention to the proper delimiter in your file or the
tree generated may contain errors/duplicate entries.
JSON data is stored in a tree structure with a dynamically expanding list for sub nodes while processing.
Sample data includes the Google product taxonomy which is downloadable from Google (in both plain-text and excel (convertable to csv) formats). Sample d3.js visualization used is collapsible tree.
Sample output with the Google taxonomy data along with the data itself in both
csv and txt formats can be found in the /samples
directory of the repo. The
sample jsontree.html
file uses the collapsible tree visualization with the
produced json as input. It may be directly viewed with a web browser.