mirror of
https://github.com/XCharts-Team/XCharts.git
synced 2026-05-22 08:50:10 +00:00
增加Comment的layer设置层级
This commit is contained in:
@@ -5,14 +5,33 @@ using UnityEngine;
|
||||
namespace XCharts.Runtime
|
||||
{
|
||||
/// <summary>
|
||||
/// comment of chart.
|
||||
/// ||图表注解组件。
|
||||
/// The layer of comment.
|
||||
/// ||注解的显示层级。
|
||||
/// </summary>
|
||||
[Since("v3.15.0")]
|
||||
public enum CommentLayer
|
||||
{
|
||||
/// <summary>
|
||||
/// The comment is display under the serie.
|
||||
/// ||注解在系列下方。
|
||||
/// </summary>
|
||||
Lower,
|
||||
/// <summary>
|
||||
/// The comment is display above the serie.
|
||||
/// ||注解在系列上方。
|
||||
/// </summary>
|
||||
Upper
|
||||
}
|
||||
/// <summary>
|
||||
/// comment of chart. Used to annotate special information in the chart.
|
||||
/// ||图表注解组件。用于标注图表中的特殊信息。
|
||||
/// </summary>
|
||||
[Serializable]
|
||||
[ComponentHandler(typeof(CommentHander), true)]
|
||||
public class Comment : MainComponent, IPropertyChanged
|
||||
{
|
||||
[SerializeField] private bool m_Show = true;
|
||||
[SerializeField][Since("v3.15.0")] private CommentLayer m_Layer = CommentLayer.Lower;
|
||||
[SerializeField] private LabelStyle m_LabelStyle = new LabelStyle();
|
||||
[SerializeField] private CommentMarkStyle m_MarkStyle;
|
||||
[SerializeField] private List<CommentItem> m_Items = new List<CommentItem>() { new CommentItem() };
|
||||
@@ -23,6 +42,11 @@ namespace XCharts.Runtime
|
||||
/// </summary>
|
||||
public bool show { get { return m_Show; } set { if (PropertyUtil.SetStruct(ref m_Show, value)) SetComponentDirty(); } }
|
||||
/// <summary>
|
||||
/// The layer of comment.
|
||||
/// ||注解的显示层级。
|
||||
/// </summary>
|
||||
public CommentLayer layer { get { return m_Layer; } set { if (PropertyUtil.SetStruct(ref m_Layer, value)) SetComponentDirty(); } }
|
||||
/// <summary>
|
||||
/// The items of comment.
|
||||
/// ||注解项。每个注解组件可以设置多个注解项。
|
||||
/// </summary>
|
||||
@@ -45,7 +69,12 @@ namespace XCharts.Runtime
|
||||
get { return m_MarkStyle; }
|
||||
set { if (PropertyUtil.SetClass(ref m_MarkStyle, value)) SetVerticesDirty(); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get the label style of comment item.
|
||||
/// ||获取注解项的文本样式。
|
||||
/// </summary>
|
||||
/// <param name="index">the index of item</param>
|
||||
/// <returns></returns>
|
||||
public LabelStyle GetLabelStyle(int index)
|
||||
{
|
||||
if (index >= 0 && index < items.Count)
|
||||
@@ -55,7 +84,12 @@ namespace XCharts.Runtime
|
||||
}
|
||||
return m_LabelStyle;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get the mark style of comment item.
|
||||
/// ||获取注解项的标记样式。
|
||||
/// </summary>
|
||||
/// <param name="index">the index of item</param>
|
||||
/// <returns></returns>
|
||||
public CommentMarkStyle GetMarkStyle(int index)
|
||||
{
|
||||
if (index >= 0 && index < items.Count)
|
||||
|
||||
@@ -23,8 +23,12 @@ namespace XCharts.Runtime
|
||||
chart.chartMaxAnchor,
|
||||
chart.chartPivot,
|
||||
chart.chartSizeDelta, -1, chart.childrenNodeNames);
|
||||
var siblingIndex = comment.layer == CommentLayer.Upper
|
||||
? chart.topPainter.transform.GetSiblingIndex() - 1
|
||||
: chart.painter.transform.GetSiblingIndex() + 1;
|
||||
|
||||
commentObj.SetActive(comment.show);
|
||||
commentObj.transform.SetSiblingIndex(siblingIndex);
|
||||
commentObj.hideFlags = chart.chartHideFlags;
|
||||
ChartHelper.HideAllObject(commentObj);
|
||||
for (int i = 0; i < comment.items.Count; i++)
|
||||
|
||||
@@ -11,11 +11,11 @@ namespace XCharts.Runtime
|
||||
public class CommentItem : ChildComponent
|
||||
{
|
||||
[SerializeField] private bool m_Show = true;
|
||||
[SerializeField] private string m_Content = "comment";
|
||||
[SerializeField] private string m_Content = "xcharts";
|
||||
[SerializeField] private Rect m_MarkRect;
|
||||
[SerializeField] private CommentMarkStyle m_MarkStyle = new CommentMarkStyle() { show = false };
|
||||
[SerializeField] private LabelStyle m_LabelStyle = new LabelStyle() { show = false };
|
||||
[SerializeField][Since("v3.5.0")] private Location m_Location = new Location() { align = Location.Align.TopLeft, top = 0.125f };
|
||||
[SerializeField][Since("v3.5.0")] private Location m_Location = new Location() { align = Location.Align.BottomRight, right = 0.1f, bottom = 0.05f };
|
||||
|
||||
public ChartLabel labelObject { get; set; }
|
||||
|
||||
|
||||
Reference in New Issue
Block a user