修复LineChart当类型为Smooth时数据过密情况下报错的问题 #101

This commit is contained in:
monitor1394
2020-11-12 09:23:10 +08:00
parent 34eb09e297
commit 438f98db68
3 changed files with 16 additions and 1 deletions

View File

@@ -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)

View File

@@ -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`版本

View File

@@ -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<Vector3> posList, Vector3 sp, Vector3 ep, float smoothness = 2f, float k = 2.0f)
public static void GetBezierListVertical(ref List<Vector3> 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<Vector3> GetBezierList(Vector3 sp, Vector3 ep, int segment, Vector3 cp)