重构minShowDataNumber、maxShowDataNumber、maxCacheDataNumber到Serie的minShow、maxShow、maxCache

This commit is contained in:
monitor1394
2019-09-29 07:37:53 +08:00
parent c54d62c8f8
commit 2a1ad8886e
14 changed files with 118 additions and 112 deletions

View File

@@ -96,6 +96,7 @@ namespace XCharts
[SerializeField] protected bool m_ShowSplitLine = false;
[SerializeField] protected SplitLineType m_SplitLineType = SplitLineType.Dashed;
[SerializeField] protected bool m_BoundaryGap = true;
[SerializeField] protected int m_MaxCache = 0;
[SerializeField] protected List<string> m_Data = new List<string>();
[SerializeField] protected AxisLine m_AxisLine = AxisLine.defaultAxisLine;
[SerializeField] protected AxisName m_AxisName = AxisName.defaultAxisName;
@@ -156,6 +157,12 @@ namespace XCharts
/// </summary>
public bool boundaryGap { get { return m_BoundaryGap; } set { m_BoundaryGap = value; } }
/// <summary>
/// The max number of axis data cache.
/// The first data will be remove when the size of axis data is larger then maxCache.
/// 可缓存的最大数据量。默认为0没有限制大于0时超过指定值会移除旧数据再插入新数据。
/// </summary>
public int maxCache { get { return m_MaxCache; } set { m_MaxCache = value < 0 ? 0 : value; } }
/// <summary>
/// Category data, available in type: 'Category' axis.
/// 类目数据在类目轴type: 'category')中有效。
/// </summary>
@@ -268,12 +275,11 @@ namespace XCharts
/// 添加一个类目到类目数据列表
/// </summary>
/// <param name="category"></param>
/// <param name="maxDataNumber"></param>
public void AddData(string category, int maxDataNumber)
public void AddData(string category)
{
if (maxDataNumber > 0)
if (maxCache > 0)
{
while (m_Data.Count > maxDataNumber) m_Data.RemoveAt(0);
while (m_Data.Count > maxCache) m_Data.RemoveAt(0);
}
m_Data.Add(category);
}