UI update 02
This commit is contained in:
@@ -0,0 +1,132 @@
|
||||
using UnityEngine;
|
||||
|
||||
namespace XCharts.Runtime
|
||||
{
|
||||
/// <summary>
|
||||
/// The style of area.
|
||||
/// ||区域填充样式。
|
||||
/// </summary>
|
||||
[System.Serializable]
|
||||
public class AreaStyle : ChildComponent, ISerieComponent, ISerieDataComponent
|
||||
{
|
||||
/// <summary>
|
||||
/// Origin position of area.
|
||||
/// ||图形区域的起始位置。默认情况下,图形会从坐标轴轴线到数据间进行填充。如果需要填充的区域是坐标轴最大值到数据间,或者坐标轴最小值到数据间,则可以通过这个配置项进行设置。
|
||||
/// </summary>
|
||||
public enum AreaOrigin
|
||||
{
|
||||
/// <summary>
|
||||
/// to fill between axis line to data.
|
||||
/// ||填充坐标轴轴线到数据间的区域。
|
||||
/// </summary>
|
||||
Auto,
|
||||
/// <summary>
|
||||
/// to fill between min axis value (when not inverse) to data.
|
||||
/// ||填充坐标轴底部到数据间的区域。
|
||||
/// </summary>
|
||||
Start,
|
||||
/// <summary>
|
||||
/// to fill between max axis value (when not inverse) to data.
|
||||
/// ||填充坐标轴顶部到数据间的区域。
|
||||
/// </summary>
|
||||
End
|
||||
}
|
||||
|
||||
[SerializeField] private bool m_Show = true;
|
||||
[SerializeField] private AreaStyle.AreaOrigin m_Origin;
|
||||
[SerializeField] private Color32 m_Color;
|
||||
[SerializeField] private Color32 m_ToColor;
|
||||
[SerializeField][Range(0, 1)] private float m_Opacity = 0.6f;
|
||||
[SerializeField][Since("v3.2.0")] private bool m_InnerFill;
|
||||
[SerializeField][Since("v3.6.0")] private bool m_ToTop = true;
|
||||
|
||||
/// <summary>
|
||||
/// Set this to false to prevent the areafrom showing.
|
||||
/// ||是否显示区域填充。
|
||||
/// </summary>
|
||||
public bool show
|
||||
{
|
||||
get { return m_Show; }
|
||||
set { if (PropertyUtil.SetStruct(ref m_Show, value)) SetVerticesDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// the origin of area.
|
||||
/// ||区域填充的起始位置。
|
||||
/// </summary>
|
||||
public AreaOrigin origin
|
||||
{
|
||||
get { return m_Origin; }
|
||||
set { if (PropertyUtil.SetStruct(ref m_Origin, value)) SetVerticesDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// the color of area,default use serie color.
|
||||
/// ||区域填充的颜色,如果toColor不是默认值,则表示渐变色的起点颜色。
|
||||
/// </summary>
|
||||
public Color32 color
|
||||
{
|
||||
get { return m_Color; }
|
||||
set { if (PropertyUtil.SetColor(ref m_Color, value)) SetVerticesDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// Gradient color, start color to toColor.
|
||||
/// ||渐变色的终点颜色。
|
||||
/// </summary>
|
||||
public Color32 toColor
|
||||
{
|
||||
get { return m_ToColor; }
|
||||
set { if (PropertyUtil.SetColor(ref m_ToColor, value)) SetVerticesDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// Opacity of the component. Supports value from 0 to 1, and the component will not be drawn when set to 0.
|
||||
/// ||图形透明度。支持从 0 到 1 的数字,为 0 时不绘制该图形。
|
||||
/// </summary>
|
||||
public float opacity
|
||||
{
|
||||
get { return m_Opacity; }
|
||||
set { if (PropertyUtil.SetStruct(ref m_Opacity, value)) SetVerticesDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// Whether to fill only polygonal areas. Currently, only convex polygons are supported.
|
||||
/// ||是否只填充多边形区域。目前只支持凸多边形。
|
||||
/// </summary>
|
||||
public bool innerFill
|
||||
{
|
||||
get { return m_InnerFill; }
|
||||
set { if (PropertyUtil.SetStruct(ref m_InnerFill, value)) SetVerticesDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// Whether to fill the gradient color to the top. The default is true, which means that the gradient color is filled to the top.
|
||||
/// If it is false, the gradient color is filled to the actual position.
|
||||
/// ||渐变色是到顶部还是到实际位置。默认为true到顶部。
|
||||
/// </summary>
|
||||
public bool toTop
|
||||
{
|
||||
get { return m_ToTop; }
|
||||
set { if (PropertyUtil.SetStruct(ref m_ToTop, value)) SetVerticesDirty(); }
|
||||
}
|
||||
|
||||
public Color32 GetColor()
|
||||
{
|
||||
if (m_Opacity == 1)
|
||||
return m_Color;
|
||||
|
||||
var color = m_Color;
|
||||
color.a = (byte) (color.a * m_Opacity);
|
||||
return color;
|
||||
}
|
||||
|
||||
public Color32 GetColor(Color32 themeColor)
|
||||
{
|
||||
if (!ChartHelper.IsClearColor(color))
|
||||
{
|
||||
return GetColor();
|
||||
}
|
||||
else
|
||||
{
|
||||
var color = themeColor;
|
||||
color.a = (byte) (color.a * opacity);
|
||||
return color;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ec0d95a9298bb4c159dcae36020beec9
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,92 @@
|
||||
using System;
|
||||
using UnityEngine;
|
||||
|
||||
namespace XCharts.Runtime
|
||||
{
|
||||
/// <summary>
|
||||
/// </summary>
|
||||
[Serializable]
|
||||
public class ArrowStyle : ChildComponent
|
||||
{
|
||||
[SerializeField] private float m_Width = 10;
|
||||
[SerializeField] private float m_Height = 15;
|
||||
[SerializeField] private float m_Offset = 0;
|
||||
[SerializeField] private float m_Dent = 3;
|
||||
[SerializeField] private Color32 m_Color = Color.clear;
|
||||
|
||||
/// <summary>
|
||||
/// The widht of arrow.
|
||||
/// ||箭头宽。
|
||||
/// </summary>
|
||||
public float width
|
||||
{
|
||||
get { return m_Width; }
|
||||
set { if (PropertyUtil.SetStruct(ref m_Width, value)) SetVerticesDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// The height of arrow.
|
||||
/// ||箭头高。
|
||||
/// </summary>
|
||||
public float height
|
||||
{
|
||||
get { return m_Height; }
|
||||
set { if (PropertyUtil.SetStruct(ref m_Height, value)) SetVerticesDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// The offset of arrow.
|
||||
/// ||箭头偏移。
|
||||
/// </summary>
|
||||
public float offset
|
||||
{
|
||||
get { return m_Offset; }
|
||||
set { if (PropertyUtil.SetStruct(ref m_Offset, value)) SetVerticesDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// The dent of arrow.
|
||||
/// ||箭头的凹度。
|
||||
/// </summary>
|
||||
public float dent
|
||||
{
|
||||
get { return m_Dent; }
|
||||
set { if (PropertyUtil.SetStruct(ref m_Dent, value)) SetVerticesDirty(); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// the color of arrow.
|
||||
/// ||箭头颜色。
|
||||
/// </summary>
|
||||
public Color32 color
|
||||
{
|
||||
get { return m_Color; }
|
||||
set { if (PropertyUtil.SetColor(ref m_Color, value)) SetVerticesDirty(); }
|
||||
}
|
||||
|
||||
public ArrowStyle Clone()
|
||||
{
|
||||
var arrow = new ArrowStyle();
|
||||
arrow.width = width;
|
||||
arrow.height = height;
|
||||
arrow.offset = offset;
|
||||
arrow.dent = dent;
|
||||
arrow.color = color;
|
||||
return arrow;
|
||||
}
|
||||
|
||||
public void Copy(ArrowStyle arrow)
|
||||
{
|
||||
width = arrow.width;
|
||||
height = arrow.height;
|
||||
offset = arrow.offset;
|
||||
dent = arrow.dent;
|
||||
color = arrow.color;
|
||||
}
|
||||
|
||||
public Color32 GetColor(Color32 defaultColor)
|
||||
{
|
||||
if (ChartHelper.IsClearColor(color))
|
||||
return defaultColor;
|
||||
else
|
||||
return color;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 2232b812c68f042d29c44863e38d0417
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,82 @@
|
||||
using UnityEngine;
|
||||
|
||||
namespace XCharts.Runtime
|
||||
{
|
||||
/// <summary>
|
||||
/// Settings related to base line.
|
||||
/// ||线条基础配置。
|
||||
/// </summary>
|
||||
[System.Serializable]
|
||||
public class BaseLine : ChildComponent
|
||||
{
|
||||
[SerializeField] protected bool m_Show;
|
||||
[SerializeField] protected LineStyle m_LineStyle = new LineStyle();
|
||||
|
||||
/// <summary>
|
||||
/// Set this to false to prevent the axis line from showing.
|
||||
/// ||是否显示坐标轴轴线。
|
||||
/// </summary>
|
||||
public bool show
|
||||
{
|
||||
get { return m_Show; }
|
||||
set { if (PropertyUtil.SetStruct(ref m_Show, value)) SetVerticesDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// 线条样式
|
||||
/// </summary>
|
||||
public LineStyle lineStyle
|
||||
{
|
||||
get { return m_LineStyle; }
|
||||
set { if (value != null) { m_LineStyle = value; SetVerticesDirty(); } }
|
||||
}
|
||||
|
||||
public static BaseLine defaultBaseLine
|
||||
{
|
||||
get
|
||||
{
|
||||
var axisLine = new BaseLine
|
||||
{
|
||||
m_Show = true,
|
||||
m_LineStyle = new LineStyle()
|
||||
};
|
||||
return axisLine;
|
||||
}
|
||||
}
|
||||
|
||||
public BaseLine()
|
||||
{
|
||||
lineStyle = new LineStyle();
|
||||
}
|
||||
|
||||
public BaseLine(bool show) : base()
|
||||
{
|
||||
m_Show = show;
|
||||
}
|
||||
|
||||
public void Copy(BaseLine axisLine)
|
||||
{
|
||||
show = axisLine.show;
|
||||
lineStyle.Copy(axisLine.lineStyle);
|
||||
}
|
||||
|
||||
public LineStyle.Type GetType(LineStyle.Type themeType)
|
||||
{
|
||||
return lineStyle.GetType(themeType);
|
||||
}
|
||||
|
||||
public float GetWidth(float themeWidth)
|
||||
{
|
||||
return lineStyle.GetWidth(themeWidth);
|
||||
}
|
||||
|
||||
public float GetLength(float themeLength)
|
||||
{
|
||||
return lineStyle.GetLength(themeLength);
|
||||
}
|
||||
|
||||
public Color32 GetColor(Color32 themeColor)
|
||||
{
|
||||
return lineStyle.GetColor(themeColor);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 4c431b00ccffe4db4b61179b6df06eb2
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,92 @@
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
namespace XCharts.Runtime
|
||||
{
|
||||
/// <summary>
|
||||
/// The style of border.
|
||||
/// ||边框样式。
|
||||
/// </summary>
|
||||
[System.Serializable]
|
||||
[Since("v3.10.0")]
|
||||
public class BorderStyle : ChildComponent
|
||||
{
|
||||
[SerializeField] private bool m_Show = false;
|
||||
[SerializeField] private float m_BorderWidth;
|
||||
[SerializeField] private Color32 m_BorderColor;
|
||||
[SerializeField] private bool m_RoundedCorner = true;
|
||||
[SerializeField] private float[] m_CornerRadius = new float[] { 0, 0, 0, 0 };
|
||||
|
||||
/// <summary>
|
||||
/// whether the border is visible.
|
||||
/// ||是否显示边框。
|
||||
/// </summary>
|
||||
public bool show
|
||||
{
|
||||
get { return m_Show; }
|
||||
set { if (PropertyUtil.SetStruct(ref m_Show, value)) SetAllDirty(); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// the width of border.
|
||||
/// ||边框宽度。
|
||||
/// </summary>
|
||||
public float borderWidth
|
||||
{
|
||||
get { return m_BorderWidth; }
|
||||
set { if (PropertyUtil.SetStruct(ref m_BorderWidth, value)) SetAllDirty(); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// the color of border.
|
||||
/// ||边框颜色。
|
||||
/// </summary>
|
||||
public Color32 borderColor
|
||||
{
|
||||
get { return m_BorderColor; }
|
||||
set { if (PropertyUtil.SetColor(ref m_BorderColor, value)) SetAllDirty(); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// whether the border is rounded corner.
|
||||
/// ||是否显示圆角。
|
||||
/// </summary>
|
||||
public bool roundedCorner
|
||||
{
|
||||
get { return m_RoundedCorner; }
|
||||
set { if (PropertyUtil.SetStruct(ref m_RoundedCorner, value)) SetAllDirty(); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The radius of rounded corner. Its unit is px. Use array to respectively specify the 4 corner radiuses((clockwise upper left,
|
||||
/// upper right, bottom right and bottom left)). When is set to (1,1,1,1), all corners are rounded.
|
||||
/// ||圆角半径。用数组分别指定4个圆角半径(顺时针左上,右上,右下,左下)。当为(1,1,1,1)时为全圆角。
|
||||
/// </summary>
|
||||
public float[] cornerRadius
|
||||
{
|
||||
get { return m_CornerRadius; }
|
||||
set { if (PropertyUtil.SetClass(ref m_CornerRadius, value)) SetAllDirty(); }
|
||||
}
|
||||
|
||||
public float GetRuntimeBorderWidth()
|
||||
{
|
||||
return m_Show ? m_BorderWidth : 0;
|
||||
}
|
||||
|
||||
public Color32 GetRuntimeBorderColor()
|
||||
{
|
||||
return m_Show ? m_BorderColor : ColorUtil.clearColor32;
|
||||
}
|
||||
|
||||
public float[] GetRuntimeCornerRadius()
|
||||
{
|
||||
return m_Show && roundedCorner ? m_CornerRadius : null;
|
||||
}
|
||||
|
||||
public bool IsCricle()
|
||||
{
|
||||
return roundedCorner && m_CornerRadius[0] == 1 && m_CornerRadius[1] == 1 &&
|
||||
m_CornerRadius[2] == 1 && m_CornerRadius[3] == 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 0a756cb373aab4292b93a0597fc4e82c
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,118 @@
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
namespace XCharts.Runtime
|
||||
{
|
||||
[System.Serializable]
|
||||
public class IconStyle : ChildComponent
|
||||
{
|
||||
public enum Layer
|
||||
{
|
||||
/// <summary>
|
||||
/// The icon is display under the label text.
|
||||
/// 图标在标签文字下
|
||||
/// </summary>
|
||||
UnderText,
|
||||
/// <summary>
|
||||
/// The icon is display above the label text.
|
||||
/// 图标在标签文字上
|
||||
/// </summary>
|
||||
AboveText
|
||||
}
|
||||
|
||||
[SerializeField] private bool m_Show = false;
|
||||
[SerializeField] private Layer m_Layer;
|
||||
[SerializeField] private Align m_Align = Align.Left;
|
||||
[SerializeField] private Sprite m_Sprite;
|
||||
[SerializeField] private Image.Type m_Type;
|
||||
[SerializeField] private Color m_Color = Color.white;
|
||||
[SerializeField] private float m_Width = 20;
|
||||
[SerializeField] private float m_Height = 20;
|
||||
[SerializeField] private Vector3 m_Offset;
|
||||
[SerializeField] private bool m_AutoHideWhenLabelEmpty = false;
|
||||
|
||||
public void Reset()
|
||||
{
|
||||
m_Show = false;
|
||||
m_Layer = Layer.UnderText;
|
||||
m_Sprite = null;
|
||||
m_Color = Color.white;
|
||||
m_Width = 20;
|
||||
m_Height = 20;
|
||||
m_Offset = Vector3.zero;
|
||||
m_AutoHideWhenLabelEmpty = false;
|
||||
}
|
||||
/// <summary>
|
||||
/// Whether the data icon is show.
|
||||
/// ||是否显示图标。
|
||||
/// </summary>
|
||||
public bool show { get { return m_Show; } set { m_Show = value; } }
|
||||
/// <summary>
|
||||
/// 显示在上层还是在下层。
|
||||
/// </summary>
|
||||
public Layer layer { get { return m_Layer; } set { m_Layer = value; } }
|
||||
/// <summary>
|
||||
/// The image of icon.
|
||||
/// ||图标的图片。
|
||||
/// </summary>
|
||||
public Sprite sprite { get { return m_Sprite; } set { m_Sprite = value; } }
|
||||
/// <summary>
|
||||
/// How to display the icon.
|
||||
/// ||图片的显示类型。
|
||||
/// </summary>
|
||||
public Image.Type type { get { return m_Type; } set { m_Type = value; } }
|
||||
/// <summary>
|
||||
/// 图标颜色。
|
||||
/// </summary>
|
||||
public Color color { get { return m_Color; } set { m_Color = value; } }
|
||||
/// <summary>
|
||||
/// 图标宽。
|
||||
/// </summary>
|
||||
public float width { get { return m_Width; } set { m_Width = value; } }
|
||||
/// <summary>
|
||||
/// 图标高。
|
||||
/// </summary>
|
||||
public float height { get { return m_Height; } set { m_Height = value; } }
|
||||
/// <summary>
|
||||
/// 图标偏移。
|
||||
/// </summary>
|
||||
public Vector3 offset { get { return m_Offset; } set { m_Offset = value; } }
|
||||
/// <summary>
|
||||
/// 水平方向对齐方式。
|
||||
/// </summary>
|
||||
public Align align { get { return m_Align; } set { m_Align = value; } }
|
||||
/// <summary>
|
||||
/// 当label内容为空时是否自动隐藏图标
|
||||
/// </summary>
|
||||
public bool autoHideWhenLabelEmpty { get { return m_AutoHideWhenLabelEmpty; } set { m_AutoHideWhenLabelEmpty = value; } }
|
||||
public IconStyle Clone()
|
||||
{
|
||||
var iconStyle = new IconStyle();
|
||||
iconStyle.show = show;
|
||||
iconStyle.layer = layer;
|
||||
iconStyle.sprite = sprite;
|
||||
iconStyle.type = type;
|
||||
iconStyle.color = color;
|
||||
iconStyle.width = width;
|
||||
iconStyle.height = height;
|
||||
iconStyle.offset = offset;
|
||||
iconStyle.align = align;
|
||||
iconStyle.autoHideWhenLabelEmpty = autoHideWhenLabelEmpty;
|
||||
return iconStyle;
|
||||
}
|
||||
|
||||
public void Copy(IconStyle iconStyle)
|
||||
{
|
||||
show = iconStyle.show;
|
||||
layer = iconStyle.layer;
|
||||
sprite = iconStyle.sprite;
|
||||
type = iconStyle.type;
|
||||
color = iconStyle.color;
|
||||
width = iconStyle.width;
|
||||
height = iconStyle.height;
|
||||
offset = iconStyle.offset;
|
||||
align = iconStyle.align;
|
||||
autoHideWhenLabelEmpty = iconStyle.autoHideWhenLabelEmpty;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 82c4d360f7b5b4ee7845e9bbe611c8a3
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,81 @@
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
namespace XCharts.Runtime
|
||||
{
|
||||
[System.Serializable]
|
||||
public class ImageStyle : ChildComponent, ISerieComponent, ISerieDataComponent
|
||||
{
|
||||
[SerializeField] private bool m_Show = true;
|
||||
[SerializeField] private Sprite m_Sprite;
|
||||
[SerializeField] private Image.Type m_Type;
|
||||
[SerializeField] private bool m_AutoColor;
|
||||
[SerializeField] private Color m_Color = Color.clear;
|
||||
[SerializeField] private float m_Width = 0;
|
||||
[SerializeField] private float m_Height = 0;
|
||||
|
||||
public void Reset()
|
||||
{
|
||||
m_Show = false;
|
||||
m_Type = Image.Type.Simple;
|
||||
m_Sprite = null;
|
||||
m_AutoColor = false;
|
||||
m_Color = Color.white;
|
||||
m_Width = 0;
|
||||
m_Height = 0;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Whether the data icon is show.
|
||||
/// ||是否显示图标。
|
||||
/// </summary>
|
||||
public bool show { get { return m_Show; } set { m_Show = value; } }
|
||||
/// <summary>
|
||||
/// The image of icon.
|
||||
/// ||图标的图片。
|
||||
/// </summary>
|
||||
public Sprite sprite { get { return m_Sprite; } set { m_Sprite = value; } }
|
||||
/// <summary>
|
||||
/// How to display the image.
|
||||
/// ||图片的显示类型。
|
||||
/// </summary>
|
||||
public Image.Type type { get { return m_Type; } set { m_Type = value; } }
|
||||
/// <summary>
|
||||
/// 是否自动颜色。
|
||||
/// </summary>
|
||||
public bool autoColor { get { return m_AutoColor; } set { m_AutoColor = value; } }
|
||||
/// <summary>
|
||||
/// 图标颜色。
|
||||
/// </summary>
|
||||
public Color color { get { return m_Color; } set { m_Color = value; } }
|
||||
/// <summary>
|
||||
/// 图标宽。
|
||||
/// </summary>
|
||||
public float width { get { return m_Width; } set { m_Width = value; } }
|
||||
/// <summary>
|
||||
/// 图标高。
|
||||
/// </summary>
|
||||
public float height { get { return m_Height; } set { m_Height = value; } }
|
||||
public ImageStyle Clone()
|
||||
{
|
||||
var imageStyle = new ImageStyle();
|
||||
imageStyle.type = type;
|
||||
imageStyle.sprite = sprite;
|
||||
imageStyle.autoColor = autoColor;
|
||||
imageStyle.color = color;
|
||||
imageStyle.width = width;
|
||||
imageStyle.height = height;
|
||||
return imageStyle;
|
||||
}
|
||||
|
||||
public void Copy(ImageStyle imageStyle)
|
||||
{
|
||||
type = imageStyle.type;
|
||||
sprite = imageStyle.sprite;
|
||||
autoColor = imageStyle.autoColor;
|
||||
color = imageStyle.color;
|
||||
width = imageStyle.width;
|
||||
height = imageStyle.height;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 5a76d1129783c4f55b0773da2eda9b67
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,377 @@
|
||||
using UnityEngine;
|
||||
|
||||
namespace XCharts.Runtime
|
||||
{
|
||||
/// <summary>
|
||||
/// 图形样式。
|
||||
/// </summary>
|
||||
[System.Serializable]
|
||||
public class ItemStyle : ChildComponent, ISerieDataComponent
|
||||
{
|
||||
[SerializeField] private bool m_Show = true;
|
||||
[SerializeField] private Color32 m_Color;
|
||||
[SerializeField] private Color32 m_Color0;
|
||||
[SerializeField] private Color32 m_ToColor;
|
||||
[SerializeField] private Color32 m_ToColor2;
|
||||
[SerializeField][Since("v3.6.0")] private Color32 m_MarkColor;
|
||||
[SerializeField] private Color32 m_BackgroundColor;
|
||||
[SerializeField] private float m_BackgroundWidth;
|
||||
[SerializeField][Since("v3.15.0")] private float m_BackgroundGap;
|
||||
[SerializeField] private Color32 m_CenterColor;
|
||||
[SerializeField] private float m_CenterGap;
|
||||
[SerializeField] private float m_BorderWidth = 0;
|
||||
[SerializeField] private float m_BorderGap = 0;
|
||||
[SerializeField] private Color32 m_BorderColor;
|
||||
[SerializeField] private Color32 m_BorderColor0;
|
||||
[SerializeField] private Color32 m_BorderToColor;
|
||||
[SerializeField][Range(0, 1)] private float m_Opacity = 1;
|
||||
[SerializeField] private string m_ItemMarker;
|
||||
[SerializeField] private string m_ItemFormatter;
|
||||
[SerializeField] private string m_NumericFormatter = "";
|
||||
[SerializeField] private float[] m_CornerRadius = new float[] { 0, 0, 0, 0 };
|
||||
|
||||
public void Reset()
|
||||
{
|
||||
m_Show = false;
|
||||
m_Color = Color.clear;
|
||||
m_Color0 = Color.clear;
|
||||
m_ToColor = Color.clear;
|
||||
m_ToColor2 = Color.clear;
|
||||
m_MarkColor = Color.clear;
|
||||
m_BackgroundColor = Color.clear;
|
||||
m_BackgroundWidth = 0;
|
||||
m_CenterColor = Color.clear;
|
||||
m_CenterGap = 0;
|
||||
m_BorderWidth = 0;
|
||||
m_BorderGap = 0;
|
||||
m_BorderColor = Color.clear;
|
||||
m_BorderColor0 = Color.clear;
|
||||
m_BorderToColor = Color.clear;
|
||||
m_Opacity = 1;
|
||||
m_ItemFormatter = null;
|
||||
m_ItemMarker = null;
|
||||
m_NumericFormatter = "";
|
||||
if (m_CornerRadius == null)
|
||||
{
|
||||
m_CornerRadius = new float[] { 0, 0, 0, 0 };
|
||||
}
|
||||
else
|
||||
{
|
||||
for (int i = 0; i < m_CornerRadius.Length; i++)
|
||||
m_CornerRadius[i] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 是否启用。
|
||||
/// </summary>
|
||||
public bool show
|
||||
{
|
||||
get { return m_Show; }
|
||||
set { if (PropertyUtil.SetStruct(ref m_Show, value)) SetVerticesDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// 数据项颜色。
|
||||
/// </summary>
|
||||
public Color32 color
|
||||
{
|
||||
get { return m_Color; }
|
||||
set { if (PropertyUtil.SetColor(ref m_Color, value)) SetVerticesDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// 数据项颜色。
|
||||
/// </summary>
|
||||
public Color32 color0
|
||||
{
|
||||
get { return m_Color0; }
|
||||
set { if (PropertyUtil.SetColor(ref m_Color0, value)) SetVerticesDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// Gradient color1.
|
||||
/// ||渐变色的颜色1。
|
||||
/// </summary>
|
||||
public Color32 toColor
|
||||
{
|
||||
get { return m_ToColor; }
|
||||
set { if (PropertyUtil.SetColor(ref m_ToColor, value)) SetVerticesDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// Gradient color2.Only valid in line diagrams.
|
||||
/// ||渐变色的颜色2。只在折线图中有效。
|
||||
/// </summary>
|
||||
public Color32 toColor2
|
||||
{
|
||||
get { return m_ToColor2; }
|
||||
set { if (PropertyUtil.SetColor(ref m_ToColor2, value)) SetVerticesDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// Serie's mark color. It is only used to display Legend and Tooltip, and does not affect the drawing color. The default value is clear.
|
||||
/// ||Serie的标识颜色。仅用于Legend和Tooltip的展示,不影响绘制颜色,默认为clear。
|
||||
/// </summary>
|
||||
public Color32 markColor
|
||||
{
|
||||
get { return m_MarkColor; }
|
||||
set { if (PropertyUtil.SetStruct(ref m_MarkColor, value)) { SetAllDirty(); } }
|
||||
}
|
||||
/// <summary>
|
||||
/// 数据项背景颜色。
|
||||
/// </summary>
|
||||
public Color32 backgroundColor
|
||||
{
|
||||
get { return m_BackgroundColor; }
|
||||
set { if (PropertyUtil.SetColor(ref m_BackgroundColor, value)) SetVerticesDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// 数据项背景宽度。
|
||||
/// </summary>
|
||||
public float backgroundWidth
|
||||
{
|
||||
get { return m_BackgroundWidth; }
|
||||
set { if (PropertyUtil.SetStruct(ref m_BackgroundWidth, value)) SetVerticesDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// the gap between background and data item.
|
||||
/// ||数据项背景间隙。
|
||||
/// </summary>
|
||||
public float backgroundGap
|
||||
{
|
||||
get { return m_BackgroundGap; }
|
||||
set { if (PropertyUtil.SetStruct(ref m_BackgroundGap, value)) SetVerticesDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// 中心区域颜色。
|
||||
/// </summary>
|
||||
public Color32 centerColor
|
||||
{
|
||||
get { return m_CenterColor; }
|
||||
set { if (PropertyUtil.SetColor(ref m_CenterColor, value)) SetVerticesDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// 中心区域间隙。
|
||||
/// </summary>
|
||||
public float centerGap
|
||||
{
|
||||
get { return m_CenterGap; }
|
||||
set { if (PropertyUtil.SetStruct(ref m_CenterGap, value)) SetVerticesDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// 边框的颜色。
|
||||
/// </summary>
|
||||
public Color32 borderColor
|
||||
{
|
||||
get { return m_BorderColor; }
|
||||
set { if (PropertyUtil.SetColor(ref m_BorderColor, value)) SetVerticesDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// 边框的颜色。
|
||||
/// </summary>
|
||||
public Color32 borderColor0
|
||||
{
|
||||
get { return m_BorderColor0; }
|
||||
set { if (PropertyUtil.SetColor(ref m_BorderColor0, value)) SetVerticesDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// 边框的渐变色。
|
||||
/// </summary>
|
||||
public Color32 borderToColor
|
||||
{
|
||||
get { return m_BorderToColor; }
|
||||
set { if (PropertyUtil.SetColor(ref m_BorderToColor, value)) SetVerticesDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// 边框宽。
|
||||
/// </summary>
|
||||
public float borderWidth
|
||||
{
|
||||
get { return m_BorderWidth; }
|
||||
set { if (PropertyUtil.SetStruct(ref m_BorderWidth, value)) SetVerticesDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// 边框间隙。
|
||||
/// </summary>
|
||||
public float borderGap
|
||||
{
|
||||
get { return m_BorderGap; }
|
||||
set { if (PropertyUtil.SetStruct(ref m_BorderGap, value)) SetVerticesDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// 透明度。支持从 0 到 1 的数字,为 0 时不绘制该图形。
|
||||
/// </summary>
|
||||
public float opacity
|
||||
{
|
||||
get { return m_Opacity; }
|
||||
set { if (PropertyUtil.SetStruct(ref m_Opacity, value)) SetVerticesDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// 提示框单项的字符串模版格式器。具体配置参考`Tooltip`的`formatter`
|
||||
/// </summary>
|
||||
public string itemFormatter
|
||||
{
|
||||
get { return m_ItemFormatter; }
|
||||
set { if (PropertyUtil.SetClass(ref m_ItemFormatter, value)) SetVerticesDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// 提示框单项的字符标志。用在Tooltip中。
|
||||
/// </summary>
|
||||
public string itemMarker
|
||||
{
|
||||
get { return m_ItemMarker; }
|
||||
set { if (PropertyUtil.SetClass(ref m_ItemMarker, value)) SetVerticesDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// Standard number and date format string. Used to format a Double value or a DateTime date as a string.
|
||||
/// numericFormatter is used as an argument to either `Double.ToString ()` or `DateTime.ToString()`. <br />
|
||||
/// The number format uses the Axx format: A is a single-character format specifier that supports C currency,
|
||||
/// D decimal, E exponent, F fixed-point number, G regular, N digit, P percentage, R round trip, and X hexadecimal.
|
||||
/// xx is precision specification, from 0-99. E.g. F1, E2<br />
|
||||
/// Date format: Starts with `date`, which is used to format DateTime. Common date formats are:
|
||||
/// yyyy year, MM month, dd day, HH hour, mm minute, ss second, fff millisecond. For example: date:yyyy-MM-dd HH:mm:ss<br />
|
||||
/// Time format: Starts with `time`, which is used to format TimeSpan. Common time formats are:
|
||||
/// d day, HH hour, mm minute, ss second, fffffff fractional part.
|
||||
/// Only the version of Unity2018 or later can support formatting, and the characters inside should be escaped.
|
||||
/// For example: time:HH\:mm\:ss<br />
|
||||
/// number format reference: https://docs.microsoft.com/en-us/dotnet/standard/base-types/standard-numeric-format-strings<br/>
|
||||
/// date format reference: https://docs.microsoft.com/en-us/dotnet/standard/base-types/standard-numeric-format-strings<br/>
|
||||
/// Note: The date and time formats are only supported by 'v3.12.0' or later.<br/>
|
||||
/// ||标准数字和日期格式字符串。用于将Double数值或DateTime日期格式化显示为字符串。numericFormatter用来作为Double.ToString()或DateTime.ToString()的参数。<br/>
|
||||
/// 数字格式使用Axx的形式:A是格式说明符的单字符,支持C货币、D十进制、E指数、F定点数、G常规、N数字、P百分比、R往返、X十六进制的。xx是精度说明,从0-99。如:F1, E2<br/>
|
||||
/// 日期格式:以`date`开头,用来格式化DateTime,常见格式有:yyyy年,MM月,dd日,HH时,mm分,ss秒,fff毫秒。如:date:yyyy-MM-dd HH:mm:ss<br/>
|
||||
/// 时间格式:以`time`开头,用来格式化TimeSpan,常见格式有:d日,HH时,mm分,ss秒,fffffff小数部分。
|
||||
/// 需要Unity2018以上版本才支持格式化,并且里面的字符要转义。如:time:d\.HH\:mm\:ss<br/>
|
||||
/// 数值格式化参考:https://docs.microsoft.com/zh-cn/dotnet/standard/base-types/standard-numeric-format-strings <br/>
|
||||
/// 日期格式化参考:https://learn.microsoft.com/zh-cn/dotnet/standard/base-types/standard-date-and-time-format-strings <br/>
|
||||
/// 时间格式化参考:https://learn.microsoft.com/zh-cn/dotnet/standard/base-types/standard-timespan-format-strings <br/>
|
||||
/// 注意:date和time格式需要`v3.12.0`以上版本才支持。
|
||||
/// </summary>
|
||||
public string numericFormatter
|
||||
{
|
||||
get { return m_NumericFormatter; }
|
||||
set { if (PropertyUtil.SetClass(ref m_NumericFormatter, value)) SetComponentDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// The radius of rounded corner. Its unit is px. Use array to respectively specify the 4 corner radiuses((clockwise upper left, upper right, bottom right and bottom left)).
|
||||
/// ||圆角半径。用数组分别指定4个圆角半径(顺时针左上,右上,右下,左下)。
|
||||
/// </summary>
|
||||
public float[] cornerRadius
|
||||
{
|
||||
get { return m_CornerRadius; }
|
||||
set { if (PropertyUtil.SetClass(ref m_CornerRadius, value, true)) SetVerticesDirty(); }
|
||||
}
|
||||
|
||||
public Color32 GetColor()
|
||||
{
|
||||
if (m_Opacity == 1 || m_Color.a == 0)
|
||||
return m_Color;
|
||||
|
||||
var color = m_Color;
|
||||
color.a = (byte) (color.a * m_Opacity);
|
||||
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)
|
||||
return m_Color0;
|
||||
|
||||
var color = m_Color0;
|
||||
color.a = (byte) (color.a * m_Opacity);
|
||||
return color;
|
||||
}
|
||||
|
||||
public Color32 GetColor(Color32 defaultColor)
|
||||
{
|
||||
var color = ChartHelper.IsClearColor(m_Color) ? defaultColor : m_Color;
|
||||
|
||||
if (m_Opacity == 1 || color.a == 0)
|
||||
return color;
|
||||
|
||||
color.a = (byte) (color.a * m_Opacity);
|
||||
return color;
|
||||
}
|
||||
|
||||
public Color32 GetColor0(Color32 defaultColor)
|
||||
{
|
||||
var color = ChartHelper.IsClearColor(m_Color0) ? defaultColor : m_Color0;
|
||||
|
||||
if (m_Opacity == 1 || color.a == 0)
|
||||
return color;
|
||||
|
||||
color.a = (byte) (color.a * m_Opacity);
|
||||
return color;
|
||||
}
|
||||
|
||||
public Color32 GetBorderColor(Color32 defaultColor)
|
||||
{
|
||||
var color = ChartHelper.IsClearColor(m_BorderColor) ? defaultColor : m_BorderColor;
|
||||
|
||||
if (m_Opacity == 1 || color.a == 0)
|
||||
return color;
|
||||
|
||||
color.a = (byte) (color.a * m_Opacity);
|
||||
return color;
|
||||
}
|
||||
|
||||
public Color32 GetBorderColor0(Color32 defaultColor)
|
||||
{
|
||||
var color = ChartHelper.IsClearColor(m_BorderColor0) ? defaultColor : m_BorderColor0;
|
||||
|
||||
if (m_Opacity == 1 || color.a == 0)
|
||||
return color;
|
||||
|
||||
color.a = (byte) (color.a * m_Opacity);
|
||||
return color;
|
||||
}
|
||||
|
||||
public bool IsNeedGradient()
|
||||
{
|
||||
return !ChartHelper.IsClearColor(m_ToColor) || !ChartHelper.IsClearColor(m_ToColor2);
|
||||
}
|
||||
|
||||
public Color32 GetGradientColor(float value, Color32 defaultColor)
|
||||
{
|
||||
if (!IsNeedGradient())
|
||||
return ChartConst.clearColor32;
|
||||
|
||||
value = Mathf.Clamp01(value);
|
||||
var startColor = ChartHelper.IsClearColor(m_Color) ? defaultColor : m_Color;
|
||||
Color32 color;
|
||||
|
||||
if (!ChartHelper.IsClearColor(m_ToColor2))
|
||||
{
|
||||
if (value <= 0.5f)
|
||||
color = Color32.Lerp(startColor, m_ToColor, 2 * value);
|
||||
else
|
||||
color = Color32.Lerp(m_ToColor, m_ToColor2, 2 * (value - 0.5f));
|
||||
}
|
||||
else
|
||||
{
|
||||
color = Color32.Lerp(startColor, m_ToColor, value);
|
||||
}
|
||||
if (m_Opacity != 1)
|
||||
{
|
||||
color.a = (byte) (color.a * m_Opacity);
|
||||
}
|
||||
return color;
|
||||
}
|
||||
|
||||
public bool IsNeedCorner()
|
||||
{
|
||||
if (m_CornerRadius == null) return false;
|
||||
foreach (var value in m_CornerRadius)
|
||||
{
|
||||
if (value != 0) return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 3ca9b30f9779c4a16b60cc21334828b0
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,57 @@
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
namespace XCharts.Runtime
|
||||
{
|
||||
[System.Serializable]
|
||||
public class Level : ChildComponent
|
||||
{
|
||||
[SerializeField][Since("v3.10.0")] private int m_Depth = 0;
|
||||
[SerializeField] private LabelStyle m_Label = new LabelStyle();
|
||||
[SerializeField] private LabelStyle m_UpperLabel = new LabelStyle();
|
||||
[SerializeField][Since("v3.10.0")] private LineStyle m_LineStyle = new LineStyle();
|
||||
[SerializeField] private ItemStyle m_ItemStyle = new ItemStyle();
|
||||
|
||||
/// <summary>
|
||||
/// the depth of level.
|
||||
/// ||层级深度。
|
||||
/// </summary>
|
||||
public int depth { get { return m_Depth; } set { m_Depth = value; } }
|
||||
/// <summary>
|
||||
/// the label style of level.
|
||||
/// ||文本标签样式。
|
||||
/// </summary>
|
||||
public LabelStyle label { get { return m_Label; } }
|
||||
/// <summary>
|
||||
/// the upper label style of level.
|
||||
/// ||上方的文本标签样式。
|
||||
/// </summary>
|
||||
public LabelStyle upperLabel { get { return m_UpperLabel; } }
|
||||
/// <summary>
|
||||
/// the line style of level.
|
||||
/// ||线条样式。
|
||||
/// </summary>
|
||||
public LineStyle lineStyle { get { return m_LineStyle; } }
|
||||
/// <summary>
|
||||
/// the item style of level.
|
||||
/// ||数据项样式。
|
||||
/// </summary>
|
||||
public ItemStyle itemStyle { get { return m_ItemStyle; } }
|
||||
}
|
||||
|
||||
[System.Serializable]
|
||||
public class LevelStyle : ChildComponent
|
||||
{
|
||||
[SerializeField] private bool m_Show = false;
|
||||
[SerializeField] private List<Level> m_Levels = new List<Level>() { new Level() };
|
||||
|
||||
/// <summary>
|
||||
/// 是否启用LevelStyle
|
||||
/// </summary>
|
||||
public bool show { get { return m_Show; } set { m_Show = value; } }
|
||||
/// <summary>
|
||||
/// 各层节点对应的配置。当enableLevels为true时生效,levels[0]对应的第一层的配置,levels[1]对应第二层,依次类推。当levels中没有对应层时用默认的设置。
|
||||
/// </summary>
|
||||
public List<Level> levels { get { return m_Levels; } }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 3760e89d324d7413d95a2ac1d434a546
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,63 @@
|
||||
using System;
|
||||
using UnityEngine;
|
||||
|
||||
namespace XCharts.Runtime
|
||||
{
|
||||
/// <summary>
|
||||
/// </summary>
|
||||
[Serializable]
|
||||
public class LineArrow : ChildComponent, ISerieComponent
|
||||
{
|
||||
public enum Position
|
||||
{
|
||||
/// <summary>
|
||||
/// 末端箭头
|
||||
/// </summary>
|
||||
End,
|
||||
/// <summary>
|
||||
/// 头端箭头
|
||||
/// </summary>
|
||||
Start
|
||||
}
|
||||
|
||||
[SerializeField] private bool m_Show;
|
||||
[SerializeField] private Position m_Position;
|
||||
[SerializeField]
|
||||
private ArrowStyle m_Arrow = new ArrowStyle()
|
||||
{
|
||||
width = 10,
|
||||
height = 15,
|
||||
offset = 0,
|
||||
dent = 3
|
||||
};
|
||||
|
||||
/// <summary>
|
||||
/// Whether to show the arrow.
|
||||
/// ||是否显示箭头。
|
||||
/// </summary>
|
||||
public bool show
|
||||
{
|
||||
get { return m_Show; }
|
||||
set { if (PropertyUtil.SetStruct(ref m_Show, value)) SetVerticesDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// The position of arrow.
|
||||
/// ||箭头位置。
|
||||
/// </summary>
|
||||
public Position position
|
||||
{
|
||||
get { return m_Position; }
|
||||
set { if (PropertyUtil.SetStruct(ref m_Position, value)) SetVerticesDirty(); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// the arrow of line.
|
||||
/// ||箭头。
|
||||
/// </summary>
|
||||
public ArrowStyle arrow
|
||||
{
|
||||
get { return m_Arrow; }
|
||||
set { if (PropertyUtil.SetClass(ref m_Arrow, value)) SetVerticesDirty(); }
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 8f2455acb3ba34409896bf03ddba593e
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,285 @@
|
||||
using UnityEngine;
|
||||
|
||||
namespace XCharts.Runtime
|
||||
{
|
||||
/// <summary>
|
||||
/// The style of line.
|
||||
/// ||线条样式。
|
||||
/// 注: 修改 lineStyle 中的颜色不会影响图例颜色,如果需要图例颜色和折线图颜色一致,需修改 itemStyle.color,线条颜色默认也会取该颜色。
|
||||
/// toColor,toColor2可设置水平方向的渐变,如需要设置垂直方向的渐变,可使用VisualMap。
|
||||
/// </summary>
|
||||
[System.Serializable]
|
||||
public class LineStyle : ChildComponent, ISerieDataComponent
|
||||
{
|
||||
/// <summary>
|
||||
/// 线的类型。
|
||||
/// </summary>
|
||||
public enum Type
|
||||
{
|
||||
/// <summary>
|
||||
/// 实线
|
||||
/// </summary>
|
||||
Solid,
|
||||
/// <summary>
|
||||
/// 虚线
|
||||
/// </summary>
|
||||
Dashed,
|
||||
/// <summary>
|
||||
/// 点线
|
||||
/// </summary>
|
||||
Dotted,
|
||||
/// <summary>
|
||||
/// 点划线
|
||||
/// </summary>
|
||||
DashDot,
|
||||
/// <summary>
|
||||
/// 双点划线
|
||||
/// </summary>
|
||||
DashDotDot,
|
||||
None,
|
||||
}
|
||||
|
||||
[SerializeField] private bool m_Show = true;
|
||||
[SerializeField] private Type m_Type = Type.Solid;
|
||||
[SerializeField] private Color32 m_Color;
|
||||
[SerializeField] private Color32 m_ToColor;
|
||||
[SerializeField] private Color32 m_ToColor2;
|
||||
[SerializeField] private float m_Width = 0;
|
||||
[SerializeField] private float m_Length = 0;
|
||||
[SerializeField][Range(0, 1)] private float m_Opacity = 1;
|
||||
[SerializeField][Since("v3.8.1")] private float m_DashLength = 4;
|
||||
[SerializeField][Since("v3.8.1")] private float m_DotLength = 2;
|
||||
[SerializeField][Since("v3.8.1")] private float m_GapLength = 2;
|
||||
|
||||
/// <summary>
|
||||
/// Whether show line.
|
||||
/// ||是否显示线条。当作为子组件,它的父组件有参数控制是否显示时,改参数无效。
|
||||
/// </summary>
|
||||
public bool show
|
||||
{
|
||||
get { return m_Show; }
|
||||
set { if (PropertyUtil.SetStruct(ref m_Show, value)) SetVerticesDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// the type of line.
|
||||
/// ||线的类型。
|
||||
/// </summary>
|
||||
public Type type
|
||||
{
|
||||
get { return m_Type; }
|
||||
set { if (PropertyUtil.SetStruct(ref m_Type, value)) SetVerticesDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// the color of line, default use serie color.
|
||||
/// ||线的颜色。
|
||||
/// </summary>
|
||||
public Color32 color
|
||||
{
|
||||
get { return m_Color; }
|
||||
set { if (PropertyUtil.SetColor(ref m_Color, value)) SetVerticesDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// the middle color of line, default use serie color.
|
||||
/// ||线的渐变颜色(需要水平方向渐变时)。
|
||||
/// </summary>
|
||||
public Color32 toColor
|
||||
{
|
||||
get { return m_ToColor; }
|
||||
set { if (PropertyUtil.SetColor(ref m_ToColor, value)) SetVerticesDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// the end color of line, default use serie color.
|
||||
/// ||线的渐变颜色2(需要水平方向三个渐变色的渐变时)。
|
||||
/// </summary>
|
||||
public Color32 toColor2
|
||||
{
|
||||
get { return m_ToColor2; }
|
||||
set { if (PropertyUtil.SetColor(ref m_ToColor2, value)) SetVerticesDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// the width of line.
|
||||
/// ||线宽。
|
||||
/// </summary>
|
||||
public float width
|
||||
{
|
||||
get { return m_Width; }
|
||||
set { if (PropertyUtil.SetStruct(ref m_Width, value)) SetVerticesDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// the length of line.
|
||||
/// ||线长。
|
||||
/// </summary>
|
||||
public float length
|
||||
{
|
||||
get { return m_Length; }
|
||||
set { if (PropertyUtil.SetStruct(ref m_Length, value)) SetVerticesDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// Opacity of the line. Supports value from 0 to 1, and the line will not be drawn when set to 0.
|
||||
/// ||线的透明度。支持从 0 到 1 的数字,为 0 时不绘制该图形。
|
||||
/// </summary>
|
||||
public float opacity
|
||||
{
|
||||
get { return m_Opacity; }
|
||||
set { if (PropertyUtil.SetStruct(ref m_Opacity, value)) SetVerticesDirty(); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// the length of dash line. default value is 0, which means the length of dash line is 12 times of line width.
|
||||
/// Represents a multiple of the number of segments in a line chart.
|
||||
/// ||虚线的长度。默认0时为线条宽度的12倍。在折线图中代表分割段数的倍数。
|
||||
/// </summary>
|
||||
public float dashLength
|
||||
{
|
||||
get { return m_DashLength; }
|
||||
set { if (PropertyUtil.SetStruct(ref m_DashLength, value)) SetVerticesDirty(); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// the length of dot line. default value is 0, which means the length of dot line is 2 times of line width.
|
||||
/// Represents a multiple of the number of segments in a line chart.
|
||||
/// ||点线的长度。默认0时为线条宽度的3倍。在折线图中代表分割段数的倍数。
|
||||
/// </summary>
|
||||
public float dotLength
|
||||
{
|
||||
get { return m_DotLength; }
|
||||
set { if (PropertyUtil.SetStruct(ref m_DotLength, value)) SetVerticesDirty(); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// the length of gap line. default value is 0, which means the length of gap line is 3 times of line width.
|
||||
/// Represents a multiple of the number of segments in a line chart.
|
||||
/// ||点线的长度。默认0时为线条宽度的3倍。在折线图中代表分割段数的倍数。
|
||||
/// </summary>
|
||||
public float gapLength
|
||||
{
|
||||
get { return m_GapLength; }
|
||||
set { if (PropertyUtil.SetStruct(ref m_GapLength, value)) SetVerticesDirty(); }
|
||||
}
|
||||
|
||||
public LineStyle()
|
||||
{ }
|
||||
|
||||
public LineStyle(float width)
|
||||
{
|
||||
this.width = width;
|
||||
}
|
||||
|
||||
public LineStyle(LineStyle.Type type)
|
||||
{
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public LineStyle(LineStyle.Type type, float width)
|
||||
{
|
||||
this.type = type;
|
||||
this.width = width;
|
||||
}
|
||||
|
||||
public LineStyle Clone()
|
||||
{
|
||||
var lineStyle = new LineStyle();
|
||||
lineStyle.show = show;
|
||||
lineStyle.type = type;
|
||||
lineStyle.color = color;
|
||||
lineStyle.toColor = toColor;
|
||||
lineStyle.toColor2 = toColor2;
|
||||
lineStyle.width = width;
|
||||
lineStyle.opacity = opacity;
|
||||
lineStyle.dashLength = dashLength;
|
||||
lineStyle.dotLength = dotLength;
|
||||
lineStyle.gapLength = gapLength;
|
||||
return lineStyle;
|
||||
}
|
||||
|
||||
public void Copy(LineStyle lineStyle)
|
||||
{
|
||||
show = lineStyle.show;
|
||||
type = lineStyle.type;
|
||||
color = lineStyle.color;
|
||||
toColor = lineStyle.toColor;
|
||||
toColor2 = lineStyle.toColor2;
|
||||
width = lineStyle.width;
|
||||
opacity = lineStyle.opacity;
|
||||
dashLength = lineStyle.dashLength;
|
||||
dotLength = lineStyle.dotLength;
|
||||
gapLength = lineStyle.gapLength;
|
||||
}
|
||||
|
||||
public bool IsNotSolidLine()
|
||||
{
|
||||
return type != Type.Solid && type != Type.None;
|
||||
}
|
||||
|
||||
public Color32 GetColor()
|
||||
{
|
||||
if (m_Opacity == 1)
|
||||
return m_Color;
|
||||
|
||||
var color = m_Color;
|
||||
color.a = (byte)(color.a * m_Opacity);
|
||||
return color;
|
||||
}
|
||||
|
||||
public bool IsNeedGradient()
|
||||
{
|
||||
return !ChartHelper.IsClearColor(m_ToColor) || !ChartHelper.IsClearColor(m_ToColor2);
|
||||
}
|
||||
|
||||
public Color32 GetGradientColor(float value, Color32 defaultColor)
|
||||
{
|
||||
var color = ChartConst.clearColor32;
|
||||
if (!IsNeedGradient())
|
||||
return color;
|
||||
|
||||
value = Mathf.Clamp01(value);
|
||||
var startColor = ChartHelper.IsClearColor(m_Color) ? defaultColor : m_Color;
|
||||
|
||||
if (!ChartHelper.IsClearColor(m_ToColor2))
|
||||
{
|
||||
if (value <= 0.5f)
|
||||
color = Color32.Lerp(startColor, m_ToColor, 2 * value);
|
||||
else
|
||||
color = Color32.Lerp(m_ToColor, m_ToColor2, 2 * (value - 0.5f));
|
||||
}
|
||||
else
|
||||
{
|
||||
color = Color32.Lerp(startColor, m_ToColor, value);
|
||||
}
|
||||
if (m_Opacity != 1)
|
||||
{
|
||||
color.a = (byte)(color.a * m_Opacity);
|
||||
}
|
||||
return color;
|
||||
}
|
||||
|
||||
public Type GetType(Type themeType)
|
||||
{
|
||||
return type == Type.None ? themeType : type;
|
||||
}
|
||||
|
||||
public float GetWidth(float themeWidth)
|
||||
{
|
||||
return width == 0 ? themeWidth : width;
|
||||
}
|
||||
|
||||
public float GetLength(float themeLength)
|
||||
{
|
||||
return length == 0 ? themeLength : length;
|
||||
}
|
||||
|
||||
public Color32 GetColor(Color32 themeColor)
|
||||
{
|
||||
if (!ChartHelper.IsClearColor(color))
|
||||
{
|
||||
return GetColor();
|
||||
}
|
||||
else
|
||||
{
|
||||
var color = themeColor;
|
||||
color.a = (byte)(color.a * opacity);
|
||||
return color;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 092f08a2daa4b4013a72ffc3c9a18f85
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,423 @@
|
||||
using System;
|
||||
using UnityEngine;
|
||||
#if dUI_TextMeshPro
|
||||
using TMPro;
|
||||
#endif
|
||||
|
||||
namespace XCharts.Runtime
|
||||
{
|
||||
/// <summary>
|
||||
/// Location type. Quick to set the general location.
|
||||
/// ||位置类型。通过Align快速设置大体位置,再通过left,right,top,bottom微调具体位置。
|
||||
/// </summary>
|
||||
[Serializable]
|
||||
public class Location : ChildComponent, IPropertyChanged
|
||||
{
|
||||
/// <summary>
|
||||
/// 对齐方式
|
||||
/// </summary>
|
||||
public enum Align
|
||||
{
|
||||
TopLeft,
|
||||
TopRight,
|
||||
TopCenter,
|
||||
BottomLeft,
|
||||
BottomRight,
|
||||
BottomCenter,
|
||||
Center,
|
||||
CenterLeft,
|
||||
CenterRight
|
||||
}
|
||||
|
||||
[SerializeField] private Align m_Align = Align.TopCenter;
|
||||
[SerializeField] private float m_Left;
|
||||
[SerializeField] private float m_Right;
|
||||
[SerializeField] private float m_Top;
|
||||
[SerializeField] private float m_Bottom;
|
||||
|
||||
private TextAnchor m_TextAlignment;
|
||||
#if dUI_TextMeshPro
|
||||
private TextAlignmentOptions m_TMPTextAlignment;
|
||||
#endif
|
||||
private Vector2 m_AnchorMin;
|
||||
private Vector2 m_AnchorMax;
|
||||
private Vector2 m_Pivot;
|
||||
|
||||
/// <summary>
|
||||
/// 对齐方式。
|
||||
/// </summary>
|
||||
public Align align
|
||||
{
|
||||
get { return m_Align; }
|
||||
set { if (PropertyUtil.SetStruct(ref m_Align, value)) { SetComponentDirty(); UpdateAlign(); } }
|
||||
}
|
||||
/// <summary>
|
||||
/// Distance between component and the left side of the container.
|
||||
/// ||离容器左侧的距离。
|
||||
/// </summary>
|
||||
public float left
|
||||
{
|
||||
get { return m_Left; }
|
||||
set { if (PropertyUtil.SetStruct(ref m_Left, value)) { SetComponentDirty(); UpdateAlign(); } }
|
||||
}
|
||||
/// <summary>
|
||||
/// Distance between component and the left side of the container.
|
||||
/// ||离容器右侧的距离。
|
||||
/// </summary>
|
||||
public float right
|
||||
{
|
||||
get { return m_Right; }
|
||||
set { if (PropertyUtil.SetStruct(ref m_Right, value)) { SetComponentDirty(); UpdateAlign(); } }
|
||||
}
|
||||
/// <summary>
|
||||
/// Distance between component and the left side of the container.
|
||||
/// ||离容器上侧的距离。
|
||||
/// </summary>
|
||||
public float top
|
||||
{
|
||||
get { return m_Top; }
|
||||
set { if (PropertyUtil.SetStruct(ref m_Top, value)) { SetComponentDirty(); UpdateAlign(); } }
|
||||
}
|
||||
/// <summary>
|
||||
/// Distance between component and the left side of the container.
|
||||
/// ||离容器下侧的距离。
|
||||
/// </summary>
|
||||
public float bottom
|
||||
{
|
||||
get { return m_Bottom; }
|
||||
set { if (PropertyUtil.SetStruct(ref m_Bottom, value)) { SetComponentDirty(); UpdateAlign(); } }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// the anchor of text.
|
||||
/// ||Location对应的Anchor锚点
|
||||
/// </summary>
|
||||
public TextAnchor runtimeTextAlignment { get { return m_TextAlignment; } }
|
||||
|
||||
#if dUI_TextMeshPro
|
||||
public TextAlignmentOptions runtimeTMPTextAlignment { get { return m_TMPTextAlignment; } }
|
||||
#endif
|
||||
/// <summary>
|
||||
/// the minimum achor.
|
||||
/// ||Location对应的anchorMin。
|
||||
/// </summary>
|
||||
public Vector2 runtimeAnchorMin { get { return m_AnchorMin; } }
|
||||
/// <summary>
|
||||
/// the maximun achor.
|
||||
/// ||Location对应的anchorMax.
|
||||
/// ||</summary>
|
||||
public Vector2 runtimeAnchorMax { get { return m_AnchorMax; } }
|
||||
/// <summary>
|
||||
/// the povot.
|
||||
/// ||Loation对应的中心点。
|
||||
/// </summary>
|
||||
public Vector2 runtimePivot { get { return m_Pivot; } }
|
||||
public float runtimeLeft { get; private set; }
|
||||
public float runtimeRight { get; private set; }
|
||||
public float runtimeBottom { get; private set; }
|
||||
public float runtimeTop { get; private set; }
|
||||
|
||||
public static Location defaultLeft
|
||||
{
|
||||
get
|
||||
{
|
||||
return new Location()
|
||||
{
|
||||
align = Align.CenterLeft,
|
||||
left = 0.03f,
|
||||
right = 0,
|
||||
top = 0,
|
||||
bottom = 0
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
public static Location defaultRight
|
||||
{
|
||||
get
|
||||
{
|
||||
return new Location()
|
||||
{
|
||||
align = Align.CenterRight,
|
||||
left = 0,
|
||||
right = 0.03f,
|
||||
top = 0,
|
||||
bottom = 0
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
public static Location defaultTop
|
||||
{
|
||||
get
|
||||
{
|
||||
return new Location()
|
||||
{
|
||||
align = Align.TopCenter,
|
||||
left = 0,
|
||||
right = 0,
|
||||
top = 0.03f,
|
||||
bottom = 0
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
public static Location defaultBottom
|
||||
{
|
||||
get
|
||||
{
|
||||
return new Location()
|
||||
{
|
||||
align = Align.BottomCenter,
|
||||
left = 0,
|
||||
right = 0,
|
||||
top = 0,
|
||||
bottom = 0.03f
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
private void UpdateAlign()
|
||||
{
|
||||
switch (m_Align)
|
||||
{
|
||||
case Align.BottomCenter:
|
||||
m_TextAlignment = TextAnchor.LowerCenter;
|
||||
#if dUI_TextMeshPro
|
||||
m_TMPTextAlignment = TextAlignmentOptions.Bottom;
|
||||
#endif
|
||||
m_AnchorMin = new Vector2(0.5f, 0);
|
||||
m_AnchorMax = new Vector2(0.5f, 0);
|
||||
m_Pivot = new Vector2(0.5f, 0);
|
||||
break;
|
||||
case Align.BottomLeft:
|
||||
m_TextAlignment = TextAnchor.LowerLeft;
|
||||
#if dUI_TextMeshPro
|
||||
m_TMPTextAlignment = TextAlignmentOptions.BottomLeft;
|
||||
#endif
|
||||
m_AnchorMin = new Vector2(0, 0);
|
||||
m_AnchorMax = new Vector2(0, 0);
|
||||
m_Pivot = new Vector2(0, 0);
|
||||
break;
|
||||
case Align.BottomRight:
|
||||
m_TextAlignment = TextAnchor.LowerRight;
|
||||
#if dUI_TextMeshPro
|
||||
m_TMPTextAlignment = TextAlignmentOptions.BottomRight;
|
||||
#endif
|
||||
m_AnchorMin = new Vector2(1, 0);
|
||||
m_AnchorMax = new Vector2(1, 0);
|
||||
m_Pivot = new Vector2(1, 0);
|
||||
break;
|
||||
case Align.Center:
|
||||
m_TextAlignment = TextAnchor.MiddleCenter;
|
||||
#if dUI_TextMeshPro
|
||||
m_TMPTextAlignment = TextAlignmentOptions.Center;
|
||||
#endif
|
||||
m_AnchorMin = new Vector2(0.5f, 0.5f);
|
||||
m_AnchorMax = new Vector2(0.5f, 0.5f);
|
||||
m_Pivot = new Vector2(0.5f, 0.5f);
|
||||
break;
|
||||
case Align.CenterLeft:
|
||||
m_TextAlignment = TextAnchor.MiddleLeft;
|
||||
#if dUI_TextMeshPro
|
||||
m_TMPTextAlignment = TextAlignmentOptions.Left;
|
||||
#endif
|
||||
m_AnchorMin = new Vector2(0, 0.5f);
|
||||
m_AnchorMax = new Vector2(0, 0.5f);
|
||||
m_Pivot = new Vector2(0, 0.5f);
|
||||
break;
|
||||
case Align.CenterRight:
|
||||
m_TextAlignment = TextAnchor.MiddleRight;
|
||||
#if dUI_TextMeshPro
|
||||
m_TMPTextAlignment = TextAlignmentOptions.Right;
|
||||
#endif
|
||||
m_AnchorMin = new Vector2(1, 0.5f);
|
||||
m_AnchorMax = new Vector2(1, 0.5f);
|
||||
m_Pivot = new Vector2(1, 0.5f);
|
||||
break;
|
||||
case Align.TopCenter:
|
||||
m_TextAlignment = TextAnchor.UpperCenter;
|
||||
#if dUI_TextMeshPro
|
||||
m_TMPTextAlignment = TextAlignmentOptions.Top;
|
||||
#endif
|
||||
m_AnchorMin = new Vector2(0.5f, 1);
|
||||
m_AnchorMax = new Vector2(0.5f, 1);
|
||||
m_Pivot = new Vector2(0.5f, 1);
|
||||
break;
|
||||
case Align.TopLeft:
|
||||
m_TextAlignment = TextAnchor.UpperLeft;
|
||||
#if dUI_TextMeshPro
|
||||
m_TMPTextAlignment = TextAlignmentOptions.TopLeft;
|
||||
#endif
|
||||
m_AnchorMin = new Vector2(0, 1);
|
||||
m_AnchorMax = new Vector2(0, 1);
|
||||
m_Pivot = new Vector2(0, 1);
|
||||
break;
|
||||
case Align.TopRight:
|
||||
m_TextAlignment = TextAnchor.UpperRight;
|
||||
#if dUI_TextMeshPro
|
||||
m_TMPTextAlignment = TextAlignmentOptions.TopRight;
|
||||
#endif
|
||||
m_AnchorMin = new Vector2(1, 1);
|
||||
m_AnchorMax = new Vector2(1, 1);
|
||||
m_Pivot = new Vector2(1, 1);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
public bool IsBottom()
|
||||
{
|
||||
switch (m_Align)
|
||||
{
|
||||
case Align.BottomCenter:
|
||||
case Align.BottomLeft:
|
||||
case Align.BottomRight:
|
||||
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public bool IsTop()
|
||||
{
|
||||
switch (m_Align)
|
||||
{
|
||||
case Align.TopCenter:
|
||||
case Align.TopLeft:
|
||||
case Align.TopRight:
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public bool IsCenter()
|
||||
{
|
||||
switch (m_Align)
|
||||
{
|
||||
case Align.Center:
|
||||
case Align.CenterLeft:
|
||||
case Align.CenterRight:
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public void UpdateRuntimeData(float chartWidth, float chartHeight)
|
||||
{
|
||||
runtimeLeft = left <= 1 ? left * chartWidth : left;
|
||||
runtimeRight = right <= 1 ? right * chartWidth : right;
|
||||
runtimeTop = top <= 1 ? top * chartHeight : top;
|
||||
runtimeBottom = bottom <= 1 ? bottom * chartHeight : bottom;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 返回在坐标系中的具体位置
|
||||
/// </summary>
|
||||
/// <param name="chartWidth"></param>
|
||||
/// <param name="chartHeight"></param>
|
||||
/// <returns></returns>
|
||||
public Vector3 GetPosition(float chartWidth, float chartHeight)
|
||||
{
|
||||
UpdateRuntimeData(chartWidth, chartHeight);
|
||||
switch (align)
|
||||
{
|
||||
case Align.BottomCenter:
|
||||
return new Vector3(chartWidth / 2, runtimeBottom);
|
||||
case Align.BottomLeft:
|
||||
return new Vector3(runtimeLeft, runtimeBottom);
|
||||
case Align.BottomRight:
|
||||
return new Vector3(chartWidth - runtimeRight, runtimeBottom);
|
||||
case Align.Center:
|
||||
return new Vector3(chartWidth / 2, chartHeight / 2);
|
||||
case Align.CenterLeft:
|
||||
return new Vector3(runtimeLeft, chartHeight / 2);
|
||||
case Align.CenterRight:
|
||||
return new Vector3(chartWidth - runtimeRight, chartHeight / 2);
|
||||
case Align.TopCenter:
|
||||
return new Vector3(chartWidth / 2, chartHeight - runtimeTop);
|
||||
case Align.TopLeft:
|
||||
return new Vector3(runtimeLeft, chartHeight - runtimeTop);
|
||||
case Align.TopRight:
|
||||
return new Vector3(chartWidth - runtimeRight, chartHeight - runtimeTop);
|
||||
default:
|
||||
return Vector2.zero;
|
||||
}
|
||||
}
|
||||
|
||||
public Rect GetRect(float graphX, float graphY, float graphWidth, float graphHeight, float rectWidth, float rectHeight)
|
||||
{
|
||||
UpdateRuntimeData(graphWidth, graphWidth);
|
||||
|
||||
float x, y, width, height;
|
||||
|
||||
width = rectWidth == 0 ? graphWidth - runtimeLeft - runtimeRight : rectWidth;
|
||||
height = rectHeight == 0 ? graphHeight - runtimeBottom - runtimeTop : rectHeight;
|
||||
|
||||
switch (align)
|
||||
{
|
||||
case Align.BottomCenter:
|
||||
x = graphX + runtimeLeft + (graphWidth - runtimeLeft - runtimeRight - width) / 2;
|
||||
y = graphY + runtimeBottom;
|
||||
break;
|
||||
|
||||
case Align.BottomLeft:
|
||||
x = graphX + runtimeLeft;
|
||||
y = graphY + runtimeBottom;
|
||||
break;
|
||||
|
||||
case Align.BottomRight:
|
||||
x = graphX + graphWidth - runtimeRight - width;
|
||||
y = graphY + runtimeBottom;
|
||||
break;
|
||||
|
||||
case Align.Center:
|
||||
x = graphX + runtimeLeft + (graphWidth - runtimeLeft - runtimeRight - width) / 2;
|
||||
y = graphY + runtimeBottom + (graphHeight - runtimeBottom - runtimeTop - height) / 2;
|
||||
break;
|
||||
|
||||
case Align.CenterLeft:
|
||||
x = graphX + runtimeLeft;
|
||||
y = graphY + runtimeBottom + (graphHeight - runtimeBottom - runtimeTop - height) / 2;
|
||||
break;
|
||||
|
||||
case Align.CenterRight:
|
||||
x = graphX + graphWidth - runtimeRight - width;
|
||||
y = graphY + runtimeBottom + (graphHeight - runtimeBottom - runtimeTop - height) / 2;
|
||||
break;
|
||||
|
||||
case Align.TopCenter:
|
||||
x = graphX + runtimeLeft + (graphWidth - runtimeLeft - runtimeRight - width) / 2;
|
||||
y = graphY + graphHeight - runtimeTop - height;
|
||||
break;
|
||||
|
||||
case Align.TopLeft:
|
||||
x = graphX + runtimeLeft;
|
||||
y = graphY + graphHeight - runtimeTop - height;
|
||||
break;
|
||||
|
||||
case Align.TopRight:
|
||||
x = graphX + graphWidth - runtimeRight - width;
|
||||
y = graphY + graphHeight - runtimeTop - height;
|
||||
break;
|
||||
|
||||
default:
|
||||
return new Rect(0, 0, 0, 0);
|
||||
}
|
||||
return new Rect(x, y, width, height);
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 属性变更时更新textAnchor,minAnchor,maxAnchor,pivot
|
||||
/// </summary>
|
||||
public void OnChanged()
|
||||
{
|
||||
UpdateAlign();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 7922ce86a6b0f4813a7f34e004b92e9a
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,73 @@
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
namespace XCharts.Runtime
|
||||
{
|
||||
/// <summary>
|
||||
/// 多样式数值。
|
||||
/// </summary>
|
||||
[Since("v3.8.0")]
|
||||
[System.Serializable]
|
||||
public class MLValue : ChildComponent
|
||||
{
|
||||
/// <summary>
|
||||
/// the type of value.
|
||||
/// ||数值类型。
|
||||
/// </summary>
|
||||
public enum Type
|
||||
{
|
||||
/// <summary>
|
||||
/// Percent value form.
|
||||
/// ||百分比形式。
|
||||
/// </summary>
|
||||
Percent,
|
||||
/// <summary>
|
||||
/// Absolute value form.
|
||||
/// ||绝对值形式。
|
||||
/// </summary>
|
||||
Absolute,
|
||||
/// <summary>
|
||||
/// Extra value form.
|
||||
/// ||额外形式。
|
||||
/// </summary>
|
||||
Extra
|
||||
}
|
||||
[SerializeField] private Type m_Type;
|
||||
[SerializeField] private float m_Value;
|
||||
|
||||
public Type type { get { return m_Type; } set { m_Type = value; } }
|
||||
public float value { get { return m_Value; } set { m_Value = value; } }
|
||||
|
||||
public MLValue(float value)
|
||||
{
|
||||
m_Type = Type.Percent;
|
||||
m_Value = value;
|
||||
}
|
||||
|
||||
public MLValue(Type type, float value)
|
||||
{
|
||||
m_Type = type;
|
||||
m_Value = value;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get the value by type.
|
||||
/// ||根据类型获取值。
|
||||
/// </summary>
|
||||
/// <param name="total">默认值</param>
|
||||
/// <returns></returns>
|
||||
public float GetValue(float total)
|
||||
{
|
||||
switch (m_Type)
|
||||
{
|
||||
case Type.Percent:
|
||||
return m_Value * total;
|
||||
case Type.Absolute:
|
||||
return m_Value;
|
||||
case Type.Extra:
|
||||
return total + m_Value;
|
||||
default: return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 10f15d7e58cf24fa6a1986793ba2a36b
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,62 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
namespace XCharts.Runtime
|
||||
{
|
||||
/// <summary>
|
||||
/// Marquee style. It can be used for the DataZoom component.
|
||||
/// 选取框样式。可用于DataZoom组件。
|
||||
/// </summary>
|
||||
[Since("v3.5.0")]
|
||||
[System.Serializable]
|
||||
public class MarqueeStyle : ChildComponent
|
||||
{
|
||||
[SerializeField][Since("v3.5.0")] private bool m_Apply = false;
|
||||
[SerializeField][Since("v3.5.0")] private bool m_RealRect = false;
|
||||
[SerializeField][Since("v3.5.0")] private AreaStyle m_AreaStyle = new AreaStyle();
|
||||
[SerializeField][Since("v3.5.0")] private LineStyle m_LineStyle = new LineStyle();
|
||||
|
||||
protected Action<DataZoom> m_OnStart;
|
||||
protected Action<DataZoom> m_OnGoing;
|
||||
protected Action<DataZoom> m_OnEnd;
|
||||
|
||||
/// <summary>
|
||||
/// The area style of marquee.
|
||||
/// ||选取框区域填充样式。
|
||||
/// </summary>
|
||||
public AreaStyle areaStyle { get { return m_AreaStyle; } set { m_AreaStyle = value; } }
|
||||
/// <summary>
|
||||
/// The line style of marquee border.
|
||||
/// ||选取框区域边框样式。
|
||||
/// </summary>
|
||||
public LineStyle lineStyle { get { return m_LineStyle; } set { m_LineStyle = value; } }
|
||||
/// <summary>
|
||||
/// Check whether the scope is applied to the DataZoom.
|
||||
/// If this parameter is set to true, the range after the selection is complete is the DataZoom selection range.
|
||||
/// ||选取框范围是否应用到DataZoom上。当为true时,框选结束后的范围即为DataZoom的选择范围。
|
||||
/// </summary>
|
||||
public bool apply { get { return m_Apply; } set { m_Apply = value; } }
|
||||
/// <summary>
|
||||
/// Whether to select the actual box selection area. When true,
|
||||
/// the actual range between the mouse's actual point and the end point is used as the box selection area.
|
||||
/// ||是否选取实际框选区域。当为true时,以鼠标的其实点和结束点间的实际范围作为框选区域。
|
||||
/// </summary>
|
||||
public bool realRect { get { return m_RealRect; } set { m_RealRect = value; } }
|
||||
/// <summary>
|
||||
/// Customize the callback to the start of the selection of the checkbox.
|
||||
/// ||自定义选取框开始选取时的回调。
|
||||
/// </summary>
|
||||
public Action<DataZoom> onStart { set { m_OnStart = value; } get { return m_OnStart; } }
|
||||
/// <summary>
|
||||
/// Custom checkboxes select ongoing callbacks.
|
||||
/// ||自定义选取框选取进行时的回调。
|
||||
/// </summary>
|
||||
public Action<DataZoom> onGoing { set { m_OnStart = value; } get { return m_OnStart; } }
|
||||
/// <summary>
|
||||
/// Customize the callback at the end of the selection.
|
||||
/// ||自定义选取框结束选取时的回调。
|
||||
/// </summary>
|
||||
public Action<DataZoom> onEnd { set { m_OnEnd = value; } get { return m_OnEnd; } }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: effa7d6629485469d91d41f896b9de8d
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,79 @@
|
||||
using System;
|
||||
using UnityEngine;
|
||||
|
||||
namespace XCharts.Runtime
|
||||
{
|
||||
/// <summary>
|
||||
/// padding setting of item or text.
|
||||
/// ||边距设置。
|
||||
/// </summary>
|
||||
[Serializable]
|
||||
public class Padding : ChildComponent
|
||||
{
|
||||
[SerializeField] protected bool m_Show = true;
|
||||
[SerializeField] protected float m_Top = 0;
|
||||
[SerializeField] protected float m_Right = 2f;
|
||||
[SerializeField] protected float m_Left = 2f;
|
||||
[SerializeField] protected float m_Bottom = 0;
|
||||
|
||||
public Padding() { }
|
||||
|
||||
public Padding(float top, float right, float bottom, float left)
|
||||
{
|
||||
SetPadding(top, right, bottom, left);
|
||||
}
|
||||
|
||||
public void SetPadding(float top, float right, float bottom, float left)
|
||||
{
|
||||
m_Top = top;;
|
||||
m_Right = right;
|
||||
m_Bottom = bottom;
|
||||
m_Left = left;
|
||||
}
|
||||
/// <summary>
|
||||
/// show padding.
|
||||
/// 是否显示。
|
||||
/// </summary>
|
||||
public bool show
|
||||
{
|
||||
get { return m_Show; }
|
||||
set { if (PropertyUtil.SetStruct(ref m_Show, value)) SetComponentDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// padding of top.
|
||||
/// ||顶部间距。
|
||||
/// </summary>
|
||||
public float top
|
||||
{
|
||||
get { return m_Top; }
|
||||
set { if (PropertyUtil.SetStruct(ref m_Top, value)) SetComponentDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// padding of right.
|
||||
/// ||右部间距。
|
||||
/// </summary>
|
||||
public float right
|
||||
{
|
||||
get { return m_Right; }
|
||||
set { if (PropertyUtil.SetStruct(ref m_Right, value)) SetComponentDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// padding of bottom.
|
||||
/// ||底部间距。
|
||||
/// </summary>
|
||||
public float bottom
|
||||
{
|
||||
get { return m_Bottom; }
|
||||
set { if (PropertyUtil.SetStruct(ref m_Bottom, value)) SetComponentDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// padding of left.
|
||||
/// ||左边间距。
|
||||
/// </summary>
|
||||
public float left
|
||||
{
|
||||
get { return m_Left; }
|
||||
set { if (PropertyUtil.SetStruct(ref m_Left, value)) SetComponentDirty(); }
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c4249907274734533ba65edb14987472
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,198 @@
|
||||
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 int m_DataIndex = 1;
|
||||
[SerializeField] private float m_DataScale = 1;
|
||||
[SerializeField] private SymbolSizeFunction m_SizeFunction;
|
||||
[SerializeField] private int m_StartIndex;
|
||||
[SerializeField] private int m_Interval;
|
||||
[SerializeField] private bool m_ForceShowLast = false;
|
||||
[SerializeField] private bool m_Repeat = false;
|
||||
[SerializeField][Since("v3.3.0")] private float m_MinSize = 0f;
|
||||
[SerializeField][Since("v3.3.0")] private float m_MaxSize = 0f;
|
||||
|
||||
public override void Reset()
|
||||
{
|
||||
base.Reset();
|
||||
m_SizeType = SymbolSizeType.Custom;
|
||||
m_DataIndex = 1;
|
||||
m_DataScale = 1;
|
||||
m_SizeFunction = null;
|
||||
m_StartIndex = 0;
|
||||
m_Interval = 0;
|
||||
m_ForceShowLast = false;
|
||||
m_Repeat = false;
|
||||
m_MinSize = 0f;
|
||||
m_MaxSize = 0f;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// the type of symbol size.
|
||||
/// ||标记图形的大小获取方式。
|
||||
/// </summary>
|
||||
public SymbolSizeType sizeType
|
||||
{
|
||||
get { return m_SizeType; }
|
||||
set { if (PropertyUtil.SetStruct(ref m_SizeType, 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 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 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>
|
||||
/// Minimum symbol size.
|
||||
/// ||图形最小尺寸。只在sizeType为SymbolSizeType.FromData时有效。
|
||||
/// </summary>
|
||||
public float minSize
|
||||
{
|
||||
get { return m_MinSize; }
|
||||
set { if (PropertyUtil.SetStruct(ref m_MinSize, value)) SetVerticesDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// Maximum symbol size.
|
||||
/// ||图形最大尺寸。只在sizeType为SymbolSizeType.FromData时有效。
|
||||
/// </summary>
|
||||
public float maxSize
|
||||
{
|
||||
get { return m_MaxSize; }
|
||||
set { if (PropertyUtil.SetStruct(ref m_MaxSize, value)) SetVerticesDirty(); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 根据指定的sizeType获得标记的大小
|
||||
/// </summary>
|
||||
public float GetSize(SerieData serieData, float themeSize)
|
||||
{
|
||||
switch (m_SizeType)
|
||||
{
|
||||
case SymbolSizeType.Custom:
|
||||
return size == 0 ? themeSize : size;
|
||||
case SymbolSizeType.FromData:
|
||||
if (serieData != null && dataIndex >= 0 && dataIndex < serieData.data.Count)
|
||||
{
|
||||
var value = (float) serieData.data[dataIndex] * m_DataScale;
|
||||
if (m_MinSize != 0 && value < m_MinSize) value = m_MinSize;
|
||||
if (m_MaxSize != 0 && value > m_MaxSize) value = m_MaxSize;
|
||||
return value;
|
||||
}
|
||||
else
|
||||
{
|
||||
return size == 0 ? themeSize : size;
|
||||
}
|
||||
case SymbolSizeType.Function:
|
||||
if (sizeFunction != null) return sizeFunction(themeSize, serieData);
|
||||
else return size == 0 ? themeSize : size;
|
||||
default:
|
||||
return size == 0 ? themeSize : size;
|
||||
}
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: cd2852f4c46ae4dbd8c105e62dcce9a2
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,26 @@
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
namespace XCharts.Runtime
|
||||
{
|
||||
[System.Serializable]
|
||||
public class StageColor : ChildComponent
|
||||
{
|
||||
[SerializeField] private float m_Percent;
|
||||
[SerializeField] private Color32 m_Color;
|
||||
/// <summary>
|
||||
/// 结束位置百分比。
|
||||
/// </summary>
|
||||
public float percent { get { return m_Percent; } set { m_Percent = value; } }
|
||||
/// <summary>
|
||||
/// 颜色。
|
||||
/// </summary>
|
||||
public Color32 color { get { return m_Color; } set { m_Color = value; } }
|
||||
|
||||
public StageColor(float percent, Color32 color)
|
||||
{
|
||||
m_Percent = percent;
|
||||
m_Color = color;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d40f9dfbc90e744858784753e0d7109d
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,230 @@
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
namespace XCharts.Runtime
|
||||
{
|
||||
/// <summary>
|
||||
/// the type of symbol.
|
||||
/// ||标记图形的类型。
|
||||
/// </summary>
|
||||
public enum SymbolType
|
||||
{
|
||||
/// <summary>
|
||||
/// 不显示标记。
|
||||
/// </summary>
|
||||
None,
|
||||
/// <summary>
|
||||
/// 自定义标记。
|
||||
/// </summary>
|
||||
Custom,
|
||||
/// <summary>
|
||||
/// 圆形。
|
||||
/// </summary>
|
||||
Circle,
|
||||
/// <summary>
|
||||
/// 空心圆。
|
||||
/// </summary>
|
||||
EmptyCircle,
|
||||
/// <summary>
|
||||
/// 正方形。可通过设置`itemStyle`的`cornerRadius`变成圆角矩形。
|
||||
/// </summary>
|
||||
Rect,
|
||||
/// <summary>
|
||||
/// 空心正方形。
|
||||
/// </summary>
|
||||
EmptyRect,
|
||||
/// <summary>
|
||||
/// 三角形。
|
||||
/// </summary>
|
||||
Triangle,
|
||||
/// <summary>
|
||||
/// 空心三角形。
|
||||
/// </summary>
|
||||
EmptyTriangle,
|
||||
/// <summary>
|
||||
/// 菱形。
|
||||
/// </summary>
|
||||
Diamond,
|
||||
/// <summary>
|
||||
/// 空心菱形。
|
||||
/// </summary>
|
||||
EmptyDiamond,
|
||||
/// <summary>
|
||||
/// 箭头。
|
||||
/// </summary>
|
||||
Arrow,
|
||||
/// <summary>
|
||||
/// 空心箭头。
|
||||
/// </summary>
|
||||
EmptyArrow,
|
||||
/// <summary>
|
||||
/// 加号。
|
||||
/// </summary>
|
||||
Plus,
|
||||
/// <summary>
|
||||
/// 减号。
|
||||
/// </summary>
|
||||
Minus,
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 系列数据项的标记的图形
|
||||
/// </summary>
|
||||
[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;
|
||||
[SerializeField][Since("v3.13.0")] protected float m_BorderWidth = 0f;
|
||||
[SerializeField][Since("v3.13.0")] protected Color32 m_EmptyColor;
|
||||
[SerializeField][Since("v3.13.0")] protected float m_Size2 = 0f;
|
||||
|
||||
public virtual void Reset()
|
||||
{
|
||||
m_Show = false;
|
||||
m_Type = SymbolType.EmptyCircle;
|
||||
m_Size = 0f;
|
||||
m_Size2 = 0f;
|
||||
m_Gap = 0;
|
||||
m_Width = 0f;
|
||||
m_Height = 0f;
|
||||
m_Offset = Vector2.zero;
|
||||
m_Image = null;
|
||||
m_ImageType = Image.Type.Simple;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Whether the symbol is showed.
|
||||
/// ||是否显示标记。
|
||||
/// </summary>
|
||||
public bool show
|
||||
{
|
||||
get { return m_Show; }
|
||||
set { if (PropertyUtil.SetStruct(ref m_Show, value)) SetAllDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// the type of symbol.
|
||||
/// ||标记类型。
|
||||
/// </summary>
|
||||
public SymbolType type
|
||||
{
|
||||
get { return m_Type; }
|
||||
set { if (PropertyUtil.SetStruct(ref m_Type, value)) SetVerticesDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// the size of symbol.
|
||||
/// ||标记的大小。
|
||||
/// </summary>
|
||||
public float size
|
||||
{
|
||||
get { return m_Size; }
|
||||
set { if (PropertyUtil.SetStruct(ref m_Size, value)) SetVerticesDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// the size of symbol.
|
||||
/// ||标记的大小。当为Rect时,size2表示高度。
|
||||
/// </summary>
|
||||
public float size2
|
||||
{
|
||||
get { return m_Size2; }
|
||||
set { if (PropertyUtil.SetStruct(ref m_Size2, value)) SetVerticesDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// the gap of symbol and line segment.
|
||||
/// ||图形标记和线条的间隙距离。
|
||||
/// </summary>
|
||||
public float gap
|
||||
{
|
||||
get { return m_Gap; }
|
||||
set { if (PropertyUtil.SetStruct(ref m_Gap, value)) SetVerticesDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// 图形的宽。
|
||||
/// </summary>
|
||||
public float width
|
||||
{
|
||||
get { return m_Width; }
|
||||
set { if (PropertyUtil.SetStruct(ref m_Width, value)) SetAllDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// 图形的高。
|
||||
/// </summary>
|
||||
public float height
|
||||
{
|
||||
get { return m_Height; }
|
||||
set { if (PropertyUtil.SetStruct(ref m_Height, value)) SetAllDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// 自定义的标记图形。
|
||||
/// </summary>
|
||||
public Sprite image
|
||||
{
|
||||
get { return m_Image; }
|
||||
set { if (PropertyUtil.SetClass(ref m_Image, value)) SetAllDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// the fill type of image.
|
||||
/// ||图形填充类型。
|
||||
/// </summary>
|
||||
public Image.Type imageType
|
||||
{
|
||||
get { return m_ImageType; }
|
||||
set { if (PropertyUtil.SetStruct(ref m_ImageType, value)) SetAllDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// 图形的偏移。
|
||||
/// </summary>
|
||||
public Vector2 offset
|
||||
{
|
||||
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(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// the border width of symbol.
|
||||
/// ||图形的边框宽度。
|
||||
/// </summary>
|
||||
public float borderWidth
|
||||
{
|
||||
get { return m_BorderWidth; }
|
||||
set { if (PropertyUtil.SetStruct(ref m_BorderWidth, value)) SetAllDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// the color of empty symbol.
|
||||
/// ||空心图形的颜色。
|
||||
/// </summary>
|
||||
public Color32 emptyColor
|
||||
{
|
||||
get { return m_EmptyColor; }
|
||||
set { if (PropertyUtil.SetStruct(ref m_EmptyColor, 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>
|
||||
/// the setting for effect scatter.
|
||||
/// ||带有涟漪特效动画的散点图的动画参数。
|
||||
/// </summary>
|
||||
public List<float> animationSize { get { return m_AnimationSize; } }
|
||||
|
||||
public Color32 GetColor(Color32 defaultColor)
|
||||
{
|
||||
return ChartHelper.IsClearColor(m_Color) ? defaultColor : m_Color;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 837d37f4d6f614b38bef9f075a64b6dc
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,150 @@
|
||||
using System;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
namespace XCharts.Runtime
|
||||
{
|
||||
/// <summary>
|
||||
/// Text character limitation and adaptation component. When the length of the text exceeds the set length,
|
||||
/// it is cropped and suffixes are appended to the end.Only valid in the category axis.
|
||||
/// ||文本字符限制和自适应。当文本长度超过设定的长度时进行裁剪,并将后缀附加在最后。
|
||||
/// 只在类目轴中有效。
|
||||
/// </summary>
|
||||
[Serializable]
|
||||
public class TextLimit : ChildComponent
|
||||
{
|
||||
[SerializeField] private bool m_Enable = false;
|
||||
[SerializeField] private float m_MaxWidth = 0;
|
||||
[SerializeField] private float m_Gap = 1;
|
||||
[SerializeField] private string m_Suffix = "...";
|
||||
|
||||
/// <summary>
|
||||
/// Whether to enable text limit.
|
||||
/// ||是否启用文本自适应。
|
||||
/// [default:true]
|
||||
/// </summary>
|
||||
public bool enable
|
||||
{
|
||||
get { return m_Enable; }
|
||||
set { if (PropertyUtil.SetStruct(ref m_Enable, value)) SetComponentDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// Set the maximum width. A default of 0 indicates automatic fetch; otherwise, custom.
|
||||
/// ||Clipping occurs when the width of the text is greater than this value.
|
||||
/// ||设定最大宽度。默认为0表示自动获取,否则表示自定义。当文本的宽度大于该值进行裁剪。
|
||||
/// </summary>
|
||||
public float maxWidth
|
||||
{
|
||||
get { return m_MaxWidth; }
|
||||
set { if (PropertyUtil.SetStruct(ref m_MaxWidth, value)) SetComponentDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// White pixel distance at both ends.
|
||||
/// ||两边留白像素距离。
|
||||
/// [default:10f]
|
||||
/// </summary>
|
||||
public float gap
|
||||
{
|
||||
get { return m_Gap; }
|
||||
set { if (PropertyUtil.SetStruct(ref m_Gap, value)) SetComponentDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// Suffixes when the length exceeds.
|
||||
/// ||长度超出时的后缀。
|
||||
/// [default: "..."]
|
||||
/// </summary>
|
||||
public string suffix
|
||||
{
|
||||
get { return m_Suffix; }
|
||||
set { if (PropertyUtil.SetClass(ref m_Suffix, value)) SetComponentDirty(); }
|
||||
}
|
||||
|
||||
private ChartText m_RelatedText;
|
||||
private float m_RelatedTextWidth = 0;
|
||||
|
||||
public TextLimit Clone()
|
||||
{
|
||||
var textLimit = new TextLimit();
|
||||
textLimit.enable = enable;
|
||||
textLimit.maxWidth = maxWidth;
|
||||
textLimit.gap = gap;
|
||||
textLimit.suffix = suffix;
|
||||
return textLimit;
|
||||
}
|
||||
|
||||
public void Copy(TextLimit textLimit)
|
||||
{
|
||||
enable = textLimit.enable;
|
||||
maxWidth = textLimit.maxWidth;
|
||||
gap = textLimit.gap;
|
||||
suffix = textLimit.suffix;
|
||||
}
|
||||
|
||||
public void SetRelatedText(ChartText txt, float labelWidth)
|
||||
{
|
||||
m_RelatedText = txt;
|
||||
m_RelatedTextWidth = labelWidth;
|
||||
}
|
||||
|
||||
public string GetLimitContent(string content)
|
||||
{
|
||||
float checkWidth = m_MaxWidth > 0 ? m_MaxWidth : m_RelatedTextWidth;
|
||||
if (m_RelatedText == null || checkWidth <= 0)
|
||||
{
|
||||
return content;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (m_Enable)
|
||||
{
|
||||
float len = m_RelatedText.GetPreferredWidth(content);
|
||||
float suffixLen = m_RelatedText.GetPreferredWidth(suffix);
|
||||
if (len >= checkWidth - m_Gap * 2)
|
||||
{
|
||||
return content.Substring(0, GetAdaptLength(content, suffixLen)) + suffix;
|
||||
}
|
||||
else
|
||||
{
|
||||
return content;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return content;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private int GetAdaptLength(string content, float suffixLen)
|
||||
{
|
||||
int start = 0;
|
||||
int middle = content.Length / 2;
|
||||
int end = content.Length;
|
||||
float checkWidth = m_MaxWidth > 0 ? m_MaxWidth : m_RelatedTextWidth;
|
||||
|
||||
float limit = checkWidth - m_Gap * 2 - suffixLen;
|
||||
if (limit < 0)
|
||||
return 0;
|
||||
|
||||
float len = 0;
|
||||
while (len != limit && middle != start)
|
||||
{
|
||||
len = m_RelatedText.GetPreferredWidth(content.Substring(0, middle));
|
||||
if (len < limit)
|
||||
{
|
||||
start = middle;
|
||||
}
|
||||
else if (len > limit)
|
||||
{
|
||||
end = middle;
|
||||
}
|
||||
else
|
||||
{
|
||||
break;
|
||||
}
|
||||
middle = (start + end) / 2;
|
||||
}
|
||||
return middle;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 3f49509a5de044535b1dd3f192f7008c
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,20 @@
|
||||
using System;
|
||||
using UnityEngine;
|
||||
|
||||
namespace XCharts.Runtime
|
||||
{
|
||||
/// <summary>
|
||||
/// Settings related to text.
|
||||
/// ||文本的内边距设置。
|
||||
/// </summary>
|
||||
[Serializable]
|
||||
public class TextPadding : Padding
|
||||
{
|
||||
public TextPadding() { }
|
||||
|
||||
public TextPadding(float top, float right, float bottom, float left)
|
||||
{
|
||||
SetPadding(top, right, bottom, left);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 407bba126a0854199a4686b44cc9407e
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,231 @@
|
||||
using System;
|
||||
using UnityEngine;
|
||||
#if dUI_TextMeshPro
|
||||
using TMPro;
|
||||
#endif
|
||||
|
||||
namespace XCharts.Runtime
|
||||
{
|
||||
/// <summary>
|
||||
/// Settings related to text.
|
||||
/// ||文本的相关设置。
|
||||
/// </summary>
|
||||
[Serializable]
|
||||
public class TextStyle : ChildComponent
|
||||
{
|
||||
[SerializeField] private bool m_Show = true;
|
||||
[SerializeField] private Font m_Font;
|
||||
[SerializeField] private bool m_AutoWrap = false;
|
||||
[SerializeField] private bool m_AutoAlign = true;
|
||||
[SerializeField] private float m_Rotate = 0;
|
||||
[SerializeField] private bool m_AutoColor = false;
|
||||
[SerializeField] private Color m_Color = Color.clear;
|
||||
[SerializeField] private int m_FontSize = 0;
|
||||
[SerializeField] private FontStyle m_FontStyle = FontStyle.Normal;
|
||||
[SerializeField] private float m_LineSpacing = 1f;
|
||||
[SerializeField] private TextAnchor m_Alignment = TextAnchor.MiddleCenter;
|
||||
#if dUI_TextMeshPro
|
||||
[SerializeField] private TMP_FontAsset m_TMPFont;
|
||||
[SerializeField] private FontStyles m_TMPFontStyle = FontStyles.Normal;
|
||||
[SerializeField][Since("v3.1.0")] private TMP_SpriteAsset m_TMPSpriteAsset;
|
||||
#endif
|
||||
public bool show
|
||||
{
|
||||
get { return m_Show; }
|
||||
set { if (PropertyUtil.SetStruct(ref m_Show, value)) SetComponentDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// Rotation of text.
|
||||
/// ||文本的旋转。
|
||||
/// [default: `0f`]
|
||||
/// </summary>
|
||||
public float rotate
|
||||
{
|
||||
get { return m_Rotate; }
|
||||
set { if (PropertyUtil.SetStruct(ref m_Rotate, value)) SetComponentDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// 是否开启自动颜色。当开启时,会自动设置颜色。
|
||||
/// </summary>
|
||||
public bool autoColor
|
||||
{
|
||||
get { return m_AutoColor; }
|
||||
set { if (PropertyUtil.SetStruct(ref m_AutoColor, value)) SetAllDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// the color of text.
|
||||
/// ||文本的颜色。
|
||||
/// [default: `Color.clear`]
|
||||
/// </summary>
|
||||
public Color color
|
||||
{
|
||||
get { return m_Color; }
|
||||
set { if (PropertyUtil.SetColor(ref m_Color, value)) SetComponentDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// the font of text. When `null`, the theme's font is used by default.
|
||||
/// ||文本字体。
|
||||
/// [default: null]
|
||||
/// </summary>
|
||||
public Font font
|
||||
{
|
||||
get { return m_Font; }
|
||||
set { if (PropertyUtil.SetClass(ref m_Font, value)) SetComponentDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// font size.
|
||||
/// ||文本字体大小。
|
||||
/// [default: 18]
|
||||
/// </summary>
|
||||
public int fontSize
|
||||
{
|
||||
get { return m_FontSize; }
|
||||
set { if (PropertyUtil.SetStruct(ref m_FontSize, value)) SetComponentDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// font style.
|
||||
/// ||文本字体的风格。
|
||||
/// [default: FontStyle.Normal]
|
||||
/// </summary>
|
||||
public FontStyle fontStyle
|
||||
{
|
||||
get { return m_FontStyle; }
|
||||
set { if (PropertyUtil.SetStruct(ref m_FontStyle, value)) SetComponentDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// text line spacing.
|
||||
/// ||行间距。
|
||||
/// [default: 1f]
|
||||
/// </summary>
|
||||
public float lineSpacing
|
||||
{
|
||||
get { return m_LineSpacing; }
|
||||
set { if (PropertyUtil.SetStruct(ref m_LineSpacing, value)) SetComponentDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// 是否自动换行。
|
||||
/// </summary>
|
||||
public bool autoWrap
|
||||
{
|
||||
get { return m_AutoWrap; }
|
||||
set { if (PropertyUtil.SetStruct(ref m_AutoWrap, value)) SetComponentDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// 文本是否让系统自动选对齐方式。为false时才会用alignment。
|
||||
/// </summary>
|
||||
public bool autoAlign
|
||||
{
|
||||
get { return m_AutoAlign; }
|
||||
set { if (PropertyUtil.SetStruct(ref m_AutoAlign, value)) SetComponentDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// 对齐方式。
|
||||
/// </summary>
|
||||
public TextAnchor alignment
|
||||
{
|
||||
get { return m_Alignment; }
|
||||
set { if (PropertyUtil.SetStruct(ref m_Alignment, value)) SetComponentDirty(); }
|
||||
}
|
||||
#if dUI_TextMeshPro
|
||||
/// <summary>
|
||||
/// the font of textmeshpro.
|
||||
/// ||TextMeshPro字体。
|
||||
/// </summary>
|
||||
public TMP_FontAsset tmpFont
|
||||
{
|
||||
get { return m_TMPFont; }
|
||||
set { if (PropertyUtil.SetClass(ref m_TMPFont, value)) SetComponentDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// the font style of TextMeshPro.
|
||||
/// ||TextMeshPro字体类型。
|
||||
/// </summary>
|
||||
public FontStyles tmpFontStyle
|
||||
{
|
||||
get { return m_TMPFontStyle; }
|
||||
set { if (PropertyUtil.SetStruct(ref m_TMPFontStyle, value)) SetComponentDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// the sprite asset of TextMeshPro.
|
||||
/// ||TextMeshPro的Sprite Asset。
|
||||
/// </summary>
|
||||
public TMP_SpriteAsset tmpSpriteAsset
|
||||
{
|
||||
get { return m_TMPSpriteAsset; }
|
||||
set { if (PropertyUtil.SetClass(ref m_TMPSpriteAsset, value)) SetComponentDirty(); }
|
||||
}
|
||||
#endif
|
||||
|
||||
public TextStyle() { }
|
||||
|
||||
public TextStyle(int fontSize)
|
||||
{
|
||||
this.fontSize = fontSize;
|
||||
}
|
||||
|
||||
public TextStyle(int fontSize, FontStyle fontStyle)
|
||||
{
|
||||
this.fontSize = fontSize;
|
||||
this.fontStyle = fontStyle;
|
||||
}
|
||||
|
||||
public TextStyle(int fontSize, FontStyle fontStyle, Color color)
|
||||
{
|
||||
this.fontSize = fontSize;
|
||||
this.fontStyle = fontStyle;
|
||||
this.color = color;
|
||||
}
|
||||
|
||||
public TextStyle(int fontSize, FontStyle fontStyle, Color color, int rorate)
|
||||
{
|
||||
this.fontSize = fontSize;
|
||||
this.fontStyle = fontStyle;
|
||||
this.color = color;
|
||||
this.rotate = rotate;
|
||||
}
|
||||
|
||||
public void Copy(TextStyle textStyle)
|
||||
{
|
||||
font = textStyle.font;
|
||||
rotate = textStyle.rotate;
|
||||
color = textStyle.color;
|
||||
fontSize = textStyle.fontSize;
|
||||
fontStyle = textStyle.fontStyle;
|
||||
lineSpacing = textStyle.lineSpacing;
|
||||
alignment = textStyle.alignment;
|
||||
autoWrap = textStyle.autoWrap;
|
||||
autoAlign = textStyle.autoAlign;
|
||||
#if dUI_TextMeshPro
|
||||
m_TMPFont = textStyle.tmpFont;
|
||||
m_TMPFontStyle = textStyle.tmpFontStyle;
|
||||
m_TMPSpriteAsset = textStyle.tmpSpriteAsset;
|
||||
#endif
|
||||
}
|
||||
|
||||
public void UpdateAlignmentByLocation(Location location)
|
||||
{
|
||||
m_Alignment = location.runtimeTextAlignment;
|
||||
}
|
||||
|
||||
public Color GetColor(Color defaultColor)
|
||||
{
|
||||
if (ChartHelper.IsClearColor(color))
|
||||
return defaultColor;
|
||||
else
|
||||
return color;
|
||||
}
|
||||
|
||||
public int GetFontSize(ComponentTheme defaultTheme)
|
||||
{
|
||||
if (fontSize == 0)
|
||||
return defaultTheme.fontSize;
|
||||
else
|
||||
return fontSize;
|
||||
}
|
||||
|
||||
public TextAnchor GetAlignment(TextAnchor defaultAlignment)
|
||||
{
|
||||
return m_AutoAlign ? defaultAlignment : alignment;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e8f6b652968894ab195666501dda672c
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user