diff --git a/Runtime/Component/Axis/AxisContext.cs b/Runtime/Component/Axis/AxisContext.cs
index d3f77c62..890fdbca 100644
--- a/Runtime/Component/Axis/AxisContext.cs
+++ b/Runtime/Component/Axis/AxisContext.cs
@@ -7,43 +7,43 @@ namespace XCharts.Runtime
{
public class AxisContext : MainComponentContext
{
- internal Orient orient { get; set; }
- public float x { get; internal set; }
- public float y { get; internal set; }
- public float width { get; internal set; }
- public float height { get; internal set; }
- public Vector3 position { get; internal set; }
- public float left { get; internal set; }
- public float right { get; internal set; }
- public float bottom { get; internal set; }
- public float top { get; internal set; }
+ public Orient orient;
+ public float x;
+ public float y;
+ public float width;
+ public float height;
+ public Vector3 position;
+ public float left;
+ public float right;
+ public float bottom;
+ public float top;
///
/// the current minimun value.
/// |当前最小值。
///
- public double minValue { get; internal set; }
+ public double minValue;
///
/// the current maximum value.
/// |当前最大值。
///
- public double maxValue { get; internal set; }
+ public double maxValue;
///
/// the offset of zero position.
/// |坐标轴原点在坐标轴的偏移。
///
- public float offset { get; internal set; }
- public double minMaxRange { get; internal set; }
- public float scaleWidth { get; internal set; }
- public float startAngle { get; set; }
- public double pointerValue { get; internal set; }
- public Vector3 pointerLabelPosition { get; internal set; }
- public double axisTooltipValue { get; internal set; }
+ public float offset;
+ public double minMaxRange;
+ public float scaleWidth;
+ public float startAngle;
+ public double pointerValue;
+ public Vector3 pointerLabelPosition;
+ public double axisTooltipValue;
public List runtimeData { get { return m_RuntimeData; } }
public List labelValueList { get { return m_LabelValueList; } }
public List labelObjectList { get { return m_AxisLabelList; } }
internal List filterData;
- internal bool lastCheckInverse { get; set; }
+ internal bool lastCheckInverse;
internal bool isNeedUpdateFilterData;
private int filterStart;
diff --git a/Runtime/Component/Axis/AxisHandler.cs b/Runtime/Component/Axis/AxisHandler.cs
index 39e3b715..007d165e 100644
--- a/Runtime/Component/Axis/AxisHandler.cs
+++ b/Runtime/Component/Axis/AxisHandler.cs
@@ -34,7 +34,7 @@ namespace XCharts
return;
if (!grid.context.isPointerEnter)
{
- axis.context.pointerValue = 0;
+ axis.context.pointerValue = double.PositiveInfinity;
}
else
{
diff --git a/Runtime/Component/Axis/RadiusAxis/RadiusAxisHandler.cs b/Runtime/Component/Axis/RadiusAxis/RadiusAxisHandler.cs
index 87721d89..c5e0d742 100644
--- a/Runtime/Component/Axis/RadiusAxis/RadiusAxisHandler.cs
+++ b/Runtime/Component/Axis/RadiusAxis/RadiusAxisHandler.cs
@@ -36,12 +36,11 @@ namespace XCharts.Runtime
axis.context.pointerValue = double.PositiveInfinity;
return;
}
+
var angleAxis = ComponentHelper.GetAngleAxis(chart.components, polar.index);
if (angleAxis == null)
return;
- var startAngle = angleAxis.context.startAngle;
-
var dist = Vector3.Distance(chart.pointerPos, polar.context.center);
axis.context.pointerValue = axis.context.minValue + (dist / polar.context.radius) * axis.context.minMaxRange;
axis.context.pointerLabelPosition = GetLabelPosition(polar, axis, angleAxis.context.startAngle, dist);
diff --git a/Runtime/Component/Child/ItemStyle.cs b/Runtime/Component/Child/ItemStyle.cs
index aee4828b..4d9a3abb 100644
--- a/Runtime/Component/Child/ItemStyle.cs
+++ b/Runtime/Component/Child/ItemStyle.cs
@@ -231,6 +231,16 @@ namespace XCharts.Runtime
return color;
}
+ public Color32 GetToColor()
+ {
+ if (m_Opacity == 1 || m_ToColor.a == 0)
+ return m_ToColor;
+
+ var color = m_ToColor;
+ color.a = (byte)(color.a * m_Opacity);
+ return color;
+ }
+
public Color32 GetColor0()
{
if (m_Opacity == 1 || m_Color0.a == 0)
diff --git a/Runtime/Component/Tooltip/TooltipHandler.cs b/Runtime/Component/Tooltip/TooltipHandler.cs
index 481bb02a..62569098 100644
--- a/Runtime/Component/Tooltip/TooltipHandler.cs
+++ b/Runtime/Component/Tooltip/TooltipHandler.cs
@@ -179,6 +179,7 @@ namespace XCharts.Runtime
private void SetTooltipIndicatorLabel(Axis axis, ChartLabel label)
{
if (label == null) return;
+ if (double.IsPositiveInfinity(axis.context.pointerValue)) return;
label.SetActive(true);
label.SetLabelActive(true);
label.SetPosition(axis.context.pointerLabelPosition);
@@ -234,7 +235,6 @@ namespace XCharts.Runtime
private void UpdateAxisPointerDataIndex(Serie serie, XAxis xAxis, YAxis yAxis, GridCoord grid, bool isTriggerAxis)
{
-
serie.context.pointerAxisDataIndexs.Clear();
if (yAxis.IsCategory())
{
diff --git a/Runtime/Coord/Grid/GridCoordContext.cs b/Runtime/Coord/Grid/GridCoordContext.cs
index 43d2220b..251766fa 100644
--- a/Runtime/Coord/Grid/GridCoordContext.cs
+++ b/Runtime/Coord/Grid/GridCoordContext.cs
@@ -3,18 +3,18 @@ using UnityEngine;
namespace XCharts.Runtime
{
- public class GridCoordContext : MainComponentContext, IRectContext
+ public class GridCoordContext : MainComponentContext
{
- public float x { get; internal set; }
- public float y { get; internal set; }
- public float width { get; internal set; }
- public float height { get; internal set; }
- public Vector3 position { get; internal set; }
- public Vector3 center { get; internal set; }
- public float left { get; internal set; }
- public float right { get; internal set; }
- public float bottom { get; internal set; }
- public float top { get; internal set; }
- public bool isPointerEnter { get; set; }
+ public float x;
+ public float y;
+ public float width;
+ public float height;
+ public Vector3 position;
+ public Vector3 center;
+ public float left;
+ public float right;
+ public float bottom;
+ public float top;
+ public bool isPointerEnter;
}
}
\ No newline at end of file
diff --git a/Runtime/Coord/Parallel/ParallelCoordContext.cs b/Runtime/Coord/Parallel/ParallelCoordContext.cs
index ba965e13..2901f84f 100644
--- a/Runtime/Coord/Parallel/ParallelCoordContext.cs
+++ b/Runtime/Coord/Parallel/ParallelCoordContext.cs
@@ -6,16 +6,16 @@ namespace XCharts.Runtime
{
public class ParallelCoordContext : MainComponentContext
{
- public float x { get; internal set; }
- public float y { get; internal set; }
- public float width { get; internal set; }
- public float height { get; internal set; }
- public Vector3 position { get; internal set; }
- public float left { get; internal set; }
- public float right { get; internal set; }
- public float bottom { get; internal set; }
- public float top { get; internal set; }
- public bool runtimeIsPointerEnter { get; set; }
+ public float x;
+ public float y;
+ public float width;
+ public float height;
+ public Vector3 position;
+ public float left;
+ public float right;
+ public float bottom;
+ public float top;
+ public bool runtimeIsPointerEnter;
internal List parallelAxes = new List();
}
}
\ No newline at end of file
diff --git a/Runtime/Coord/Polar/PolarCoordContext.cs b/Runtime/Coord/Polar/PolarCoordContext.cs
index 4fed70df..20b67c4e 100644
--- a/Runtime/Coord/Polar/PolarCoordContext.cs
+++ b/Runtime/Coord/Polar/PolarCoordContext.cs
@@ -10,12 +10,12 @@ namespace XCharts.Runtime
/// the center position of polar in container.
/// |极坐标在容器中的具体中心点。
///
- public Vector3 center { get; internal set; }
+ public Vector3 center;
///
/// the true radius of polar.
/// |极坐标的运行时实际半径。
///
- public float radius { get; internal set; }
- public bool isPointerEnter { get; set; }
+ public float radius;
+ public bool isPointerEnter;
}
}
\ No newline at end of file
diff --git a/Runtime/Helper/SerieHelper.cs b/Runtime/Helper/SerieHelper.cs
index d8c50c64..efd45160 100644
--- a/Runtime/Helper/SerieHelper.cs
+++ b/Runtime/Helper/SerieHelper.cs
@@ -277,90 +277,71 @@ namespace XCharts.Runtime
public static Color32 GetItemColor(Serie serie, SerieData serieData, ThemeStyle theme, int index, bool highlight)
{
- if (serie == null) return ChartConst.clearColor32;
+ if (serie == null)
+ return ChartConst.clearColor32;
+
+ ItemStyle itemStyle = null;
if (highlight)
- {
- var itemStyleEmphasis = GetItemStyleEmphasis(serie, serieData);
- if (itemStyleEmphasis != null && !ChartHelper.IsClearColor(itemStyleEmphasis.color))
- {
- var color = itemStyleEmphasis.color;
- ChartHelper.SetColorOpacity(ref color, itemStyleEmphasis.opacity);
- return color;
- }
- }
- var itemStyle = GetItemStyle(serie, serieData);
- if (!ChartHelper.IsClearColor(itemStyle.color))
- {
- return itemStyle.GetColor();
- }
- else
- {
- var color = theme.GetColor(index);
- if (highlight) color = ChartHelper.GetHighlightColor(color);
- ChartHelper.SetColorOpacity(ref color, itemStyle.opacity);
- return color;
- }
+ itemStyle = GetItemStyleEmphasis(serie, serieData);
+ if (itemStyle == null)
+ itemStyle = GetItemStyle(serie, serieData);
+
+ var color = ChartHelper.IsClearColor(itemStyle.color)
+ ? theme.GetColor(index)
+ : itemStyle.color;
+
+ if (highlight)
+ color = ChartHelper.GetHighlightColor(color);
+
+ ChartHelper.SetColorOpacity(ref color, itemStyle.opacity);
+ return color;
}
public static Color32 GetItemColor0(Serie serie, SerieData serieData, ThemeStyle theme, bool highlight, Color32 defaultColor)
{
- if (serie == null) return ChartConst.clearColor32;
+ if (serie == null)
+ return ChartConst.clearColor32;
+
+ ItemStyle itemStyle = null;
if (highlight)
- {
- var itemStyleEmphasis = GetItemStyleEmphasis(serie, serieData);
- if (itemStyleEmphasis != null && !ChartHelper.IsClearColor(itemStyleEmphasis.color))
- {
- var color = itemStyleEmphasis.color0;
- ChartHelper.SetColorOpacity(ref color, itemStyleEmphasis.opacity);
- return color;
- }
- }
- var itemStyle = GetItemStyle(serie, serieData);
- if (!ChartHelper.IsClearColor(itemStyle.color0))
- {
- return itemStyle.GetColor0();
- }
- else
- {
- var color = defaultColor;
- if (highlight) color = ChartHelper.GetHighlightColor(color);
- ChartHelper.SetColorOpacity(ref color, itemStyle.opacity);
- return color;
- }
+ itemStyle = GetItemStyleEmphasis(serie, serieData);
+ if (itemStyle == null)
+ itemStyle = GetItemStyle(serie, serieData);
+
+ var color = ChartHelper.IsClearColor(itemStyle.color0)
+ ? defaultColor
+ : itemStyle.color0;
+
+ if (highlight)
+ color = ChartHelper.GetHighlightColor(color);
+
+ ChartHelper.SetColorOpacity(ref color, itemStyle.opacity);
+ return color;
}
public static Color32 GetItemToColor(Serie serie, SerieData serieData, ThemeStyle theme, int index, bool highlight)
{
+ if (serie == null)
+ return ChartConst.clearColor32;
+
+ ItemStyle itemStyle = null;
if (highlight)
+ itemStyle = GetItemStyleEmphasis(serie, serieData);
+ if (itemStyle == null)
+ itemStyle = GetItemStyle(serie, serieData);
+
+ var color = itemStyle.toColor;
+ if (ChartHelper.IsClearColor(color))
{
- var itemStyleEmphasis = GetItemStyleEmphasis(serie, serieData);
- if (itemStyleEmphasis != null && !ChartHelper.IsClearColor(itemStyleEmphasis.toColor))
- {
- return itemStyleEmphasis.GetColor();
- }
- }
- var itemStyle = GetItemStyle(serie, serieData, highlight);
- if (itemStyle == null) itemStyle = serieData.itemStyle;
- if (!ChartHelper.IsClearColor(itemStyle.toColor))
- {
- var color = itemStyle.toColor;
- if (highlight) color = ChartHelper.GetHighlightColor(color);
- ChartHelper.SetColorOpacity(ref color, itemStyle.opacity);
- return color;
- }
- if (!ChartHelper.IsClearColor(itemStyle.color))
- {
- var color = itemStyle.color;
- if (highlight) color = ChartHelper.GetHighlightColor(color);
- ChartHelper.SetColorOpacity(ref color, itemStyle.opacity);
- return color;
- }
- else
- {
- var color = theme.GetColor(index);
- if (highlight) color = ChartHelper.GetHighlightColor(color);
- ChartHelper.SetColorOpacity(ref color, itemStyle.opacity);
- return color;
+ color = ChartHelper.IsClearColor(itemStyle.color)
+ ? theme.GetColor(index)
+ : itemStyle.color;
}
+
+ if (highlight)
+ color = ChartHelper.GetHighlightColor(color);
+
+ ChartHelper.SetColorOpacity(ref color, itemStyle.opacity);
+ return color;
}
public static bool IsDownPoint(Serie serie, int index)
diff --git a/Runtime/Internal/Misc/IRectContext.cs b/Runtime/Internal/Misc/IRectContext.cs
deleted file mode 100644
index 15b37fcd..00000000
--- a/Runtime/Internal/Misc/IRectContext.cs
+++ /dev/null
@@ -1,14 +0,0 @@
-
-using UnityEngine;
-
-namespace XCharts.Runtime
-{
- public interface IRectContext
- {
- float x { get; }
- float y { get; }
- float width { get; }
- float height { get; }
- Vector3 position { get; }
- }
-}
\ No newline at end of file
diff --git a/Runtime/Internal/Misc/IRectContext.cs.meta b/Runtime/Internal/Misc/IRectContext.cs.meta
deleted file mode 100644
index 4c981138..00000000
--- a/Runtime/Internal/Misc/IRectContext.cs.meta
+++ /dev/null
@@ -1,11 +0,0 @@
-fileFormatVersion: 2
-guid: 6e994b64b93384ae4bfa9a7a85ba8914
-MonoImporter:
- externalObjects: {}
- serializedVersion: 2
- defaultReferences: []
- executionOrder: 0
- icon: {instanceID: 0}
- userData:
- assetBundleName:
- assetBundleVariant:
diff --git a/Runtime/Serie/Bar/BarHandler.cs b/Runtime/Serie/Bar/BarHandler.cs
index 10f2ad39..3bc51638 100644
--- a/Runtime/Serie/Bar/BarHandler.cs
+++ b/Runtime/Serie/Bar/BarHandler.cs
@@ -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;
diff --git a/Runtime/Serie/InteractData.cs b/Runtime/Serie/InteractData.cs
index 43343e89..c61bd060 100644
--- a/Runtime/Serie/InteractData.cs
+++ b/Runtime/Serie/InteractData.cs
@@ -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()
diff --git a/Runtime/Serie/SerieData.cs b/Runtime/Serie/SerieData.cs
index 8be1f983..b10b0e16 100644
--- a/Runtime/Serie/SerieData.cs
+++ b/Runtime/Serie/SerieData.cs
@@ -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();
diff --git a/Runtime/Serie/SerieDataContext.cs b/Runtime/Serie/SerieDataContext.cs
index 9299b176..319b6f1d 100644
--- a/Runtime/Serie/SerieDataContext.cs
+++ b/Runtime/Serie/SerieDataContext.cs
@@ -36,7 +36,6 @@ namespace XCharts.Runtime
public Vector3 position;
public List dataPoints = new List();
public List children = new List();
-
///
/// 绘制区域。
///
@@ -50,7 +49,6 @@ namespace XCharts.Runtime
public Vector3 offsetCenter;
public float stackHeight;
public bool isClip;
-
public bool canShowLabel = true;
public Image symbol;
///
@@ -58,5 +56,17 @@ namespace XCharts.Runtime
/// |该数据项是否被高亮,一般由鼠标悬停或图例悬停触发高亮。
///
public bool highlight;
+
+ public void Reset()
+ {
+ canShowLabel = true;
+ highlight = false;
+ parent = null;
+ symbol = null;
+ rect = Rect.zero;
+ subRect = Rect.zero;
+ children.Clear();
+ dataPoints.Clear();
+ }
}
}
\ No newline at end of file