Move the bar calcs out of the callback.