Skip to content

Commit

Permalink
Fixed the problem of displaying exceptions after adding data again wh…
Browse files Browse the repository at this point in the history
…en `DataZoom` is enable (#163)
  • Loading branch information
monitor1394 committed Aug 16, 2021
1 parent 3590d1e commit d87e0f8
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 3 deletions.
1 change: 1 addition & 0 deletions Assets/XCharts/CHANGELOG-EN.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@

## master

* (2021.08.15) Fixed the problem of displaying exceptions after adding data again when `DataZoom` is enable (#163)
* (2021.08.15) Improved `Axis`'s `AxisLabel` text rotate setting to avoid inconsistency offset in `DataZoom` (#163)
* (2021.08.14) Added `Legend`'s `textAutoColor` to set the text color match with `Serie` color (#163)
* (2021.08.12) Optimize `BarChart` setting `Corner` when the positive and negative columns are fillet symmetric
Expand Down
1 change: 1 addition & 0 deletions Assets/XCharts/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@

## master

* (2021.08.15) 修复`DataZoom`开启时重新添加数据后图表数据显示异常的问题 (#163)
* (2021.08.15) 优化`Axis``AxisLabel`文本旋转设置,避免在DataZoom开启时偏移不一致 (#163)
* (2021.08.14) 增加`Legend``textAutoColor`设置文本颜色和`Serie`一致 (#163)
* (2021.08.12) 优化`BarChart`设置`Corner`时正负柱条圆角对称
Expand Down
19 changes: 16 additions & 3 deletions Assets/XCharts/Examples/Runtime/Example_Test.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,22 @@ void Update()

void OnTestBtn()
{
int index = Random.Range(0, chart.series.Count);
var serie = chart.series.GetSerie(index);
chart.UpdateData(index, Random.Range(0, serie.dataCount), Random.Range(50, 100));
object[][] m_TestData = new object[][]{
new object[]{"01/06/20", 2.2d, 5.6d},
new object[]{"22/06/20", 2.4d, 5.3d},
new object[]{"04/08/21", 4.5d, 5.4d},
new object[]{"05/08/21", 6.3d, 6.4d},
new object[]{"06/08/21", 3.1d, 6.4d},
new object[]{"09/08/21", 3.9d, 6.3d},
new object[]{"10/08/21", 1.9d, 4.6d},
};
chart.ClearData();
foreach (var list in m_TestData)
{
chart.AddXAxisData((string)list[0]);
chart.AddData(0, (double)list[1]);
chart.AddData(1, (double)list[2]);
}
}

void AddData()
Expand Down
3 changes: 3 additions & 0 deletions Assets/XCharts/Runtime/Component/Main/Serie.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1355,6 +1355,7 @@ public void ClearData()
RemoveData(0);
}
m_Data.Clear();
m_NeedUpdateFilterData = true;
SetVerticesDirty();
}

Expand Down Expand Up @@ -1388,6 +1389,7 @@ public void RemoveData(int index)
m_DownSmoothPoints.Remove(serieData.index);
}
m_Data.RemoveAt(index);
m_NeedUpdateFilterData = true;
}
}

Expand Down Expand Up @@ -1416,6 +1418,7 @@ private void AddSerieDataHeadOrTail(SerieData serieData)
{
if (m_InsertDataToHead) m_Data.Insert(0, serieData);
else m_Data.Add(serieData);
m_NeedUpdateFilterData = true;
}

private void CheckDataName(string dataName)
Expand Down

0 comments on commit d87e0f8

Please sign in to comment.