[diagram] Workaround floating point errors leading to diagram distortion
Fix #8554