mirror of
https://github.com/XCharts-Team/XCharts.git
synced 2026-05-22 00:20:18 +00:00
性能优化
This commit is contained in:
@@ -747,7 +747,7 @@ namespace XCharts
|
||||
m_TooltipLabel = label;
|
||||
m_TooltipLabelRect = label.GetComponent<RectTransform>();
|
||||
m_TooltipLabelText = label.GetComponentInChildren<Text>();
|
||||
m_TooltipLabel.SetActive(true);
|
||||
ChartHelper.SetActive(m_TooltipLabel, true);
|
||||
}
|
||||
|
||||
internal void SetTooltipLabelColor(Color bgColor, Color textColor)
|
||||
@@ -760,7 +760,7 @@ namespace XCharts
|
||||
{
|
||||
if (m_TooltipLabel && m_TooltipLabel.activeInHierarchy != flag)
|
||||
{
|
||||
m_TooltipLabel.SetActive(flag);
|
||||
ChartHelper.SetActive(m_TooltipLabel, flag);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1016,6 +1016,10 @@ namespace XCharts
|
||||
/// </summary>
|
||||
public void ClearData()
|
||||
{
|
||||
foreach (var serieData in m_Data)
|
||||
{
|
||||
SerieDataPool.Release(serieData);
|
||||
}
|
||||
m_Data.Clear();
|
||||
SetVerticesDirty();
|
||||
}
|
||||
@@ -1049,15 +1053,15 @@ namespace XCharts
|
||||
while (m_Data.Count > m_MaxCache)
|
||||
{
|
||||
m_NeedUpdateFilterData = true;
|
||||
SerieDataPool.Release(m_Data[0]);
|
||||
m_Data.RemoveAt(0);
|
||||
}
|
||||
}
|
||||
int xValue = m_Data.Count;
|
||||
var serieData = new SerieData()
|
||||
{
|
||||
data = new List<float>() { xValue, value },
|
||||
name = dataName
|
||||
};
|
||||
var serieData = SerieDataPool.Get();
|
||||
serieData.data.Add(xValue);
|
||||
serieData.data.Add(value);
|
||||
serieData.name = dataName;
|
||||
serieData.index = xValue;
|
||||
m_Data.Add(serieData);
|
||||
m_ShowDataDimension = 1;
|
||||
@@ -1087,19 +1091,11 @@ namespace XCharts
|
||||
/// <param name="maxDataNumber"></param>
|
||||
public SerieData AddXYData(float xValue, float yValue, string dataName = null)
|
||||
{
|
||||
if (m_MaxCache > 0)
|
||||
{
|
||||
while (m_Data.Count > m_MaxCache)
|
||||
{
|
||||
m_NeedUpdateFilterData = true;
|
||||
m_Data.RemoveAt(0);
|
||||
}
|
||||
}
|
||||
var serieData = new SerieData()
|
||||
{
|
||||
data = new List<float>() { xValue, yValue },
|
||||
name = dataName
|
||||
};
|
||||
CheckMaxCache();
|
||||
var serieData = SerieDataPool.Get();
|
||||
serieData.data.Add(xValue);
|
||||
serieData.data.Add(yValue);
|
||||
serieData.name = dataName;
|
||||
serieData.index = m_Data.Count;
|
||||
m_Data.Add(serieData);
|
||||
m_ShowDataDimension = 2;
|
||||
@@ -1128,16 +1124,9 @@ namespace XCharts
|
||||
}
|
||||
else
|
||||
{
|
||||
if (m_MaxCache > 0)
|
||||
{
|
||||
while (m_Data.Count > m_MaxCache)
|
||||
{
|
||||
m_NeedUpdateFilterData = true;
|
||||
m_Data.RemoveAt(0);
|
||||
}
|
||||
}
|
||||
CheckMaxCache();
|
||||
m_ShowDataDimension = valueList.Count;
|
||||
var serieData = new SerieData();
|
||||
var serieData = SerieDataPool.Get();
|
||||
serieData.name = dataName;
|
||||
serieData.index = m_Data.Count;
|
||||
for (int i = 0; i < valueList.Count; i++)
|
||||
@@ -1151,6 +1140,17 @@ namespace XCharts
|
||||
}
|
||||
}
|
||||
|
||||
private void CheckMaxCache()
|
||||
{
|
||||
if (m_MaxCache <= 0) return;
|
||||
while (m_Data.Count > m_MaxCache)
|
||||
{
|
||||
m_NeedUpdateFilterData = true;
|
||||
SerieDataPool.Release(m_Data[0]);
|
||||
m_Data.RemoveAt(0);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获得维度Y索引对应的数据
|
||||
/// </summary>
|
||||
@@ -1572,7 +1572,7 @@ namespace XCharts
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 设置指定index的数据图标的尺寸
|
||||
|
||||
@@ -229,7 +229,7 @@ namespace XCharts
|
||||
#if UNITY_EDITOR
|
||||
if (!Application.isPlaying) return true;
|
||||
#endif
|
||||
return !enable || m_IsEnd || (m_CurrDataProgress > m_DestDataProgress && m_CurrDetailProgress > m_DestDetailProgress);
|
||||
return !m_Enable || m_IsEnd || (m_CurrDataProgress > m_DestDataProgress && m_CurrDetailProgress > m_DestDetailProgress);
|
||||
}
|
||||
|
||||
public bool IsInDelay()
|
||||
|
||||
@@ -177,6 +177,17 @@ namespace XCharts
|
||||
private List<float> m_DataUpdateTime = new List<float>();
|
||||
private List<bool> m_DataUpdateFlag = new List<bool>();
|
||||
|
||||
public void Clear()
|
||||
{
|
||||
m_Name = string.Empty;
|
||||
m_Selected = false;
|
||||
m_Radius = 0;
|
||||
m_Data.Clear();
|
||||
m_PreviousData.Clear();
|
||||
m_DataUpdateTime.Clear();
|
||||
m_DataUpdateFlag.Clear();
|
||||
}
|
||||
|
||||
public float GetData(int index, bool inverse = false)
|
||||
{
|
||||
if (index >= 0 && index < m_Data.Count)
|
||||
|
||||
Reference in New Issue
Block a user