What's new in our first release version of the dailygraphics rig?

Our dailygraphics rig has been around for more than a year and in that time we’ve used it to make hundreds of responsive rectangles of good internet, but we’ve never made it easy for others to use. The rig is heavily customized for our needs and includes our organization-specific styles and templates. Despite this, a handful of hardy news organizations have made efforts to adopt it. In order to better facilitate this, today we are releasing our first fixed “version” of the rig: 0.1.0.

This isn’t a traditional release. The rapid pace of development and the pace of our news cycle makes it impossible for us to manage normal open source releases. Instead, we will tag selected commits with version numbers, and maintain a detailed CHANGELOG of everything that happens between those commits. This way users who want to use and stay up to date with the rig will have a clear path to do so.

As part of this release we’ve folded in a number of changes that make dailygraphics better than ever.

Block histogram

This block histogram is a format we’ve used several times to display discrete “binned” data. It works especially well for states or countries. Aly has turned it into a new graphic template so we can spin them up quickly. Run fab add_block_histogram to make one now!

Negative numbers and smart label positioning

The bar_chart, column_chart, grouped_bar_chart, stacked_bar_chart and stacked_column_chart graphic templates have all been updated to gracefully support negative numbers.

These five templates are also now much smarter about positioning labels so they always fit within the confines of the chart or hiding them if there is no way to make them fit in the available space.

(Curious how we did this? Here is the relevant code for bar charts. And here it is for column charts.)

Custom Jinja filters

Lastly, we’ve added support for defining custom Jinja filter functions in graphic_config.py. This allows for, among other things, much more complex formatting of numbers in Jinja templates. For example, to print comma-formatted numbers you can add this filter function:

def comma_format(value):
    return locale.format('%d', float(value), grouping=True)

JINJA_FILTER_FUNCTIONS = [
    comma_format
]

And then use it in your template, like this:

{{ row.value|comma_format }}

Documention for this feature has been added to the README.

Please see the CHANGELOG for a more complete list of changes we’ve made. We hope this new release process allows more news organizations to experience the joy of using a code-driven process for making daily charts and graphics.

Never miss a gig

Join the Visuals Gigs mailing list to get an email when we post internships and full-time jobs.

Your membership will be kept confidential.

 

Carebot

Meaningful analytics for journalism.

Elex

A command-line tool to get election results from the Associated Press Election API v2.0. Elex is designed to be friendly, fast and agnostic to your language/database choices.

Pym.js

A JavaScript library for responsive iframes.

 

On The Team Blog

March 31, 2017

Subverting the Story Model

How we broke the story model and remade it to suit the new pace of news — and how you can, too (external link)

More