From e8737ec50e0ae0a8838fbee1842e734a2f983993 Mon Sep 17 00:00:00 2001 From: monitor1394 Date: Fri, 18 Dec 2020 19:06:34 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D`Animation`=E4=B8=8D=E5=90=AF?= =?UTF-8?q?=E7=94=A8=E6=97=B6=E6=9B=B4=E6=96=B0=E6=95=B0=E6=8D=AE=E4=BC=9A?= =?UTF-8?q?=E5=AF=BC=E8=87=B4=E5=9B=BE=E8=A1=A8=E4=B8=80=E7=9B=B4=E5=88=B7?= =?UTF-8?q?=E6=96=B0=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Assets/XCharts/CHANGELOG-EN.md | 1 + Assets/XCharts/CHANGELOG.md | 1 + Assets/XCharts/Runtime/API/RingChart_API.cs | 11 +++-------- Assets/XCharts/Runtime/Component/Main/Serie.cs | 10 +++++++--- Assets/XCharts/Runtime/Component/Sub/SerieData.cs | 4 ++-- 5 files changed, 14 insertions(+), 13 deletions(-) diff --git a/Assets/XCharts/CHANGELOG-EN.md b/Assets/XCharts/CHANGELOG-EN.md index 1f1033e8..c60a5f34 100644 --- a/Assets/XCharts/CHANGELOG-EN.md +++ b/Assets/XCharts/CHANGELOG-EN.md @@ -1,6 +1,7 @@ # 更新日志 +* (2020.12.18) fixed an issue where updating data when `Animation` was not enabled caused the chart to keep refreshing * (2020.12.01) fixed an issue where a newly created chart on `Unity2020` could not be drawn properly * (2020.11.22) Release `v1.6.2` version * (2020.11.22) Fixed an issue where `LineChart` draws an exception when the data is too dense #99 diff --git a/Assets/XCharts/CHANGELOG.md b/Assets/XCharts/CHANGELOG.md index c3e69c1c..3eac657b 100644 --- a/Assets/XCharts/CHANGELOG.md +++ b/Assets/XCharts/CHANGELOG.md @@ -1,6 +1,7 @@ # 更新日志 +* (2020.12.18) 修复`Animation`不启用时更新数据会导致图表一直刷新的问题 * (2020.12.01) 修复`Unity2020`上新创建的图表无法正常绘制的问题 * (2020.11.22) 发布`v1.6.2`版本 * (2020.11.22) 修复`LineChart`在数据过于密集时折线绘制异常的问题 #99 diff --git a/Assets/XCharts/Runtime/API/RingChart_API.cs b/Assets/XCharts/Runtime/API/RingChart_API.cs index 15786f36..245dd802 100644 --- a/Assets/XCharts/Runtime/API/RingChart_API.cs +++ b/Assets/XCharts/Runtime/API/RingChart_API.cs @@ -24,11 +24,7 @@ public bool UpdateMax(int serieIndex, int dataIndex, float value) var serie = m_Series.GetSerie(serieIndex); if (serie != null) { - var serieData = serie.GetSerieData(dataIndex); - if (serieData != null) - { - return serieData.UpdateData(1, value, serie.animation.GetUpdateAnimationDuration()); - } + return serie.UpdateData(dataIndex, 1, value); } return false; } @@ -45,10 +41,9 @@ public bool UpdateMax(int serieIndex, float value) if (serie != null) { var flag = true; - foreach (var serieData in serie.data) + for (int i = 0; i < serie.dataCount; i++) { - if (!serieData.UpdateData(1, value, serie.animation.GetUpdateAnimationDuration())) - flag = false; + if (serie.UpdateData(i, 1, value)) flag = false; } return flag; } diff --git a/Assets/XCharts/Runtime/Component/Main/Serie.cs b/Assets/XCharts/Runtime/Component/Main/Serie.cs index 08264212..1b94ab18 100644 --- a/Assets/XCharts/Runtime/Component/Main/Serie.cs +++ b/Assets/XCharts/Runtime/Component/Main/Serie.cs @@ -1095,7 +1095,7 @@ public float yTotal { if (sdata.show) total += sdata.GetCurrData(1, animation.GetUpdateAnimationDuration()); - //total += sdata.GetData(1); + //total += sdata.GetData(1); } return total; } @@ -1504,7 +1504,9 @@ public bool UpdateData(int index, int dimension, float value) { if (index >= 0 && index < m_Data.Count) { - var flag = m_Data[index].UpdateData(dimension, value, animation.GetUpdateAnimationDuration()); + var animationOpen = animation.enable; + var animationDuration = animation.GetUpdateAnimationDuration(); + var flag = m_Data[index].UpdateData(dimension, value, animationOpen, animationDuration); if (flag) SetVerticesDirty(); return flag; } @@ -1524,8 +1526,10 @@ public bool UpdateData(int index, List values) if (index >= 0 && index < m_Data.Count && values != null) { var serieData = m_Data[index]; + var animationOpen = animation.enable; + var animationDuration = animation.GetUpdateAnimationDuration(); for (int i = 0; i < values.Count; i++) - serieData.UpdateData(i, values[i], animation.GetUpdateAnimationDuration()); + serieData.UpdateData(i, values[i], animationOpen, animationDuration); SetVerticesDirty(); return true; } diff --git a/Assets/XCharts/Runtime/Component/Sub/SerieData.cs b/Assets/XCharts/Runtime/Component/Sub/SerieData.cs index bfb93851..958978af 100644 --- a/Assets/XCharts/Runtime/Component/Sub/SerieData.cs +++ b/Assets/XCharts/Runtime/Component/Sub/SerieData.cs @@ -280,7 +280,7 @@ public float GetCurrData(int index, float animationDuration, bool inverse, float } } - public bool UpdateData(int dimension, float value, float animationDuration = 500f) + public bool UpdateData(int dimension, float value, bool updateAnimation, float animationDuration = 500f) { if (dimension >= 0 && dimension < data.Count) { @@ -288,7 +288,7 @@ public bool UpdateData(int dimension, float value, float animationDuration = 500 m_PreviousData[dimension] = GetCurrData(dimension, animationDuration); //m_PreviousData[dimension] = data[dimension];; m_DataUpdateTime[dimension] = Time.time; - m_DataUpdateFlag[dimension] = true; + m_DataUpdateFlag[dimension] = updateAnimation; data[dimension] = value; return true; }