A small visualization I’ve wanted to do for a while is a tree of life graph — visualizing all known species and their relationships.
Recently I found that the Catalog of Life project has a very accessible database of all known species / taxonomic groups and their relationships, available for download here. This let me put together a simple site backed by their database, available here:
http://taxontree.bpodgursky.com/
All the source code is available on Github.
Design
I’ve used dagre + d3 on a number of other graph visualization projects, so dagre-d3 was the natural choice for the visualization component. The actual code required to do the graph building and rendering is pretty trivial.
The data fetching was a bit trickier. Since pre-loading tens of millions of records was obviously unrealistic, I had to implement a graph class (BackedBiGraph) which lazily expands and collapses, using user-provided callbacks to fetch new data. In this case, the callbacks were just ajax calls back to the server.
The Catalog of Life database did not come with a Java client, so I thought this would be a good opportunity to use jOOQ to generate Java models and query builders corresponding to the COL database, since I am allergic to writing actual SQL queries. This ended up working very well — configuring the jOOQ Maven plugin was simple, and the generated code made writing the queries trivial:
private Collection<TaxonNodeInfo> taxonInfo(Condition condition) {
return context.select()
.from(TAXON)
.leftOuterJoin(TAXON_NAME_ELEMENT)
.on(TAXON.ID.equal(TAXON_NAME_ELEMENT.TAXON_ID))
.leftOuterJoin(SCIENTIFIC_NAME_ELEMENT)
.on(SCIENTIFIC_NAME_ELEMENT.ID.equal(TAXON_NAME_ELEMENT.SCIENTIFIC_NAME_ELEMENT_ID))
.where(condition).fetch().stream().map(record -> new TaxonNodeInfo(
record.into(TAXON),
record.into(TAXON_NAME_ELEMENT),
record.into(SCIENTIFIC_NAME_ELEMENT)
)).collect(Collectors.toList());
}
All in all, there are a lot of rough edges still, but dagre, d3 and jOOQ made this a much easier project than expected. The code is on Github, so suggestions, improvements, or bugfixes are always welcome.

