updated so that bar height never exceeds y axis limit