Week Beginning 11th January 2014

I spent most of this week continuing to work with the visualisations for the Mapping Metaphor project, going through the list of new features and fixes that has been built up since I first unveiled the test version of the site to the project team.  I renamed to top-level main categories as found in the side panel of the aggregate view of the diagram so they have the correct names, which I somehow managed to get wrong before.  I also updated the way dates are displayed in the ‘metaphor card’ view.  Previously the dates were rounded to decades but it was decided that this gave a somewhat false impression of accuracy.  I have now rounded the dates to half centuries – e.g. ‘First half of the 14th century’, which is a lot better.  Of course, all the dates currently used for test purposes were pulled out of thin air, but once I get some proper data things will work as required.

Those two changes were pretty easy to implement, and after getting those out of the way I dived into some more taxing updates.  Firstly, I added in facilities to rotate the diagram.  Previously the diagram loaded and the user had to option of rotating it – not so good if the category name is very long and gets cut off, or if you want to get the category you’re particularly interested in at the left with straight, easily readable text.  Now I’ve added buttons that allow users to rotate the diagram clockwise or anti-clockwise, moving 10 degrees per click.  I think it works very well and makes the diagrams much more readable.

The next thing I added was the option to focus in on one particular subcategory, showing just it and all the subcategories linked to / from it.  This view really helps when you’re looking at a category that has a huge number of connections within it (e.g. B – life).  If you’re particularly in the connections between one of the subcategories (e.g. B02 Birth) you can now click an option load the diagram with the connections to/from this subcategory without the rest of the category connections cluttering things up.  And of course you can easily return to the full category view, or navigate to another subcategory too.  It works rather nicely.  I might try and get some animation into the diagram, so the non-linked subcategories fade away and the linked categories move around the diagram to their optimal positions.  This is for sometime down the line though!

The final big thing I started to investigate this week was providing an option to export your diagram as an image file.  At the moment you can view lots of information using the diagram, but it’s not possible to save a particular view for future use, or to export an image to use in your research etc.  I wanted to add the facility to save the diagram as a nice, high-resolution PNG file.  In my naivety I had thought that converting an SVG file into a PNG file would be quite a straightforward task.  But no.  Actually, it might be straightforward with relatively simple SVG files, but ones that include so much text where the position of the text is of vital importance proved quite tricky.  Initially I had hope to accomplish this at the client side using Javascript.  I used a library called canvg to add the SVG onto an HTML5 canvas element, with the intension of then using  the HTML5 canvas.toDataURL facility to convert the canvas area to a PNG.  Unfortunately canvg failed to get the text labels properly positioned so I instead decided to try a server-side tool.

Having used ImageMagick for many years to convert images through PHP scripts, I thought this would be an ideal solution.  However, there is some issue with ImageMagick’s SVG processing capabilities, and it too managed to mess up the positioning of the text elements when generating a PNG file.  Eventually I found a very nice SVG manipulation and creation tool called inkscape that as well as providing a GUI based SVG editor also includes some handy command-line tools, including an SVG to PNG converter.  This created my test SVG file to a PNG perfectly, both on my local PC and on our server at the command-line.  Problem solved?  Unfortunately no.  While the script worked directly at the command line it refused to output a PNG file when executed via Apache within a PHP script.  The PHP script itself also worked fine at the command-line so there was some problem with permissions when running things through Apache.  Chris, our helpful server admin guy, and I spent a few frustrating hours trying to get to the bottom of this on Friday and I’m afraid to say we still haven’t found a solution.  I really hope we can figure something out next week.

Other than Mapping Metaphor stuff I spent a little time on Burns related things this week.  I had a meeting with Kirsteen and Vivien about their ‘Choral Burns’ project which is starting up this month.  I also started working on the website for this project, although there is still a lot to set up for it.

I also attended a meeting with Carole Hough, Simon Taylor and Thomas Clancy about a new AHRC bid that they are putting together.  I will be involved in the writing of the technical plan for this project in the next couple of weeks or so.