BBC News: Poll tracker 2019

A project showing how each of the UK political parties are performing in the polls, built using JS (ES6), D3, Handlebars and Sass.

I focused more effort on the back-end of this project than we usually do for Visual Journalism projects.

For the core content / fallback, we decided to output a screenshot of the graph, to give users as full an experience as possible. I wrote a Node script to use Puppeteer to go to the project, take a screenshot of the graph at different viewport dimensions and save these locally. They are then pulled in as a fallback image for the graph.

We have one large dataset powering the three visual products on the page (the chart, the pictogram and the table of polls). This needs to be transformed and manipulated differently for each product. I worked with the data team to help them write JavaScript to filter and manipulate the data, which we could then run as a Node script during the build process. We could then format the resulting dataset how we needed for each product and output it as separate JSON files locally to the project.

We developed an auto deployment strategy, so the poll tracker could be updated out of hours without the need for a developer.
I used an AWS Lambda, running every minute, to check the data against a local copy to see if it had been updated. If it had, it would then trigger a Jenkins job.
Jenkins would build the project, run the data formatting tasks and generate an updated screenshot for the fallback content. I configured it to notify a Slack channel with it's progress - particularly focussing on descriptive erorr messages. This would allow the journalists to know if something went wrong. If it was successful, Jenkins would then deploy the project.

We wrote some unit tests to accompany this data formatting to make sure the data being pulled in and being outputted was how we expected it to be formatted and the values were within expected ranges. This was especially important because the auto deployment solution meant less manual checking / testing than when a project is usually updated.

Visit the Site

Related Work

  • How much warmer is your city?
  • Falling through the pay gap