mirror of
https://github.com/XCharts-Team/XCharts.git
synced 2026-05-26 10:50:08 +00:00
[optimize] optimize interact and performance
This commit is contained in:
@@ -90,7 +90,8 @@ namespace XCharts.Runtime
|
||||
serie.context.pointerEnter = false;
|
||||
foreach (var serieData in serie.data)
|
||||
{
|
||||
if (serieData.context.rect.Contains(chart.pointerPos))
|
||||
if (serie.context.pointerAxisDataIndexs.Contains(serieData.index)
|
||||
|| serieData.context.rect.Contains(chart.pointerPos))
|
||||
{
|
||||
serie.context.pointerItemDataIndex = serieData.index;
|
||||
serie.context.pointerEnter = true;
|
||||
|
||||
@@ -25,11 +25,14 @@ namespace XCharts.Runtime
|
||||
{
|
||||
if (m_TargetValue != size)
|
||||
{
|
||||
needInteract = true;
|
||||
m_UpdateFlag = true;
|
||||
m_ValueEnable = true;
|
||||
m_UpdateTime = Time.time;
|
||||
m_PreviousValue = m_TargetValue;
|
||||
if (float.IsNaN(m_TargetValue))
|
||||
{
|
||||
needInteract = true;
|
||||
m_UpdateFlag = true;
|
||||
m_ValueEnable = true;
|
||||
m_UpdateTime = Time.time;
|
||||
m_PreviousValue = m_TargetValue;
|
||||
}
|
||||
m_TargetValue = size;
|
||||
}
|
||||
}
|
||||
@@ -38,11 +41,14 @@ namespace XCharts.Runtime
|
||||
{
|
||||
if (!ChartHelper.IsValueEqualsColor(color, m_TargetColor))
|
||||
{
|
||||
needInteract = true;
|
||||
m_UpdateFlag = true;
|
||||
m_ValueEnable = true;
|
||||
m_UpdateTime = Time.time;
|
||||
m_PreviousColor = m_TargetColor;
|
||||
if (!ChartHelper.IsClearColor(m_TargetColor))
|
||||
{
|
||||
needInteract = true;
|
||||
m_UpdateFlag = true;
|
||||
m_ValueEnable = true;
|
||||
m_UpdateTime = Time.time;
|
||||
m_PreviousColor = m_TargetColor;
|
||||
}
|
||||
m_TargetColor = color;
|
||||
}
|
||||
}
|
||||
@@ -51,11 +57,14 @@ namespace XCharts.Runtime
|
||||
SetColor(ref needInteract, color);
|
||||
if (!ChartHelper.IsValueEqualsColor(toColor, m_TargetToColor))
|
||||
{
|
||||
needInteract = true;
|
||||
m_UpdateFlag = true;
|
||||
m_ValueEnable = true;
|
||||
m_UpdateTime = Time.time;
|
||||
m_PreviousToColor = m_TargetToColor;
|
||||
if (!ChartHelper.IsClearColor(m_TargetToColor))
|
||||
{
|
||||
needInteract = true;
|
||||
m_UpdateFlag = true;
|
||||
m_ValueEnable = true;
|
||||
m_UpdateTime = Time.time;
|
||||
m_PreviousToColor = m_TargetToColor;
|
||||
}
|
||||
m_TargetToColor = toColor;
|
||||
}
|
||||
}
|
||||
@@ -179,7 +188,13 @@ namespace XCharts.Runtime
|
||||
|
||||
public void Reset()
|
||||
{
|
||||
m_UpdateFlag = false;
|
||||
m_ValueEnable = false;
|
||||
m_PreviousValue = float.NaN;
|
||||
m_TargetColor = ColorUtil.clearColor32;
|
||||
m_TargetToColor = ColorUtil.clearColor32;
|
||||
m_PreviousColor = ColorUtil.clearColor32;
|
||||
m_PreviousToColor = ColorUtil.clearColor32;
|
||||
}
|
||||
|
||||
private bool IsValueEnable()
|
||||
|
||||
@@ -120,11 +120,8 @@ namespace XCharts.Runtime
|
||||
m_Name = string.Empty;
|
||||
m_Show = true;
|
||||
m_Selected = false;
|
||||
context.canShowLabel = true;
|
||||
context.highlight = false;
|
||||
context.children.Clear();
|
||||
context.dataPoints.Clear();
|
||||
m_Radius = 0;
|
||||
context.Reset();
|
||||
interact.Reset();
|
||||
m_Data.Clear();
|
||||
m_PreviousData.Clear();
|
||||
|
||||
@@ -36,7 +36,6 @@ namespace XCharts.Runtime
|
||||
public Vector3 position;
|
||||
public List<Vector3> dataPoints = new List<Vector3>();
|
||||
public List<SerieData> children = new List<SerieData>();
|
||||
|
||||
/// <summary>
|
||||
/// 绘制区域。
|
||||
/// </summary>
|
||||
@@ -50,7 +49,6 @@ namespace XCharts.Runtime
|
||||
public Vector3 offsetCenter;
|
||||
public float stackHeight;
|
||||
public bool isClip;
|
||||
|
||||
public bool canShowLabel = true;
|
||||
public Image symbol;
|
||||
/// <summary>
|
||||
@@ -58,5 +56,17 @@ namespace XCharts.Runtime
|
||||
/// |该数据项是否被高亮,一般由鼠标悬停或图例悬停触发高亮。
|
||||
/// </summary>
|
||||
public bool highlight;
|
||||
|
||||
public void Reset()
|
||||
{
|
||||
canShowLabel = true;
|
||||
highlight = false;
|
||||
parent = null;
|
||||
symbol = null;
|
||||
rect = Rect.zero;
|
||||
subRect = Rect.zero;
|
||||
children.Clear();
|
||||
dataPoints.Clear();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user