Refactor out parts of graph widget for histogram widget

There are quite a few common parts that histograms (or all charts with a time axis, for that matter) could re-use. This also needs to be done before we can do #132 properly.