This stuff should really live in charts.js.