Simplification of bar chart code

See if this looks good. If so, I can simplify other code as well.