Compare commits

...

3 Commits
v2.8.2 ... 2.0

Author SHA1 Message Date
monitor1394
1d2f83169d 修复Pie只有一个数据时设置border后显示异常的问题 (#237) 2022-12-28 18:17:00 +08:00
monitor1394
a7c4e24555 [bug][datazoom] fix datazoom range error (#221) 2022-08-30 08:10:18 +08:00
monitor1394
6fad4fcccc update to Unity2019.4.39f1 2022-08-16 06:54:04 +08:00
6 changed files with 34 additions and 29 deletions

View File

@@ -46,6 +46,9 @@
## branch-2.0 ## branch-2.0
* (2022.12.28) 修复`Pie`只有一个数据时设置`border`后显示异常的问题 (#237)
* (2022.08.30) 修复`DataZoom`在某些情况下计算范围不准确的问题 (#221)
## v2.8.2 ## v2.8.2
* (2022.08.15) 发布`v2.8.2`版本 * (2022.08.15) 发布`v2.8.2`版本

View File

@@ -712,13 +712,13 @@ namespace XCharts
int start = 0, end = 0; int start = 0, end = 0;
if (dataZoom.runtimeInvert) if (dataZoom.runtimeInvert)
{ {
end = Mathf.CeilToInt(data.Count * dataZoom.end / 100); end = Mathf.RoundToInt(data.Count * dataZoom.end / 100);
start = end - range; start = end - range;
if (start < 0) start = 0; if (start < 0) start = 0;
} }
else else
{ {
start = Mathf.FloorToInt(data.Count * dataZoom.start / 100); start = Mathf.RoundToInt(data.Count * dataZoom.start / 100);
end = start + range; end = start + range;
if (end > data.Count) end = data.Count; if (end > data.Count) end = data.Count;
} }
@@ -735,8 +735,8 @@ namespace XCharts
if (filterMinShow > data.Count) range = data.Count; if (filterMinShow > data.Count) range = data.Count;
else range = filterMinShow; else range = filterMinShow;
} }
if (range > data.Count - start - 1) if (range > data.Count - start)
start = data.Count - range - 1; start = data.Count - range;
filterData = data.GetRange(start, range); filterData = data.GetRange(start, range);
} }
else else

View File

@@ -642,13 +642,13 @@ namespace XCharts
int start = 0, end = 0; int start = 0, end = 0;
if (dataZoom.runtimeInvert) if (dataZoom.runtimeInvert)
{ {
end = Mathf.CeilToInt(data.Count * dataZoom.end / 100); end = Mathf.RoundToInt(data.Count * dataZoom.end / 100);
start = end - range; start = end - range;
if (start < 0) start = 0; if (start < 0) start = 0;
} }
else else
{ {
start = Mathf.FloorToInt(data.Count * dataZoom.start / 100); start = Mathf.RoundToInt(data.Count * dataZoom.start / 100);
end = start + range; end = start + range;
if (end > data.Count) end = data.Count; if (end > data.Count) end = data.Count;
} }
@@ -666,8 +666,8 @@ namespace XCharts
if (dataZoom.minShowNum > data.Count) range = data.Count; if (dataZoom.minShowNum > data.Count) range = data.Count;
else range = dataZoom.minShowNum; else range = dataZoom.minShowNum;
} }
if (range > data.Count - start - 1) if (range > data.Count - start)
start = data.Count - range - 1; start = data.Count - range;
serie.m_FilterData = data.GetRange(start, range); serie.m_FilterData = data.GetRange(start, range);
} }
else else

View File

@@ -34,7 +34,7 @@ namespace XUGL
/// <param name="dent">箭头凹度</param> /// <param name="dent">箭头凹度</param>
/// <param name="color">颜色</param> /// <param name="color">颜色</param>
public static void DrawArrow(VertexHelper vh, Vector3 startPoint, Vector3 arrowPoint, float width, public static void DrawArrow(VertexHelper vh, Vector3 startPoint, Vector3 arrowPoint, float width,
float height, float offset, float dent, Color32 color) float height, float offset, float dent, Color32 color)
{ {
var dir = (arrowPoint - startPoint).normalized; var dir = (arrowPoint - startPoint).normalized;
var sharpPos = arrowPoint + (offset + height / 4) * dir; var sharpPos = arrowPoint + (offset + height / 4) * dir;
@@ -435,7 +435,7 @@ namespace XUGL
/// <param name="color">颜色</param> /// <param name="color">颜色</param>
/// <param name="vertical">是否垂直方向</param> /// <param name="vertical">是否垂直方向</param>
public static void DrawRectangle(VertexHelper vh, Vector3 p, float xRadius, float yRadius, public static void DrawRectangle(VertexHelper vh, Vector3 p, float xRadius, float yRadius,
Color32 color, bool vertical = true) Color32 color, bool vertical = true)
{ {
DrawRectangle(vh, p, xRadius, yRadius, color, color, vertical); DrawRectangle(vh, p, xRadius, yRadius, color, color, vertical);
} }
@@ -1063,7 +1063,7 @@ namespace XUGL
} }
public static void DrawTriangle(VertexHelper vh, Vector3 p1, public static void DrawTriangle(VertexHelper vh, Vector3 p1,
Vector3 p2, Vector3 p3, Color32 color, Color32 color2, Color32 color3) Vector3 p2, Vector3 p3, Color32 color, Color32 color2, Color32 color3)
{ {
UIVertex v1 = new UIVertex(); UIVertex v1 = new UIVertex();
v1.position = p1; v1.position = p1;
@@ -1091,7 +1091,7 @@ namespace XUGL
} }
public static void DrawCricle(VertexHelper vh, Vector3 center, float radius, Color32 color, public static void DrawCricle(VertexHelper vh, Vector3 center, float radius, Color32 color,
Color32 toColor, float smoothness = 2f) Color32 toColor, float smoothness = 2f)
{ {
DrawSector(vh, center, radius, color, toColor, 0, 360, 0, s_ClearColor32, smoothness); DrawSector(vh, center, radius, color, toColor, 0, 360, 0, s_ClearColor32, smoothness);
} }
@@ -1138,13 +1138,13 @@ namespace XUGL
} }
public static void DrawSector(VertexHelper vh, Vector3 center, float radius, Color32 color, public static void DrawSector(VertexHelper vh, Vector3 center, float radius, Color32 color,
float startDegree, float toDegree, float smoothness = 2f) float startDegree, float toDegree, float smoothness = 2f)
{ {
DrawSector(vh, center, radius, color, color, startDegree, toDegree, 0, s_ClearColor32, smoothness); DrawSector(vh, center, radius, color, color, startDegree, toDegree, 0, s_ClearColor32, smoothness);
} }
public static void DrawSector(VertexHelper vh, Vector3 center, float radius, Color32 color, Color32 toColor, public static void DrawSector(VertexHelper vh, Vector3 center, float radius, Color32 color, Color32 toColor,
float startDegree, float toDegree, int gradientType = 0, bool isYAxis = false, float smoothness = 2f) float startDegree, float toDegree, int gradientType = 0, bool isYAxis = false, float smoothness = 2f)
{ {
DrawSector(vh, center, radius, color, toColor, startDegree, toDegree, 0, s_ClearColor32, 0, smoothness, DrawSector(vh, center, radius, color, toColor, startDegree, toDegree, 0, s_ClearColor32, 0, smoothness,
gradientType, isYAxis); gradientType, isYAxis);
@@ -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)
{ {

View File

@@ -9,15 +9,15 @@ MonoBehaviour:
m_GameObject: {fileID: 0} m_GameObject: {fileID: 0}
m_Enabled: 1 m_Enabled: 1
m_EditorHideFlags: 0 m_EditorHideFlags: 0
m_Script: {fileID: 0} m_Script: {fileID: 13964, guid: 0000000000000000e000000000000000, type: 0}
m_Name: m_Name:
m_EditorClassIdentifier: UnityEditor:UnityEditor.PackageManager.UI:PackageManagerProjectSettings m_EditorClassIdentifier:
m_ScopedRegistriesSettingsExpanded: 1 m_ScopedRegistriesSettingsExpanded: 1
oneTimeWarningShown: 0 oneTimeWarningShown: 0
m_Registries: m_Registries:
- m_Id: main - m_Id: main
m_Name: m_Name:
m_Url: https://packages.unity.cn m_Url: https://packages.unity.com
m_Scopes: [] m_Scopes: []
m_IsDefault: 1 m_IsDefault: 1
m_UserSelectedRegistryName: m_UserSelectedRegistryName:

View File

@@ -1,2 +1,2 @@
m_EditorVersion: 2019.4.13f1c1 m_EditorVersion: 2019.4.39f1
m_EditorVersionWithRevision: 2019.4.13f1c1 (ddecf0c37a3b) m_EditorVersionWithRevision: 2019.4.39f1 (78d14dfa024b)