mirror of
https://github.com/XCharts-Team/XCharts.git
synced 2026-05-22 08:50:10 +00:00
[refactor] refactor symbol and label
This commit is contained in:
@@ -4,6 +4,9 @@ using UnityEngine;
|
||||
|
||||
namespace XCharts.Runtime
|
||||
{
|
||||
/// <summary>
|
||||
/// 标签的引导线
|
||||
/// </summary>
|
||||
[System.Serializable]
|
||||
public class LabelLine : ChildComponent, ISerieExtraComponent, ISerieDataComponent
|
||||
{
|
||||
@@ -29,16 +32,20 @@ namespace XCharts.Runtime
|
||||
[SerializeField] private bool m_Show = true;
|
||||
[SerializeField] private LineType m_LineType = LineType.BrokenLine;
|
||||
[SerializeField] private Color32 m_LineColor = ChartConst.clearColor32;
|
||||
[SerializeField] private float m_LineAngle = 0;
|
||||
[SerializeField] private float m_LineWidth = 1.0f;
|
||||
[SerializeField] private float m_LineGap = 1.0f;
|
||||
[SerializeField] private float m_LineLength1 = 25f;
|
||||
[SerializeField] private float m_LineLength2 = 15f;
|
||||
[SerializeField] private SymbolStyle m_StartSymbol = new SymbolStyle() { type = SymbolType.Circle, size = 3 };
|
||||
[SerializeField] private SymbolStyle m_EndSymbol = new SymbolStyle() { type = SymbolType.Circle, size = 3 };
|
||||
|
||||
public void Reset()
|
||||
{
|
||||
m_Show = false;
|
||||
m_LineType = LineType.BrokenLine;
|
||||
m_LineColor = Color.clear;
|
||||
m_LineAngle = 0;
|
||||
m_LineWidth = 1.0f;
|
||||
m_LineGap = 1.0f;
|
||||
m_LineLength1 = 25f;
|
||||
@@ -73,6 +80,15 @@ namespace XCharts.Runtime
|
||||
set { if (PropertyUtil.SetStruct(ref m_LineColor, value)) SetVerticesDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// the angle of visual guild line.
|
||||
/// |视觉引导线的固定角度。对折线和曲线有效。
|
||||
/// </summary>
|
||||
public float lineAngle
|
||||
{
|
||||
get { return m_LineAngle; }
|
||||
set { if (PropertyUtil.SetStruct(ref m_LineAngle, value)) SetVerticesDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// the width of visual guild line.
|
||||
/// |视觉引导线的宽度。
|
||||
/// </summary>
|
||||
@@ -108,5 +124,23 @@ namespace XCharts.Runtime
|
||||
get { return m_LineLength2; }
|
||||
set { if (PropertyUtil.SetStruct(ref m_LineLength2, value)) SetVerticesDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// The symbol of the start point of labelline.
|
||||
/// |起始点的图形标记。
|
||||
/// </summary>
|
||||
public SymbolStyle startSymbol
|
||||
{
|
||||
get { return m_StartSymbol; }
|
||||
set { if (PropertyUtil.SetClass(ref m_StartSymbol, value)) SetVerticesDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// The symbol of the end point of labelline.
|
||||
/// |结束点的图形标记。
|
||||
/// </summary>
|
||||
public SymbolStyle endSymbol
|
||||
{
|
||||
get { return m_EndSymbol; }
|
||||
set { if (PropertyUtil.SetClass(ref m_EndSymbol, value)) SetVerticesDirty(); }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -244,7 +244,12 @@ namespace XCharts.Runtime
|
||||
|
||||
public bool IsInside()
|
||||
{
|
||||
return position == Position.Inside || position == Position.Center;
|
||||
return m_Position == Position.Inside || m_Position == Position.Center;
|
||||
}
|
||||
|
||||
public bool IsDefaultPosition(Position position)
|
||||
{
|
||||
return m_Position == Position.Default || m_Position == position;
|
||||
}
|
||||
|
||||
public bool IsAutoSize()
|
||||
|
||||
33
Runtime/Component/Child/SerieDataBaseInfo.cs
Normal file
33
Runtime/Component/Child/SerieDataBaseInfo.cs
Normal file
@@ -0,0 +1,33 @@
|
||||
using UnityEngine;
|
||||
|
||||
namespace XCharts.Runtime
|
||||
{
|
||||
/// <summary>
|
||||
/// 数据项的其他基础数据。
|
||||
/// </summary>
|
||||
[System.Serializable]
|
||||
public class SerieDataBaseInfo : ChildComponent, ISerieDataComponent
|
||||
{
|
||||
[SerializeField] private bool m_Ignore = false;
|
||||
[SerializeField] private bool m_Selected;
|
||||
[SerializeField] private float m_Radius;
|
||||
|
||||
/// <summary>
|
||||
/// 是否忽略数据。当为 true 时,数据不进行绘制。
|
||||
/// </summary>
|
||||
public bool ignore
|
||||
{
|
||||
get { return m_Ignore; }
|
||||
set { if (PropertyUtil.SetStruct(ref m_Ignore, value)) SetVerticesDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// 自定义半径。可用在饼图中自定义某个数据项的半径。
|
||||
/// </summary>
|
||||
public float radius { get { return m_Radius; } set { m_Radius = value; } }
|
||||
/// <summary>
|
||||
/// Whether the data item is selected.
|
||||
/// |该数据项是否被选中。
|
||||
/// </summary>
|
||||
public bool selected { get { return m_Selected; } set { m_Selected = value; } }
|
||||
}
|
||||
}
|
||||
11
Runtime/Component/Child/SerieDataBaseInfo.cs.meta
Normal file
11
Runtime/Component/Child/SerieDataBaseInfo.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a6d8757fbd847419aaed450e020e827c
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
242
Runtime/Component/Child/SerieSymbl.cs
Normal file
242
Runtime/Component/Child/SerieSymbl.cs
Normal file
@@ -0,0 +1,242 @@
|
||||
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
namespace XCharts.Runtime
|
||||
{
|
||||
/// <summary>
|
||||
/// The way to get serie symbol size.
|
||||
/// |获取标记图形大小的方式。
|
||||
/// </summary>
|
||||
public enum SymbolSizeType
|
||||
{
|
||||
/// <summary>
|
||||
/// Specify constant for symbol size.
|
||||
/// |自定义大小。
|
||||
/// </summary>
|
||||
Custom,
|
||||
/// <summary>
|
||||
/// Specify the dataIndex and dataScale to calculate symbol size.
|
||||
/// |通过 dataIndex 从数据中获取,再乘以一个比例系数 dataScale 。
|
||||
/// </summary>
|
||||
FromData,
|
||||
/// <summary>
|
||||
/// Specify function for symbol size.
|
||||
/// |通过委托函数获取。
|
||||
/// </summary>
|
||||
Function,
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 系列数据项的标记的图形
|
||||
/// </summary>
|
||||
[System.Serializable]
|
||||
public class SerieSymbol : SymbolStyle, ISerieDataComponent
|
||||
{
|
||||
[SerializeField] private SymbolSizeType m_SizeType = SymbolSizeType.Custom;
|
||||
[SerializeField] private float m_SelectedSize = 0f;
|
||||
[SerializeField] private int m_DataIndex = 1;
|
||||
[SerializeField] private float m_DataScale = 1;
|
||||
[SerializeField] private float m_SelectedDataScale = 1.5f;
|
||||
[SerializeField] private SymbolSizeFunction m_SizeFunction;
|
||||
[SerializeField] private SymbolSizeFunction m_SelectedSizeFunction;
|
||||
[SerializeField] private int m_StartIndex;
|
||||
[SerializeField] private int m_Interval;
|
||||
[SerializeField] private bool m_ForceShowLast = false;
|
||||
[SerializeField] private bool m_Repeat = false;
|
||||
|
||||
public override void Reset()
|
||||
{
|
||||
base.Reset();
|
||||
m_SizeType = SymbolSizeType.Custom;
|
||||
m_SelectedSize = 0f;
|
||||
m_DataIndex = 1;
|
||||
m_DataScale = 1;
|
||||
m_SelectedDataScale = 1.5f;
|
||||
m_SizeFunction = null;
|
||||
m_SelectedSizeFunction = null;
|
||||
m_StartIndex = 0;
|
||||
m_Interval = 0;
|
||||
m_ForceShowLast = false;
|
||||
m_Repeat = false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// the type of symbol size.
|
||||
/// |标记图形的大小获取方式。
|
||||
/// </summary>
|
||||
public SymbolSizeType sizeType
|
||||
{
|
||||
get { return m_SizeType; }
|
||||
set { if (PropertyUtil.SetStruct(ref m_SizeType, value)) SetVerticesDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// the size of selected symbol.
|
||||
/// |被选中的标记的大小。
|
||||
/// </summary>
|
||||
public float selectedSize
|
||||
{
|
||||
get { return m_SelectedSize; }
|
||||
set { if (PropertyUtil.SetStruct(ref m_SelectedSize, value)) SetVerticesDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// whitch data index is when the sizeType assined as FromData.
|
||||
/// |当sizeType指定为FromData时,指定的数据源索引。
|
||||
/// </summary>
|
||||
public int dataIndex
|
||||
{
|
||||
get { return m_DataIndex; }
|
||||
set { if (PropertyUtil.SetStruct(ref m_DataIndex, value)) SetVerticesDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// the scale of data when sizeType assined as FromData.
|
||||
/// |当sizeType指定为FromData时,指定的倍数系数。
|
||||
/// </summary>
|
||||
public float dataScale
|
||||
{
|
||||
get { return m_DataScale; }
|
||||
set { if (PropertyUtil.SetStruct(ref m_DataScale, value)) SetVerticesDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// the scale of selected data when sizeType assined as FromData.
|
||||
/// |当sizeType指定为FromData时,指定的高亮倍数系数。
|
||||
/// </summary>
|
||||
public float selectedDataScale
|
||||
{
|
||||
get { return m_SelectedDataScale; }
|
||||
set { if (PropertyUtil.SetStruct(ref m_SelectedDataScale, value)) SetVerticesDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// the function of size when sizeType assined as Function.
|
||||
/// |当sizeType指定为Function时,指定的委托函数。
|
||||
/// </summary>
|
||||
public SymbolSizeFunction sizeFunction
|
||||
{
|
||||
get { return m_SizeFunction; }
|
||||
set { if (PropertyUtil.SetClass(ref m_SizeFunction, value)) SetVerticesDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// the function of size when sizeType assined as Function.
|
||||
/// |当sizeType指定为Function时,指定的高亮委托函数。
|
||||
/// </summary>
|
||||
public SymbolSizeFunction selectedSizeFunction
|
||||
{
|
||||
get { return m_SelectedSizeFunction; }
|
||||
set { if (PropertyUtil.SetClass(ref m_SelectedSizeFunction, value)) SetVerticesDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// the index start to show symbol.
|
||||
/// |开始显示图形标记的索引。
|
||||
/// </summary>
|
||||
public int startIndex
|
||||
{
|
||||
get { return m_StartIndex; }
|
||||
set { if (PropertyUtil.SetStruct(ref m_StartIndex, value)) SetVerticesDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// the interval of show symbol.
|
||||
/// |显示图形标记的间隔。0表示显示所有标签,1表示隔一个隔显示一个标签,以此类推。
|
||||
/// </summary>
|
||||
public int interval
|
||||
{
|
||||
get { return m_Interval; }
|
||||
set { if (PropertyUtil.SetStruct(ref m_Interval, value)) SetVerticesDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// whether to show the last symbol.
|
||||
/// |是否强制显示最后一个图形标记。
|
||||
/// </summary>
|
||||
public bool forceShowLast
|
||||
{
|
||||
get { return m_ForceShowLast; }
|
||||
set { if (PropertyUtil.SetStruct(ref m_ForceShowLast, value)) SetVerticesDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// 图形是否重复。
|
||||
/// </summary>
|
||||
public bool repeat
|
||||
{
|
||||
get { return m_Repeat; }
|
||||
set { if (PropertyUtil.SetStruct(ref m_Repeat, value)) SetAllDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// 根据指定的sizeType获得标记的大小
|
||||
/// </summary>
|
||||
/// <param name="data"></param>
|
||||
/// <returns></returns>
|
||||
public float GetSize(List<double> data, float themeSize)
|
||||
{
|
||||
switch (m_SizeType)
|
||||
{
|
||||
case SymbolSizeType.Custom:
|
||||
return size == 0 ? themeSize : size;
|
||||
case SymbolSizeType.FromData:
|
||||
if (data != null && dataIndex >= 0 && dataIndex < data.Count)
|
||||
{
|
||||
return (float)data[dataIndex] * m_DataScale;
|
||||
}
|
||||
else
|
||||
{
|
||||
return size == 0 ? themeSize : size;
|
||||
}
|
||||
case SymbolSizeType.Function:
|
||||
if (data != null && sizeFunction != null) return sizeFunction(data);
|
||||
else return size == 0 ? themeSize : size;
|
||||
default: return size == 0 ? themeSize : size;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 根据sizeType获得高亮时的标记大小
|
||||
/// </summary>
|
||||
/// <param name="data"></param>
|
||||
/// <returns></returns>
|
||||
public float GetSelectedSize(List<double> data, float themeSelectedSize)
|
||||
{
|
||||
switch (m_SizeType)
|
||||
{
|
||||
case SymbolSizeType.Custom:
|
||||
|
||||
return selectedSize == 0 ? themeSelectedSize : selectedSize;
|
||||
|
||||
case SymbolSizeType.FromData:
|
||||
|
||||
if (data != null && dataIndex >= 0 && dataIndex < data.Count)
|
||||
{
|
||||
return (float)data[dataIndex] * m_SelectedDataScale;
|
||||
}
|
||||
else
|
||||
{
|
||||
return selectedSize == 0 ? themeSelectedSize : selectedSize;
|
||||
}
|
||||
|
||||
case SymbolSizeType.Function:
|
||||
|
||||
if (data != null && selectedSizeFunction != null)
|
||||
return selectedSizeFunction(data);
|
||||
else
|
||||
return selectedSize == 0 ? themeSelectedSize : selectedSize;
|
||||
|
||||
default: return selectedSize == 0 ? themeSelectedSize : selectedSize;
|
||||
}
|
||||
}
|
||||
|
||||
public bool ShowSymbol(int dataIndex, int dataCount)
|
||||
{
|
||||
if (!show)
|
||||
return false;
|
||||
|
||||
if (dataIndex < startIndex)
|
||||
return false;
|
||||
|
||||
if (m_Interval <= 0)
|
||||
return true;
|
||||
|
||||
if (m_ForceShowLast && dataIndex == dataCount - 1)
|
||||
return true;
|
||||
|
||||
return (dataIndex - startIndex) % (m_Interval + 1) == 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
11
Runtime/Component/Child/SerieSymbl.cs.meta
Normal file
11
Runtime/Component/Child/SerieSymbl.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: cd2852f4c46ae4dbd8c105e62dcce9a2
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -61,75 +61,31 @@ namespace XCharts.Runtime
|
||||
EmptyArrow
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The way to get serie symbol size.
|
||||
/// |获取标记图形大小的方式。
|
||||
/// </summary>
|
||||
public enum SymbolSizeType
|
||||
{
|
||||
/// <summary>
|
||||
/// Specify constant for symbol size.
|
||||
/// |自定义大小。
|
||||
/// </summary>
|
||||
Custom,
|
||||
/// <summary>
|
||||
/// Specify the dataIndex and dataScale to calculate symbol size.
|
||||
/// |通过 dataIndex 从数据中获取,再乘以一个比例系数 dataScale 。
|
||||
/// </summary>
|
||||
FromData,
|
||||
/// <summary>
|
||||
/// Specify function for symbol size.
|
||||
/// |通过委托函数获取。
|
||||
/// </summary>
|
||||
Function,
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 系列数据项的标记的图形
|
||||
/// </summary>
|
||||
[System.Serializable]
|
||||
public class SymbolStyle : ChildComponent, ISerieDataComponent
|
||||
public class SymbolStyle : ChildComponent
|
||||
{
|
||||
[SerializeField] private bool m_Show = true;
|
||||
[SerializeField] private SymbolType m_Type = SymbolType.EmptyCircle;
|
||||
[SerializeField] private SymbolSizeType m_SizeType = SymbolSizeType.Custom;
|
||||
[SerializeField] private float m_Size = 0f;
|
||||
[SerializeField] private float m_SelectedSize = 0f;
|
||||
[SerializeField] private int m_DataIndex = 1;
|
||||
[SerializeField] private float m_DataScale = 1;
|
||||
[SerializeField] private float m_SelectedDataScale = 1.5f;
|
||||
[SerializeField] private SymbolSizeFunction m_SizeFunction;
|
||||
[SerializeField] private SymbolSizeFunction m_SelectedSizeFunction;
|
||||
[SerializeField] private int m_StartIndex;
|
||||
[SerializeField] private int m_Interval;
|
||||
[SerializeField] private bool m_ForceShowLast = false;
|
||||
[SerializeField] private float m_Gap = 0;
|
||||
[SerializeField] private float m_Width = 0f;
|
||||
[SerializeField] private float m_Height = 0f;
|
||||
[SerializeField] private bool m_Repeat = false;
|
||||
[SerializeField] private Vector2 m_Offset = Vector2.zero;
|
||||
[SerializeField] private Sprite m_Image;
|
||||
[SerializeField] private Image.Type m_ImageType;
|
||||
[SerializeField] protected bool m_Show = true;
|
||||
[SerializeField] protected SymbolType m_Type = SymbolType.EmptyCircle;
|
||||
[SerializeField] protected float m_Size = 0f;
|
||||
[SerializeField] protected float m_Gap = 0;
|
||||
[SerializeField] protected float m_Width = 0f;
|
||||
[SerializeField] protected float m_Height = 0f;
|
||||
[SerializeField] protected Vector2 m_Offset = Vector2.zero;
|
||||
[SerializeField] protected Sprite m_Image;
|
||||
[SerializeField] protected Image.Type m_ImageType;
|
||||
[SerializeField] protected Color32 m_Color;
|
||||
|
||||
public void Reset()
|
||||
public virtual void Reset()
|
||||
{
|
||||
m_Show = false;
|
||||
m_Type = SymbolType.EmptyCircle;
|
||||
m_SizeType = SymbolSizeType.Custom;
|
||||
m_Size = 0f;
|
||||
m_SelectedSize = 0f;
|
||||
m_DataIndex = 1;
|
||||
m_DataScale = 1;
|
||||
m_SelectedDataScale = 1.5f;
|
||||
m_SizeFunction = null;
|
||||
m_SelectedSizeFunction = null;
|
||||
m_StartIndex = 0;
|
||||
m_Interval = 0;
|
||||
m_ForceShowLast = false;
|
||||
m_Gap = 0;
|
||||
m_Width = 0f;
|
||||
m_Height = 0f;
|
||||
m_Repeat = false;
|
||||
m_Offset = Vector2.zero;
|
||||
m_Image = null;
|
||||
m_ImageType = Image.Type.Simple;
|
||||
@@ -154,15 +110,6 @@ namespace XCharts.Runtime
|
||||
set { if (PropertyUtil.SetStruct(ref m_Type, value)) SetVerticesDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// the type of symbol size.
|
||||
/// |标记图形的大小获取方式。
|
||||
/// </summary>
|
||||
public SymbolSizeType sizeType
|
||||
{
|
||||
get { return m_SizeType; }
|
||||
set { if (PropertyUtil.SetStruct(ref m_SizeType, value)) SetVerticesDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// the size of symbol.
|
||||
/// |标记的大小。
|
||||
/// </summary>
|
||||
@@ -172,87 +119,6 @@ namespace XCharts.Runtime
|
||||
set { if (PropertyUtil.SetStruct(ref m_Size, value)) SetVerticesDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// the size of selected symbol.
|
||||
/// |被选中的标记的大小。
|
||||
/// </summary>
|
||||
public float selectedSize
|
||||
{
|
||||
get { return m_SelectedSize; }
|
||||
set { if (PropertyUtil.SetStruct(ref m_SelectedSize, value)) SetVerticesDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// whitch data index is when the sizeType assined as FromData.
|
||||
/// |当sizeType指定为FromData时,指定的数据源索引。
|
||||
/// </summary>
|
||||
public int dataIndex
|
||||
{
|
||||
get { return m_DataIndex; }
|
||||
set { if (PropertyUtil.SetStruct(ref m_DataIndex, value)) SetVerticesDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// the scale of data when sizeType assined as FromData.
|
||||
/// |当sizeType指定为FromData时,指定的倍数系数。
|
||||
/// </summary>
|
||||
public float dataScale
|
||||
{
|
||||
get { return m_DataScale; }
|
||||
set { if (PropertyUtil.SetStruct(ref m_DataScale, value)) SetVerticesDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// the scale of selected data when sizeType assined as FromData.
|
||||
/// |当sizeType指定为FromData时,指定的高亮倍数系数。
|
||||
/// </summary>
|
||||
public float selectedDataScale
|
||||
{
|
||||
get { return m_SelectedDataScale; }
|
||||
set { if (PropertyUtil.SetStruct(ref m_SelectedDataScale, value)) SetVerticesDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// the function of size when sizeType assined as Function.
|
||||
/// |当sizeType指定为Function时,指定的委托函数。
|
||||
/// </summary>
|
||||
public SymbolSizeFunction sizeFunction
|
||||
{
|
||||
get { return m_SizeFunction; }
|
||||
set { if (PropertyUtil.SetClass(ref m_SizeFunction, value)) SetVerticesDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// the function of size when sizeType assined as Function.
|
||||
/// |当sizeType指定为Function时,指定的高亮委托函数。
|
||||
/// </summary>
|
||||
public SymbolSizeFunction selectedSizeFunction
|
||||
{
|
||||
get { return m_SelectedSizeFunction; }
|
||||
set { if (PropertyUtil.SetClass(ref m_SelectedSizeFunction, value)) SetVerticesDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// the index start to show symbol.
|
||||
/// |开始显示图形标记的索引。
|
||||
/// </summary>
|
||||
public int startIndex
|
||||
{
|
||||
get { return m_StartIndex; }
|
||||
set { if (PropertyUtil.SetStruct(ref m_StartIndex, value)) SetVerticesDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// the interval of show symbol.
|
||||
/// |显示图形标记的间隔。0表示显示所有标签,1表示隔一个隔显示一个标签,以此类推。
|
||||
/// </summary>
|
||||
public int interval
|
||||
{
|
||||
get { return m_Interval; }
|
||||
set { if (PropertyUtil.SetStruct(ref m_Interval, value)) SetVerticesDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// whether to show the last symbol.
|
||||
/// |是否强制显示最后一个图形标记。
|
||||
/// </summary>
|
||||
public bool forceShowLast
|
||||
{
|
||||
get { return m_ForceShowLast; }
|
||||
set { if (PropertyUtil.SetStruct(ref m_ForceShowLast, value)) SetVerticesDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// the gap of symbol and line segment.
|
||||
/// |图形标记和线条的间隙距离。
|
||||
/// </summary>
|
||||
@@ -278,14 +144,6 @@ namespace XCharts.Runtime
|
||||
set { if (PropertyUtil.SetStruct(ref m_Height, value)) SetAllDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// 图形是否重复。
|
||||
/// </summary>
|
||||
public bool repeat
|
||||
{
|
||||
get { return m_Repeat; }
|
||||
set { if (PropertyUtil.SetStruct(ref m_Repeat, value)) SetAllDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// 自定义的标记图形。
|
||||
/// </summary>
|
||||
public Sprite image
|
||||
@@ -306,6 +164,14 @@ namespace XCharts.Runtime
|
||||
get { return m_Offset; }
|
||||
set { if (PropertyUtil.SetStruct(ref m_Offset, value)) SetAllDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// 图形的颜色。
|
||||
/// </summary>
|
||||
public Color32 color
|
||||
{
|
||||
get { return m_Color; }
|
||||
set { if (PropertyUtil.SetStruct(ref m_Color, value)) SetAllDirty(); }
|
||||
}
|
||||
public Vector3 offset3 { get { return new Vector3(m_Offset.x, m_Offset.y, 0); } }
|
||||
private List<float> m_AnimationSize = new List<float>() { 0, 5, 10 };
|
||||
/// <summary>
|
||||
@@ -313,84 +179,11 @@ namespace XCharts.Runtime
|
||||
/// |带有涟漪特效动画的散点图的动画参数。
|
||||
/// </summary>
|
||||
public List<float> animationSize { get { return m_AnimationSize; } }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 根据指定的sizeType获得标记的大小
|
||||
/// </summary>
|
||||
/// <param name="data"></param>
|
||||
/// <returns></returns>
|
||||
public float GetSize(List<double> data, float themeSize)
|
||||
public Color32 GetColor(Color32 defaultColor)
|
||||
{
|
||||
switch (m_SizeType)
|
||||
{
|
||||
case SymbolSizeType.Custom:
|
||||
return size == 0 ? themeSize : size;
|
||||
case SymbolSizeType.FromData:
|
||||
if (data != null && dataIndex >= 0 && dataIndex < data.Count)
|
||||
{
|
||||
return (float)data[dataIndex] * m_DataScale;
|
||||
}
|
||||
else
|
||||
{
|
||||
return size == 0 ? themeSize : size;
|
||||
}
|
||||
case SymbolSizeType.Function:
|
||||
if (data != null && sizeFunction != null) return sizeFunction(data);
|
||||
else return size == 0 ? themeSize : size;
|
||||
default: return size == 0 ? themeSize : size;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 根据sizeType获得高亮时的标记大小
|
||||
/// </summary>
|
||||
/// <param name="data"></param>
|
||||
/// <returns></returns>
|
||||
public float GetSelectedSize(List<double> data, float themeSelectedSize)
|
||||
{
|
||||
switch (m_SizeType)
|
||||
{
|
||||
case SymbolSizeType.Custom:
|
||||
|
||||
return selectedSize == 0 ? themeSelectedSize : selectedSize;
|
||||
|
||||
case SymbolSizeType.FromData:
|
||||
|
||||
if (data != null && dataIndex >= 0 && dataIndex < data.Count)
|
||||
{
|
||||
return (float)data[dataIndex] * m_SelectedDataScale;
|
||||
}
|
||||
else
|
||||
{
|
||||
return selectedSize == 0 ? themeSelectedSize : selectedSize;
|
||||
}
|
||||
|
||||
case SymbolSizeType.Function:
|
||||
|
||||
if (data != null && selectedSizeFunction != null)
|
||||
return selectedSizeFunction(data);
|
||||
else
|
||||
return selectedSize == 0 ? themeSelectedSize : selectedSize;
|
||||
|
||||
default: return selectedSize == 0 ? themeSelectedSize : selectedSize;
|
||||
}
|
||||
}
|
||||
|
||||
public bool ShowSymbol(int dataIndex, int dataCount)
|
||||
{
|
||||
if (!show)
|
||||
return false;
|
||||
|
||||
if (dataIndex < startIndex)
|
||||
return false;
|
||||
|
||||
if (m_Interval <= 0)
|
||||
return true;
|
||||
|
||||
if (m_ForceShowLast && dataIndex == dataCount - 1)
|
||||
return true;
|
||||
|
||||
return (dataIndex - startIndex) % (m_Interval + 1) == 0;
|
||||
return ChartHelper.IsClearColor(m_Color) ? defaultColor : m_Color;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -242,11 +242,10 @@ namespace XCharts.Runtime
|
||||
private void DrawMarkLineSymbol(VertexHelper vh, SymbolStyle symbol, Serie serie, GridCoord grid, ThemeStyle theme,
|
||||
Vector3 pos, Vector3 startPos, Color32 lineColor)
|
||||
{
|
||||
var symbolSize = symbol.GetSize(null, theme.serie.lineSymbolSize);
|
||||
var tickness = SerieHelper.GetSymbolBorder(serie, null, theme, false);
|
||||
var borderColor = SerieHelper.GetSymbolBorderColor(serie, null, theme, false);
|
||||
var cornerRadius = SerieHelper.GetSymbolCornerRadius(serie, null, false);
|
||||
chart.DrawClipSymbol(vh, symbol.type, symbolSize, tickness, pos, lineColor, lineColor,
|
||||
chart.DrawClipSymbol(vh, symbol.type, symbol.size, tickness, pos, lineColor, lineColor,
|
||||
ColorUtil.clearColor32, borderColor, symbol.gap, true, cornerRadius, grid, startPos);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user