2019-07-13 16:38:38 +08:00
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using UnityEngine;
|
|
|
|
|
|
2022-02-19 22:37:57 +08:00
|
|
|
namespace XCharts.Runtime
|
2019-07-13 16:38:38 +08:00
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Split area of axis in grid area, not shown by default.
|
2022-03-24 08:37:06 +08:00
|
|
|
/// |坐标轴在 grid 区域中的分隔区域,默认不显示。
|
2019-07-13 16:38:38 +08:00
|
|
|
/// </summary>
|
|
|
|
|
[Serializable]
|
2021-11-23 13:20:07 +08:00
|
|
|
public class AxisSplitArea : ChildComponent
|
2019-07-13 16:38:38 +08:00
|
|
|
{
|
|
|
|
|
[SerializeField] private bool m_Show;
|
2020-08-23 14:31:26 +08:00
|
|
|
[SerializeField] private List<Color32> m_Color;
|
2019-07-13 16:38:38 +08:00
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Set this to true to show the splitArea.
|
2022-03-24 08:37:06 +08:00
|
|
|
/// |是否显示分隔区域。
|
2019-07-13 16:38:38 +08:00
|
|
|
/// </summary>
|
2020-03-05 20:25:19 +08:00
|
|
|
public bool show
|
|
|
|
|
{
|
|
|
|
|
get { return m_Show; }
|
2021-01-11 08:54:28 +08:00
|
|
|
set { if (PropertyUtil.SetStruct(ref m_Show, value)) SetVerticesDirty(); }
|
2020-03-05 20:25:19 +08:00
|
|
|
}
|
2019-07-13 16:38:38 +08:00
|
|
|
/// <summary>
|
|
|
|
|
/// Color of split area. SplitArea color could also be set in color array,
|
2022-03-24 08:37:06 +08:00
|
|
|
/// which the split lines would take as their colors in turns.
|
|
|
|
|
/// |Dark and light colors in turns are used by default.
|
|
|
|
|
/// |分隔区域颜色。分隔区域会按数组中颜色的顺序依次循环设置颜色。默认是一个深浅的间隔色。
|
2019-07-13 16:38:38 +08:00
|
|
|
/// </summary>
|
2020-08-23 14:31:26 +08:00
|
|
|
public List<Color32> color
|
2020-03-05 20:25:19 +08:00
|
|
|
{
|
|
|
|
|
get { return m_Color; }
|
|
|
|
|
set { if (value != null) { m_Color = value; SetVerticesDirty(); } }
|
|
|
|
|
}
|
2019-07-13 16:38:38 +08:00
|
|
|
|
|
|
|
|
public static AxisSplitArea defaultSplitArea
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
|
|
|
|
return new AxisSplitArea()
|
|
|
|
|
{
|
|
|
|
|
m_Show = false,
|
2022-05-22 22:17:38 +08:00
|
|
|
m_Color = new List<Color32>() { }
|
2019-07-13 16:38:38 +08:00
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2020-04-18 12:31:21 +08:00
|
|
|
public AxisSplitArea Clone()
|
|
|
|
|
{
|
|
|
|
|
var axisSplitArea = new AxisSplitArea();
|
|
|
|
|
axisSplitArea.show = show;
|
2020-08-23 14:31:26 +08:00
|
|
|
axisSplitArea.color = new List<Color32>();
|
2020-04-18 12:31:21 +08:00
|
|
|
ChartHelper.CopyList(axisSplitArea.color, color);
|
|
|
|
|
return axisSplitArea;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void Copy(AxisSplitArea splitArea)
|
|
|
|
|
{
|
|
|
|
|
show = splitArea.show;
|
|
|
|
|
color.Clear();
|
|
|
|
|
ChartHelper.CopyList(color, splitArea.color);
|
|
|
|
|
}
|
|
|
|
|
|
2021-01-11 08:54:28 +08:00
|
|
|
public Color32 GetColor(int index, BaseAxisTheme theme)
|
2019-07-13 16:38:38 +08:00
|
|
|
{
|
2021-01-11 08:54:28 +08:00
|
|
|
if (color.Count > 0)
|
|
|
|
|
{
|
|
|
|
|
var i = index % color.Count;
|
|
|
|
|
return color[i];
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
var i = index % theme.splitAreaColors.Count;
|
|
|
|
|
return theme.splitAreaColors[i];
|
|
|
|
|
}
|
2019-07-13 16:38:38 +08:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|