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:
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.