From 438f98db68b6805a7af13b6ee2844d2d325fc2cb Mon Sep 17 00:00:00 2001 From: monitor1394 Date: Thu, 12 Nov 2020 09:23:10 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D`LineChart`=E5=BD=93=E7=B1=BB?= =?UTF-8?q?=E5=9E=8B=E4=B8=BA`Smooth`=E6=97=B6=E6=95=B0=E6=8D=AE=E8=BF=87?= =?UTF-8?q?=E5=AF=86=E6=83=85=E5=86=B5=E4=B8=8B=E6=8A=A5=E9=94=99=E7=9A=84?= =?UTF-8?q?=E9=97=AE=E9=A2=98=20#101?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CHANGELOG-EN.md | 1 + CHANGELOG.md | 1 + Runtime/Internal/Utility/ChartHelper.cs | 15 ++++++++++++++- 3 files changed, 16 insertions(+), 1 deletion(-) diff --git a/CHANGELOG-EN.md b/CHANGELOG-EN.md index b66dd70a..41d9866c 100644 --- a/CHANGELOG-EN.md +++ b/CHANGELOG-EN.md @@ -1,6 +1,7 @@ # 更新日志 +* (2020.11.12) Fixed `LineChart` reporting errors when the type was `Smooth` when the data was too secure #101 * (2020.10.22) Improve the support of `VisualMap` for `Piecewise` in `HeatmapChart` * (2020.09.22) Fixed `PieChart` inconsistent border size * (2020.09.18) Added `Remove All Chart Object` to Remove All child nodes under the Chart (automatically reinitialized) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0e9f02e9..24d5b859 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,7 @@ # 更新日志 +* (2020.11.12) 修复`LineChart`当类型为`Smooth`时数据过密情况下报错的问题 #101 * (2020.10.22) 完善`HeatmapChart`中`VisualMap`对`Piecewise`的支持 * (2020.09.22) 修复`PieChart`边框大小不一致的问题 * (2020.09.19) 发布`v1.6.1`版本 diff --git a/Runtime/Internal/Utility/ChartHelper.cs b/Runtime/Internal/Utility/ChartHelper.cs index 4ab92e44..8b60116f 100644 --- a/Runtime/Internal/Utility/ChartHelper.cs +++ b/Runtime/Internal/Utility/ChartHelper.cs @@ -341,9 +341,16 @@ namespace XCharts if (segment < 1) segment = (int)(dist / 0.5f); if (segment < 4) segment = 4; GetBezierList2(ref posList, sp, ep, segment, cp1, cp2); + if (posList.Count < 2) + { + posList.Clear(); + posList.Add(sp); + posList.Add(ep); + } } - public static void GetBezierListVertical(ref List posList, Vector3 sp, Vector3 ep, float smoothness = 2f, float k = 2.0f) + public static void GetBezierListVertical(ref List posList, Vector3 sp, Vector3 ep, + float smoothness = 2f, float k = 2.0f) { Vector3 dir = (ep - sp).normalized; float dist = Vector3.Distance(sp, ep); @@ -353,6 +360,12 @@ namespace XCharts cp2.x = ep.x; int segment = (int)(dist / (smoothness <= 0 ? 2f : smoothness)); GetBezierList2(ref posList, sp, ep, segment, cp1, cp2); + if (posList.Count < 2) + { + posList.Clear(); + posList.Add(sp); + posList.Add(ep); + } } public static List GetBezierList(Vector3 sp, Vector3 ep, int segment, Vector3 cp)