/******************************************/
/* */
/* Copyright (c) 2018 monitor1394 */
/* https://github.com/monitor1394 */
/* */
/******************************************/
using System;
using UnityEngine;
namespace XCharts
{
///
/// Text label of chart, to explain some data information about graphic item like value, name and so on.
/// 图形上的文本标签,可用于说明图形的一些数据信息,比如值,名称等。
///
[System.Serializable]
public class SerieLabel : SubComponent
{
///
/// The position of label.
/// 标签的位置。
///
public enum Position
{
///
/// Outside of sectors of pie chart, which relates to corresponding sector through visual guide line.
/// 饼图扇区外侧,通过视觉引导线连到相应的扇区。
///
Outside,
///
/// Inside the sectors of pie chart.
/// 饼图扇区内部。
///
Inside,
///
/// In the center of pie chart.
/// 在饼图中心位置。
///
Center,
///
/// top of symbol.
/// 图形标志的顶部。
///
Top,
///
/// the left of symbol.
/// 图形标志的左边。
///
//Left,
///
/// the right of symbol.
/// 图形标志的右边。
///
//Right,
///
/// the bottom of symbol.
/// 图形标志的底部。
///
Bottom,
}
///
/// 标签视觉引导线类型
///
public enum LineType
{
///
/// 折线
///
BrokenLine,
///
/// 曲线
///
Curves,
///
/// 水平线
///
HorizontalLine
}
[SerializeField] private bool m_Show = false;
[SerializeField] Position m_Position;
[SerializeField] private Vector3 m_Offset;
[SerializeField] private float m_Margin;
[SerializeField] private string m_Formatter;
[SerializeField] private float m_Rotate = 0;
[SerializeField] private float m_PaddingLeftRight = 2f;
[SerializeField] private float m_PaddingTopBottom = 2f;
[SerializeField] private Color m_Color;
[SerializeField] private Color m_BackgroundColor;
[SerializeField] private float m_BackgroundWidth = 0;
[SerializeField] private float m_BackgroundHeight = 0;
[SerializeField] private int m_FontSize = 18;
[SerializeField] private FontStyle m_FontStyle = FontStyle.Normal;
[SerializeField] private bool m_Line = true;
[SerializeField] private LineType m_LineType = LineType.BrokenLine;
[SerializeField] private Color m_LineColor = Color.clear;
[SerializeField] private float m_LineWidth = 1.0f;
[SerializeField] private float m_LineLength1 = 25f;
[SerializeField] private float m_LineLength2 = 15f;
[SerializeField] private bool m_Border = false;
[SerializeField] private float m_BorderWidth = 0.5f;
[SerializeField] private Color m_BorderColor = Color.grey;
[SerializeField] private string m_NumericFormatter = "";
///
/// Whether the label is showed.
/// 是否显示文本标签。
///
public bool show
{
get { return m_Show; }
set { if (PropertyUtility.SetStruct(ref m_Show, value)) SetAllDirty(); }
}
///
/// The position of label.
/// 标签的位置。
///
public Position position
{
get { return m_Position; }
set { if (PropertyUtility.SetStruct(ref m_Position, value)) SetVerticesDirty(); }
}
///
/// 标签内容字符串模版格式器。支持用 \n 换行。
/// 模板变量有:
///
/// - {a}:系列名。
/// - {b}:数据名。
/// - {c}:数据值。
/// - {d}:百分比。
///
///
///
/// 示例:“{b}:{c}”
///
public string formatter
{
get { return m_Formatter; }
set { if (PropertyUtility.SetClass(ref m_Formatter, value)) SetVerticesDirty(); }
}
///
/// offset to the host graphic element.
/// 距离图形元素的偏移
///
public Vector3 offset
{
get { return m_Offset; }
set { if (PropertyUtility.SetStruct(ref m_Offset, value)) SetVerticesDirty(); }
}
///
/// 距离轴线的距离。
///
public float margin
{
get { return m_Margin; }
set { if (PropertyUtility.SetStruct(ref m_Margin, value)) SetVerticesDirty(); }
}
///
/// Text color,If set as default ,the color will assigned as series color.
/// 自定义文字颜色,默认和系列的颜色一致。
///
public Color color
{
get { return m_Color; }
set { if (PropertyUtility.SetStruct(ref m_Color, value)) SetComponentDirty(); }
}
///
/// the background color. If set as default, it means than don't show background.
/// 标签的背景色,默认无颜色。
///
public Color backgroundColor
{
get { return m_BackgroundColor; }
set { if (PropertyUtility.SetStruct(ref m_BackgroundColor, value)) SetVerticesDirty(); }
}
///
/// the width of background. If set as default value 0, it means than the background width auto set as the text width.
/// 标签的背景宽度。一般不用指定,不指定时则自动是文字的宽度。
///
///
public float backgroundWidth
{
get { return m_BackgroundWidth; }
set { if (PropertyUtility.SetStruct(ref m_BackgroundWidth, value)) SetComponentDirty(); }
}
///
/// the height of background. If set as default value 0, it means than the background height auto set as the text height.
/// 标签的背景高度。一般不用指定,不指定时则自动是文字的高度。
///
///
public float backgroundHeight
{
get { return m_BackgroundHeight; }
set { if (PropertyUtility.SetStruct(ref m_BackgroundHeight, value)) SetComponentDirty(); }
}
///
/// Rotate label.
/// 标签旋转。
///
public float rotate
{
get { return m_Rotate; }
set { if (PropertyUtility.SetStruct(ref m_Rotate, value)) SetComponentDirty(); }
}
///
/// the text padding of left and right. defaut:2.
/// 左右边距。
///
public float paddingLeftRight
{
get { return m_PaddingLeftRight; }
set { if (PropertyUtility.SetStruct(ref m_PaddingLeftRight, value)) SetComponentDirty(); }
}
///
/// the text padding of top and bottom. defaut:2.
/// 上下边距。
///
public float paddingTopBottom
{
get { return m_PaddingTopBottom; }
set { if (PropertyUtility.SetStruct(ref m_PaddingTopBottom, value)) SetComponentDirty(); }
}
///
/// font size.
/// 文字的字体大小。
///
public int fontSize
{
get { return m_FontSize; }
set { if (PropertyUtility.SetStruct(ref m_FontSize, value)) SetAllDirty(); }
}
///
/// font style.
/// 文字的字体风格。
///
public FontStyle fontStyle
{
get { return m_FontStyle; }
set { if (PropertyUtility.SetStruct(ref m_FontStyle, value)) SetAllDirty(); }
}
///
/// Whether to show visual guide line.Will show when label position is set as 'outside'.
/// 是否显示视觉引导线。在 label 位置 设置为'outside'的时候会显示视觉引导线。
///
public bool line
{
get { return m_Line; }
set { if (PropertyUtility.SetStruct(ref m_Line, value)) SetComponentDirty(); }
}
///
/// the type of visual guide line.
/// 视觉引导线类型。
///
public LineType lineType
{
get { return m_LineType; }
set { if (PropertyUtility.SetStruct(ref m_LineType, value)) SetVerticesDirty(); }
}
///
/// the color of visual guild line.
/// 视觉引导线颜色。默认和serie一致取自调色板。
///
public Color lineColor
{
get { return m_LineColor; }
set { if (PropertyUtility.SetStruct(ref m_LineColor, value)) SetVerticesDirty(); }
}
///
/// the width of visual guild line.
/// 视觉引导线的宽度。
///
public float lineWidth
{
get { return m_LineWidth; }
set { if (PropertyUtility.SetStruct(ref m_LineWidth, value)) SetVerticesDirty(); }
}
///
/// The length of the first segment of visual guide line.
/// 视觉引导线第一段的长度。
///
public float lineLength1
{
get { return m_LineLength1; }
set { if (PropertyUtility.SetStruct(ref m_LineLength1, value)) SetVerticesDirty(); }
}
///
/// The length of the second segment of visual guide line.
/// 视觉引导线第二段的长度。
///
public float lineLength2
{
get { return m_LineLength2; }
set { if (PropertyUtility.SetStruct(ref m_LineLength2, value)) SetVerticesDirty(); }
}
///
/// Whether to show border.
/// 是否显示边框。
///
public bool border
{
get { return m_Border; }
set { if (PropertyUtility.SetStruct(ref m_Border, value)) SetVerticesDirty(); }
}
///
/// the width of border.
/// 边框宽度。
///
public float borderWidth
{
get { return m_BorderWidth; }
set { if (PropertyUtility.SetStruct(ref m_BorderWidth, value)) SetVerticesDirty(); }
}
///
/// the color of border.
/// 边框颜色。
///
public Color borderColor
{
get { return m_BorderColor; }
set { if (PropertyUtility.SetStruct(ref m_BorderColor, value)) SetVerticesDirty(); }
}
///
/// Standard numeric format strings.
/// 标准数字格式字符串。用于将数值格式化显示为字符串。
/// 使用Axx的形式:A是格式说明符的单字符,支持C货币、D十进制、E指数、F定点数、G常规、N数字、P百分比、R往返、X十六进制的。xx是精度说明,从0-99。
/// 参考:https://docs.microsoft.com/zh-cn/dotnet/standard/base-types/standard-numeric-format-strings
///
///
public string numericFormatter
{
get { return m_NumericFormatter; }
set { if (PropertyUtility.SetClass(ref m_NumericFormatter, value)) SetComponentDirty(); }
}
}
}