mirror of
https://github.com/XCharts-Team/XCharts.git
synced 2026-05-23 09:20:08 +00:00
增加Axis的图标、自动换行、自定义长宽的支持
This commit is contained in:
@@ -26,6 +26,9 @@ namespace XCharts
|
||||
[SerializeField] private string m_NumericFormatter = "";
|
||||
[SerializeField] private bool m_ShowAsPositiveNumber = false;
|
||||
[SerializeField] private bool m_OnZero = false;
|
||||
[SerializeField] private float m_Width = 0f;
|
||||
[SerializeField] private float m_Height = 0f;
|
||||
[SerializeField] private bool m_AutoAlign = true;
|
||||
[SerializeField] private TextLimit m_TextLimit = new TextLimit();
|
||||
[SerializeField] private TextStyle m_TextStyle = new TextStyle();
|
||||
|
||||
@@ -106,6 +109,30 @@ namespace XCharts
|
||||
get { return m_OnZero; }
|
||||
set { if (PropertyUtil.SetStruct(ref m_OnZero, value)) SetComponentDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// 文本的宽。为0时会自动匹配。
|
||||
/// </summary>
|
||||
public float width
|
||||
{
|
||||
get { return m_Width; }
|
||||
set { if (PropertyUtil.SetStruct(ref m_Width, value)) SetComponentDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// 文本的高。为0时会自动匹配。
|
||||
/// </summary>
|
||||
public float height
|
||||
{
|
||||
get { return m_Height; }
|
||||
set { if (PropertyUtil.SetStruct(ref m_Height, value)) SetComponentDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// 文本是否自动选对齐方式。为false时会用TextStyle下的alignment。
|
||||
/// </summary>
|
||||
public bool autoAlign
|
||||
{
|
||||
get { return m_AutoAlign; }
|
||||
set { if (PropertyUtil.SetStruct(ref m_AutoAlign, value)) SetComponentDirty(); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 文本限制。
|
||||
@@ -150,28 +177,34 @@ namespace XCharts
|
||||
|
||||
public AxisLabel Clone()
|
||||
{
|
||||
var axisLable = new AxisLabel();
|
||||
axisLable.show = show;
|
||||
axisLable.formatter = formatter;
|
||||
axisLable.interval = interval;
|
||||
axisLable.inside = inside;
|
||||
axisLable.margin = margin;
|
||||
axisLable.numericFormatter = numericFormatter;
|
||||
axisLable.textLimit = textLimit.Clone();
|
||||
axisLable.textStyle.Copy(textStyle);
|
||||
return axisLable;
|
||||
var axisLabel = new AxisLabel();
|
||||
axisLabel.show = show;
|
||||
axisLabel.formatter = formatter;
|
||||
axisLabel.interval = interval;
|
||||
axisLabel.inside = inside;
|
||||
axisLabel.margin = margin;
|
||||
axisLabel.numericFormatter = numericFormatter;
|
||||
axisLabel.width = width;
|
||||
axisLabel.height = height;
|
||||
axisLabel.autoAlign = autoAlign;
|
||||
axisLabel.textLimit = textLimit.Clone();
|
||||
axisLabel.textStyle.Copy(textStyle);
|
||||
return axisLabel;
|
||||
}
|
||||
|
||||
public void Copy(AxisLabel axisLable)
|
||||
public void Copy(AxisLabel axisLabel)
|
||||
{
|
||||
show = axisLable.show;
|
||||
formatter = axisLable.formatter;
|
||||
interval = axisLable.interval;
|
||||
inside = axisLable.inside;
|
||||
margin = axisLable.margin;
|
||||
numericFormatter = axisLable.numericFormatter;
|
||||
textLimit.Copy(axisLable.textLimit);
|
||||
textStyle.Copy(axisLable.textStyle);
|
||||
show = axisLabel.show;
|
||||
formatter = axisLabel.formatter;
|
||||
interval = axisLabel.interval;
|
||||
inside = axisLabel.inside;
|
||||
margin = axisLabel.margin;
|
||||
numericFormatter = axisLabel.numericFormatter;
|
||||
width = axisLabel.width;
|
||||
height = axisLabel.height;
|
||||
autoAlign = axisLabel.autoAlign;
|
||||
textLimit.Copy(axisLabel.textLimit);
|
||||
textStyle.Copy(axisLabel.textStyle);
|
||||
}
|
||||
|
||||
public void SetRelatedText(ChartText txt, float labelWidth)
|
||||
|
||||
@@ -10,9 +10,6 @@ using UnityEngine.UI;
|
||||
|
||||
namespace XCharts
|
||||
{
|
||||
/// <summary>
|
||||
/// 系列数据项的图标
|
||||
/// </summary>
|
||||
[System.Serializable]
|
||||
public class IconStyle : SubComponent
|
||||
{
|
||||
@@ -25,8 +22,8 @@ namespace XCharts
|
||||
[SerializeField] private Layer m_Layer;
|
||||
[SerializeField] private Sprite m_Sprite;
|
||||
[SerializeField] private Color m_Color = Color.white;
|
||||
[SerializeField] private float m_Width = 40;
|
||||
[SerializeField] private float m_Height = 40;
|
||||
[SerializeField] private float m_Width = 20;
|
||||
[SerializeField] private float m_Height = 20;
|
||||
[SerializeField] private Vector3 m_Offset;
|
||||
|
||||
public void Reset()
|
||||
@@ -35,8 +32,8 @@ namespace XCharts
|
||||
m_Layer = Layer.UnderLabel;
|
||||
m_Sprite = null;
|
||||
m_Color = Color.white;
|
||||
m_Width = 40;
|
||||
m_Height = 40;
|
||||
m_Width = 20;
|
||||
m_Height = 20;
|
||||
m_Offset = Vector3.zero;
|
||||
}
|
||||
/// <summary>
|
||||
@@ -70,6 +67,28 @@ namespace XCharts
|
||||
/// </summary>
|
||||
public Vector3 offset { get { return m_Offset; } set { m_Offset = value; } }
|
||||
|
||||
public IconStyle Clone()
|
||||
{
|
||||
var iconStyle = new IconStyle();
|
||||
iconStyle.show = show;
|
||||
iconStyle.layer = layer;
|
||||
iconStyle.sprite = sprite;
|
||||
iconStyle.color = color;
|
||||
iconStyle.width = width;
|
||||
iconStyle.height = height;
|
||||
iconStyle.offset = offset;
|
||||
return iconStyle;
|
||||
}
|
||||
|
||||
public void Copy(IconStyle iconStyle)
|
||||
{
|
||||
show = iconStyle.show;
|
||||
layer = iconStyle.layer;
|
||||
sprite = iconStyle.sprite;
|
||||
color = iconStyle.color;
|
||||
width = iconStyle.width;
|
||||
height = iconStyle.height;
|
||||
offset = iconStyle.offset;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,6 +22,7 @@ namespace XCharts
|
||||
{
|
||||
[SerializeField] private Font m_Font;
|
||||
|
||||
[SerializeField] private bool m_Wrap = true;
|
||||
[SerializeField] private float m_Rotate = 0;
|
||||
[SerializeField] private Vector2 m_Offset = Vector2.zero;
|
||||
[SerializeField] private Color m_Color = Color.clear;
|
||||
@@ -119,6 +120,14 @@ namespace XCharts
|
||||
set { if (PropertyUtil.SetStruct(ref m_LineSpacing, value)) SetComponentDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// 是否自动换行。
|
||||
/// </summary>
|
||||
public bool wrap
|
||||
{
|
||||
get { return m_Wrap; }
|
||||
set { if (PropertyUtil.SetStruct(ref m_Wrap, value)) SetComponentDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// 对齐方式。
|
||||
/// </summary>
|
||||
public TextAnchor alignment
|
||||
@@ -186,6 +195,7 @@ namespace XCharts
|
||||
fontStyle = textStyle.fontStyle;
|
||||
lineSpacing = textStyle.lineSpacing;
|
||||
alignment = textStyle.alignment;
|
||||
wrap = textStyle.wrap;
|
||||
#if dUI_TextMeshPro
|
||||
m_TMPFont = textStyle.tmpFont;
|
||||
m_TMPAlignment = textStyle.tmpAlignment;
|
||||
@@ -210,7 +220,7 @@ namespace XCharts
|
||||
|
||||
public int GetFontSize(ComponentTheme defaultTheme)
|
||||
{
|
||||
if(fontSize == 0) return defaultTheme.fontSize;
|
||||
if (fontSize == 0) return defaultTheme.fontSize;
|
||||
else return fontSize;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user