Taxonomic diagrams

I’ve been trying to work out a way to automatically generate taxonomic species diagrams from my species list. I’ve nearly achieved it, subject to one annoying problem. It’s close enough though, so I’ve put it live anyway. The diagrams can be reached by selecting ‘diagram’ from the ‘view mode’ option on the species list. Like the list itself, the diagram will regenerate when filters are applied from the left hand side of the page.

The problem that I haven’t yet solved is the unwanted vertical lines that don’t connect to anything. I know exactly why it happens, but I’m yet to figure out the logic to avoid it happening. I can see a couple of solutions that will work, but not without hitting the database for every single data item on the diagram, which is too much overhead. The problem stems from having to generate the diagram sequentially, but needing foresight of the data that is yet to be read, so that it’s possible to determine whether a particular data item is the last one within its parent’s group. If I can’t find a solution, it will stay as it is – it works, and it’s close enough. However, I’ll try to solve it – weirdly, I enjoy this stuff.

*update* The problem is now resolved 🙂