修复Pie只有一个数据时设置border后显示异常的问题 (#237)

This commit is contained in:
monitor1394
2022-12-28 18:17:56 +08:00
parent bc6c387db3
commit 317ffc4d99
2 changed files with 6 additions and 3 deletions

View File

@@ -65,6 +65,7 @@ slug: /changelog
## master ## master
* (2022.12.28) 修复`Pie`只有一个数据时设置`border`后显示异常的问题 (#237)
* (2022.12.22) 调整`Covert`重命名为`Convert`,涉及的接口有:`ConvertXYAxis()``CovertSerie()` * (2022.12.22) 调整`Covert`重命名为`Convert`,涉及的接口有:`ConvertXYAxis()``CovertSerie()`
* (2022.12.22) 修复`Convert XY Axis`后Y轴的`Label`显示异常的问题 * (2022.12.22) 修复`Convert XY Axis`后Y轴的`Label`显示异常的问题
* (2022.12.12) 修复`Axis``Value`轴在某些情况下计算数值范围不准确的问题 * (2022.12.12) 修复`Axis``Value`轴在某些情况下计算数值范围不准确的问题

View File

@@ -1323,7 +1323,8 @@ namespace XUGL
float smoothness, int gradientType = 0, bool isYAxis = false) float smoothness, int gradientType = 0, bool isYAxis = false)
{ {
if (radius == 0) return; if (radius == 0) return;
if (gap > 0 && Mathf.Abs(toDegree - startDegree) >= 360) gap = 0; var isCircle = Mathf.Abs(toDegree - startDegree) >= 360;
if (gap > 0 && isCircle) gap = 0;
radius -= borderWidth; radius -= borderWidth;
smoothness = (smoothness < 0 ? 2f : smoothness); smoothness = (smoothness < 0 ? 2f : smoothness);
int segments = (int) ((2 * Mathf.PI * radius) * (Mathf.Abs(toDegree - startDegree) / 360) / smoothness); int segments = (int) ((2 * Mathf.PI * radius) * (Mathf.Abs(toDegree - startDegree) / 360) / smoothness);
@@ -1363,7 +1364,7 @@ namespace XUGL
if (realToAngle < realStartAngle) realToAngle = realStartAngle; if (realToAngle < realStartAngle) realToAngle = realStartAngle;
p2 = UGLHelper.GetPos(center, radius, realStartAngle); p2 = UGLHelper.GetPos(center, radius, realStartAngle);
} }
if (needBorder) if (needBorder && !isCircle)
{ {
borderDiff = borderLineWidth / Mathf.Sin(halfAngle); borderDiff = borderLineWidth / Mathf.Sin(halfAngle);
realCenter += borderDiff * middleDire; realCenter += borderDiff * middleDire;
@@ -1514,6 +1515,7 @@ namespace XUGL
insideRadius += borderWidth; insideRadius += borderWidth;
smoothness = smoothness < 0 ? 2f : smoothness; smoothness = smoothness < 0 ? 2f : smoothness;
Vector3 p1, p2, p3, p4, e1, e2; Vector3 p1, p2, p3, p4, e1, e2;
var isCircle = Mathf.Abs(toDegree - startDegree) >= 360;
var needBorder = borderWidth != 0; var needBorder = borderWidth != 0;
var needSpace = gap != 0; var needSpace = gap != 0;
var diffAngle = Mathf.Abs(toDegree - startDegree) * Mathf.Deg2Rad; var diffAngle = Mathf.Abs(toDegree - startDegree) * Mathf.Deg2Rad;
@@ -1581,7 +1583,7 @@ namespace XUGL
p2 = UGLHelper.GetPos(center, outsideRadius, realStartOutAngle, false); p2 = UGLHelper.GetPos(center, outsideRadius, realStartOutAngle, false);
e2 = UGLHelper.GetPos(center, outsideRadius, realToOutAngle, false); e2 = UGLHelper.GetPos(center, outsideRadius, realToOutAngle, false);
} }
if (needBorder) if (needBorder && !isCircle)
{ {
var borderDiff = borderWidth / Mathf.Sin(halfAngle); var borderDiff = borderWidth / Mathf.Sin(halfAngle);
realCenter += Mathf.Abs(borderDiff) * middleDire; realCenter += Mathf.Abs(borderDiff) * middleDire;