Visualising electoral data again
Obviously with the results of the general election announced my mind turns to analysis and visualisation. I had/have been looking at this for a while, and here are my notes. Actually this is an index entry as much of what I had found is catalogued in the two related posts below/overleaf. …
The ONS offer tools visualising facts by constituency
I had another look at this in 2021. I have found the following links,
- https://open-innovations.org/blog/2017-05-08-mapping-election-with-hexes, an opening page at odileeds, mainly about why hexagons.
- https://odileeds.github.io/odi.hexmap.js/, they say, “This library assumes you have an existing hex layout as HexJSON (e.g. layouts we’ve made) and the ability to add Javascript to a webpage. The library creates an SVG (scalable vector graphic) of hexes – which can be styled via CSS – and some basic event callbacks.” This has a lot of example code, otherwise known by me as%CODE2%
- https://open-innovations.org/projects/hexmaps/ge2019/ this is the 2019 GE with popups on the constituencies, %CODE3%
- https://open-innovations.org/blog/2017-05-08-mapping-election-with-hexes or how Leeds got there! They point at the hexmap of constituencies, and the code that does the 2015 and other results.
- https://github.com/jbaileyh/geogrid claims to be a tool that generates the cartograms from HexJson. It does and works from a .csv spreadsheet. I used this colour picker to get the colour hex codes.
- A document on HexJSON and how to write it.
So I made a hexmap, it’s not finished yet.
- I started from here, where they publish code that almost works. I found this via the ODI page documenting the javascript.
- I used this page to generate the hexmap in json.
%CODE1%
I had to poke around the ODI pages to find the ODI.ready(function(){ rune, which I found inside the ODI javascript. They talk about a format function which I can’t quite get to work. Format is used if varying the SVG file, it uses tspan
entity. I would like to offer a popup box rather than use this tool.
Related Posts
The latter link has the following links,
- Election hex mapping, at ODI Leeds.
- 2017 General Election hex map, at ODI Leeds.
Comment ( 1 )