Modified the calculation of the positions where the value items are painted