using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
namespace XCharts.Runtime
{
///
/// the type of symbol.
/// |标记图形的类型。
///
public enum SymbolType
{
///
/// 不显示标记。
///
None,
///
/// 自定义标记。
///
Custom,
///
/// 圆形。
///
Circle,
///
/// 空心圆。
///
EmptyCircle,
///
/// 正方形。可通过设置`itemStyle`的`cornerRadius`变成圆角矩形。
///
Rect,
///
/// 空心正方形。
///
EmptyRect,
///
/// 三角形。
///
Triangle,
///
/// 空心三角形。
///
EmptyTriangle,
///
/// 菱形。
///
Diamond,
///
/// 空心菱形。
///
EmptyDiamond,
///
/// 箭头。
///
Arrow,
///
/// 空心箭头。
///
EmptyArrow
}
///
/// 系列数据项的标记的图形
///
[System.Serializable]
public class SymbolStyle : ChildComponent
{
[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 virtual void Reset()
{
m_Show = false;
m_Type = SymbolType.EmptyCircle;
m_Size = 0f;
m_Gap = 0;
m_Width = 0f;
m_Height = 0f;
m_Offset = Vector2.zero;
m_Image = null;
m_ImageType = Image.Type.Simple;
}
///
/// Whether the symbol is showed.
/// |是否显示标记。
///
public bool show
{
get { return m_Show; }
set { if (PropertyUtil.SetStruct(ref m_Show, value)) SetAllDirty(); }
}
///
/// the type of symbol.
/// |标记类型。
///
public SymbolType type
{
get { return m_Type; }
set { if (PropertyUtil.SetStruct(ref m_Type, value)) SetVerticesDirty(); }
}
///
/// the size of symbol.
/// |标记的大小。
///
public float size
{
get { return m_Size; }
set { if (PropertyUtil.SetStruct(ref m_Size, value)) SetVerticesDirty(); }
}
///
/// the gap of symbol and line segment.
/// |图形标记和线条的间隙距离。
///
public float gap
{
get { return m_Gap; }
set { if (PropertyUtil.SetStruct(ref m_Gap, value)) SetVerticesDirty(); }
}
///
/// 图形的宽。
///
public float width
{
get { return m_Width; }
set { if (PropertyUtil.SetStruct(ref m_Width, value)) SetAllDirty(); }
}
///
/// 图形的高。
///
public float height
{
get { return m_Height; }
set { if (PropertyUtil.SetStruct(ref m_Height, value)) SetAllDirty(); }
}
///
/// 自定义的标记图形。
///
public Sprite image
{
get { return m_Image; }
set { if (PropertyUtil.SetClass(ref m_Image, value)) SetAllDirty(); }
}
///
/// the fill type of image.
/// |图形填充类型。
///
public Image.Type imageType
{
get { return m_ImageType; }
set { if (PropertyUtil.SetStruct(ref m_ImageType, value)) SetAllDirty(); }
}
///
/// 图形的偏移。
///
public Vector2 offset
{
get { return m_Offset; }
set { if (PropertyUtil.SetStruct(ref m_Offset, value)) SetAllDirty(); }
}
///
/// 图形的颜色。
///
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 m_AnimationSize = new List() { 0, 5, 10 };
///
/// the setting for effect scatter.
/// |带有涟漪特效动画的散点图的动画参数。
///
public List animationSize { get { return m_AnimationSize; } }
public Color32 GetColor(Color32 defaultColor)
{
return ChartHelper.IsClearColor(m_Color) ? defaultColor : m_Color;
}
}
}