Posted by John Durance on 20 Apr, 2015
If you haven’t heard, someone has struck oil in Surrey – yes, in Surrey – but before you consider rushing to the home counties, the BBC news article I read last week reports that only a fraction of the oil is recoverable. The UK is not about to rival the big Middle East oil giants.
Arguably, the Middle East has ten oil-producing countries. The other countries in the region have no – or no significant – proven reserves. The map opposite shows which countries are sitting on top of the large reserves. The legend shows the map’s scale, measured in billions of barrels.
Creating a legend, which describes a scale for (choropleth) maps, is the final task I have completed for a data visualisation project I am currently working on – at least for the map part of the project. Overall, the aim of the project is to make a drupal module that can upload large datasets and display D3 driven visualisations of the uploaded data.
I found a handy plugin, on GitHub, to create my legends: d3-svg-legend. This plugin takes as its main argument a D3 scale and then several additional arguments for formatting the look of the legend. You may alter the width, height, units, labels etc. You can also choose a vertical or a horizontal legend (as I have done for this map). It got me most of the way there. I just needed to make a few minor alterations in my own code to get exactly the result I wanted.