mirror of
https://github.com/XCharts-Team/XCharts.git
synced 2026-05-30 05:08:48 +00:00
修复Pie只有一个数据时设置border后显示异常的问题 (#237)
This commit is contained in:
@@ -46,6 +46,7 @@
|
|||||||
|
|
||||||
## branch-2.0
|
## branch-2.0
|
||||||
|
|
||||||
|
* (2022.12.28) 修复`Pie`只有一个数据时设置`border`后显示异常的问题 (#237)
|
||||||
* (2022.08.30) 修复`DataZoom`在某些情况下计算范围不准确的问题 (#221)
|
* (2022.08.30) 修复`DataZoom`在某些情况下计算范围不准确的问题 (#221)
|
||||||
|
|
||||||
## v2.8.2
|
## v2.8.2
|
||||||
|
|||||||
@@ -1183,10 +1183,11 @@ 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 (space > 0 && Mathf.Abs(toDegree - startDegree) >= 360) space = 0;
|
var isCircle = Mathf.Abs(toDegree - startDegree) >= 360;
|
||||||
|
if (space > 0 && isCircle) space = 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);
|
||||||
if (segments < 1) segments = 1;
|
if (segments < 1) segments = 1;
|
||||||
float startAngle = startDegree * Mathf.Deg2Rad;
|
float startAngle = startDegree * Mathf.Deg2Rad;
|
||||||
float toAngle = toDegree * Mathf.Deg2Rad;
|
float toAngle = toDegree * Mathf.Deg2Rad;
|
||||||
@@ -1223,7 +1224,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;
|
||||||
@@ -1259,9 +1260,9 @@ namespace XUGL
|
|||||||
{
|
{
|
||||||
p4 = new Vector3(p3.x, realCenter.y);
|
p4 = new Vector3(p3.x, realCenter.y);
|
||||||
var dist = p4.x - realCenter.x;
|
var dist = p4.x - realCenter.x;
|
||||||
var tcolor = Color32.Lerp(color, toColor, dist >= 0
|
var tcolor = Color32.Lerp(color, toColor, dist >= 0 ?
|
||||||
? dist / radius
|
dist / radius :
|
||||||
: Mathf.Min(radius + dist, radius) / radius);
|
Mathf.Min(radius + dist, radius) / radius);
|
||||||
if (isLeft && (i == segments || i == 0)) tcolor = toColor;
|
if (isLeft && (i == segments || i == 0)) tcolor = toColor;
|
||||||
DrawQuadrilateral(vh, lastP4, p2, p3, p4, lastColor, tcolor);
|
DrawQuadrilateral(vh, lastP4, p2, p3, p4, lastColor, tcolor);
|
||||||
lastP4 = p4;
|
lastP4 = p4;
|
||||||
@@ -1374,11 +1375,12 @@ 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 = space != 0;
|
var needSpace = space != 0;
|
||||||
var diffAngle = Mathf.Abs(toDegree - startDegree) * Mathf.Deg2Rad;
|
var diffAngle = Mathf.Abs(toDegree - startDegree) * Mathf.Deg2Rad;
|
||||||
|
|
||||||
int segments = (int)((2 * Mathf.PI * outsideRadius) * (diffAngle * Mathf.Rad2Deg / 360) / smoothness);
|
int segments = (int) ((2 * Mathf.PI * outsideRadius) * (diffAngle * Mathf.Rad2Deg / 360) / smoothness);
|
||||||
if (segments < 1) segments = 1;
|
if (segments < 1) segments = 1;
|
||||||
float startAngle = startDegree * Mathf.Deg2Rad;
|
float startAngle = startDegree * Mathf.Deg2Rad;
|
||||||
float toAngle = toDegree * Mathf.Deg2Rad;
|
float toAngle = toDegree * Mathf.Deg2Rad;
|
||||||
@@ -1441,7 +1443,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;
|
||||||
@@ -1624,7 +1626,7 @@ namespace XUGL
|
|||||||
float lineWidth, Color32 lineColor, float smoothness)
|
float lineWidth, Color32 lineColor, float smoothness)
|
||||||
{
|
{
|
||||||
var dist = Vector3.Distance(sp, ep);
|
var dist = Vector3.Distance(sp, ep);
|
||||||
var segment = (int)(dist / (smoothness <= 0 ? 2f : smoothness));
|
var segment = (int) (dist / (smoothness <= 0 ? 2f : smoothness));
|
||||||
UGLHelper.GetBezierList2(ref s_CurvesPosList, sp, ep, segment, cp1, cp2);
|
UGLHelper.GetBezierList2(ref s_CurvesPosList, sp, ep, segment, cp1, cp2);
|
||||||
if (s_CurvesPosList.Count > 1)
|
if (s_CurvesPosList.Count > 1)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user