diff --git a/CHANGELOG.md b/CHANGELOG.md index 02cf9f85..b2282e0b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -54,6 +54,7 @@ ## master +* (2022.06.25) 优化`Line`的平滑曲线表现 (#169) * (2022.06.25) 修复`DataZoom`开启时`Tooltip`显示数据不一致的问题 (#203) * (2022.06.25) 修复`Toolip`在类目轴无数据时绘制异常的问题 (#204) * (2022.06.25) 优化`Serie`设置`PlaceHolder`时的`Tooltip`表现 diff --git a/Runtime/Component/Settings/Settings.cs b/Runtime/Component/Settings/Settings.cs index 1ae8d719..5a7fb4c1 100644 --- a/Runtime/Component/Settings/Settings.cs +++ b/Runtime/Component/Settings/Settings.cs @@ -17,7 +17,7 @@ namespace XCharts.Runtime [SerializeField] protected Material m_SeriePainterMaterial; [SerializeField] protected Material m_UpperPainterMaterial; [SerializeField] protected Material m_TopPainterMaterial; - [SerializeField][Range(1, 10)] protected float m_LineSmoothStyle = 3f; + [SerializeField][Range(1, 10)] protected float m_LineSmoothStyle = 2.5f; [SerializeField][Range(1f, 20)] protected float m_LineSmoothness = 2f; [SerializeField][Range(0.5f, 20)] protected float m_LineSegmentDistance = 3f; [SerializeField][Range(1, 10)] protected float m_CicleSmoothness = 2f; diff --git a/Runtime/Serie/Line/LineHelper.cs b/Runtime/Serie/Line/LineHelper.cs index 27d06aeb..b1a2fb1f 100644 --- a/Runtime/Serie/Line/LineHelper.cs +++ b/Runtime/Serie/Line/LineHelper.cs @@ -496,7 +496,7 @@ namespace XCharts.Runtime if (isY) UGLHelper.GetBezierListVertical(ref s_CurvesPosList, sp, ep, smoothness, setting.lineSmoothStyle); else - UGLHelper.GetBezierList(ref s_CurvesPosList, sp, ep, lsp, nep, smoothness, setting.lineSmoothStyle); + UGLHelper.GetBezierList(ref s_CurvesPosList, sp, ep, lsp, nep, smoothness, setting.lineSmoothStyle, true); for (int j = 1; j < s_CurvesPosList.Count; j++) { diff --git a/Runtime/XUGL/UGLHelper.cs b/Runtime/XUGL/UGLHelper.cs index 9d17934f..2f7166cb 100644 --- a/Runtime/XUGL/UGLHelper.cs +++ b/Runtime/XUGL/UGLHelper.cs @@ -59,8 +59,7 @@ namespace XUGL for (int i = 0; i < list1.Count; i++) { - if (list1[i] == null && list2[i] == null) - { } + if (list1[i] == null && list2[i] == null) { } else { if (list1[i] != null) @@ -109,7 +108,7 @@ namespace XUGL } public static void GetBezierList(ref List posList, Vector3 sp, Vector3 ep, - Vector3 lsp, Vector3 nep, float smoothness = 2f, float k = 2.0f) + Vector3 lsp, Vector3 nep, float smoothness = 2f, float k = 2.0f, bool limit = false) { float dist = Mathf.Abs(sp.x - ep.x); Vector3 cp1, cp2; @@ -124,9 +123,20 @@ namespace XUGL else { cp1 = sp + (ep - lsp).normalized * diff; + if (limit) + cp1.y = sp.y; + + } + if (nep == ep) + { + cp2 = ep; + } + else + { + cp2 = ep - (nep - sp).normalized * diff; + if (limit) + cp2.y = ep.y; } - if (nep == ep) cp2 = ep; - else cp2 = ep - (nep - sp).normalized * diff; dist = Vector3.Distance(sp, ep); int segment = (int) (dist / (smoothness <= 0 ? 2f : smoothness)); if (segment < 1) segment = (int) (dist / 0.5f);