avoid negative value

This commit is contained in:
Murugan, Vimal 2020-01-21 20:31:02 +05:30
parent 13cc6bf209
commit fffb04e5e1

View File

@ -176,7 +176,7 @@ open class DoughnutChart: View {
labelContainer.layoutIfNeeded()
let radius = sizeObject.getValueBasedOnApplicationWidth()/2 - lineWidth()
let labelheight = labelContainer.frame.height/2
let padding = sizeObject.getValueBasedOnApplicationWidth()/2 - sqrt(abs(pow(radius, 2) - pow(labelheight, 2)))
let padding = sizeObject.getValueBasedOnApplicationWidth()/2 - sqrt(max(0, pow(radius, 2) - pow(labelheight, 2)))
labelContainerLeftConstraint?.constant = padding
labelContainerRightConstraint?.constant = padding