Skip to content

Commit

Permalink
修复Animation不启用时更新数据会导致图表一直刷新的问题
Browse files Browse the repository at this point in the history
  • Loading branch information
monitor1394 committed Dec 18, 2020
1 parent 045e157 commit e8737ec
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 13 deletions.
1 change: 1 addition & 0 deletions Assets/XCharts/CHANGELOG-EN.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
1 change: 1 addition & 0 deletions Assets/XCharts/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@

# 更新日志

* (2020.12.18) 修复`Animation`不启用时更新数据会导致图表一直刷新的问题
* (2020.12.01) 修复`Unity2020`上新创建的图表无法正常绘制的问题
* (2020.11.22) 发布`v1.6.2`版本
* (2020.11.22) 修复`LineChart`在数据过于密集时折线绘制异常的问题 #99
Expand Down
11 changes: 3 additions & 8 deletions Assets/XCharts/Runtime/API/RingChart_API.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand All @@ -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;
}
Expand Down
10 changes: 7 additions & 3 deletions Assets/XCharts/Runtime/Component/Main/Serie.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down Expand Up @@ -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;
}
Expand All @@ -1524,8 +1526,10 @@ public bool UpdateData(int index, List<float> 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;
}
Expand Down
4 changes: 2 additions & 2 deletions Assets/XCharts/Runtime/Component/Sub/SerieData.cs
Original file line number Diff line number Diff line change
Expand Up @@ -280,15 +280,15 @@ 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)
{
CheckLastData();
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;
}
Expand Down

0 comments on commit e8737ec

Please sign in to comment.