2019-08-04 15:24:31 +08:00
|
|
|
|
using UnityEngine;
|
|
|
|
|
|
|
2022-02-19 22:37:57 +08:00
|
|
|
|
namespace XCharts.Runtime
|
2019-08-04 15:24:31 +08:00
|
|
|
|
{
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// The style of area.
|
2022-03-24 08:37:06 +08:00
|
|
|
|
/// |区域填充样式。
|
2019-08-04 15:24:31 +08:00
|
|
|
|
/// </summary>
|
|
|
|
|
|
[System.Serializable]
|
2022-01-22 21:08:26 +08:00
|
|
|
|
public class AreaStyle : ChildComponent, ISerieExtraComponent, ISerieDataComponent
|
2019-08-04 15:24:31 +08:00
|
|
|
|
{
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Origin position of area.
|
2022-03-24 08:37:06 +08:00
|
|
|
|
/// |图形区域的起始位置。默认情况下,图形会从坐标轴轴线到数据间进行填充。如果需要填充的区域是坐标轴最大值到数据间,或者坐标轴最小值到数据间,则可以通过这个配置项进行设置。
|
2019-08-04 15:24:31 +08:00
|
|
|
|
/// </summary>
|
|
|
|
|
|
public enum AreaOrigin
|
|
|
|
|
|
{
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// to fill between axis line to data.
|
2022-03-24 21:48:53 +08:00
|
|
|
|
/// |填充坐标轴轴线到数据间的区域。
|
2019-08-04 15:24:31 +08:00
|
|
|
|
/// </summary>
|
|
|
|
|
|
Auto,
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// to fill between min axis value (when not inverse) to data.
|
2022-03-24 21:48:53 +08:00
|
|
|
|
/// |填充坐标轴底部到数据间的区域。
|
2019-08-04 15:24:31 +08:00
|
|
|
|
/// </summary>
|
|
|
|
|
|
Start,
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// to fill between max axis value (when not inverse) to data.
|
2022-03-24 21:48:53 +08:00
|
|
|
|
/// |填充坐标轴顶部到数据间的区域。
|
2019-08-04 15:24:31 +08:00
|
|
|
|
/// </summary>
|
|
|
|
|
|
End
|
|
|
|
|
|
}
|
2022-05-22 22:17:38 +08:00
|
|
|
|
|
2021-12-28 08:18:24 +08:00
|
|
|
|
[SerializeField] private bool m_Show = true;
|
2022-07-04 08:30:43 +08:00
|
|
|
|
[SerializeField] private AreaStyle.AreaOrigin m_Origin;
|
2020-08-23 14:31:26 +08:00
|
|
|
|
[SerializeField] private Color32 m_Color;
|
|
|
|
|
|
[SerializeField] private Color32 m_ToColor;
|
2022-05-22 22:17:38 +08:00
|
|
|
|
[SerializeField][Range(0, 1)] private float m_Opacity = 0.6f;
|
2022-08-09 08:29:06 +08:00
|
|
|
|
[SerializeField][Since("v3.2.0")] private bool m_InnerFill;
|
2019-08-04 15:24:31 +08:00
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Set this to false to prevent the areafrom showing.
|
2022-03-24 08:37:06 +08:00
|
|
|
|
/// |是否显示区域填充。
|
2019-08-04 15:24:31 +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-08-04 15:24:31 +08:00
|
|
|
|
/// <summary>
|
2019-09-25 09:44:53 +08:00
|
|
|
|
/// the origin of area.
|
2022-03-24 08:37:06 +08:00
|
|
|
|
/// |区域填充的起始位置。
|
2019-08-04 15:24:31 +08:00
|
|
|
|
/// </summary>
|
2020-03-05 20:25:19 +08:00
|
|
|
|
public AreaOrigin origin
|
|
|
|
|
|
{
|
|
|
|
|
|
get { return m_Origin; }
|
2021-01-11 08:54:28 +08:00
|
|
|
|
set { if (PropertyUtil.SetStruct(ref m_Origin, value)) SetVerticesDirty(); }
|
2020-03-05 20:25:19 +08:00
|
|
|
|
}
|
2019-08-04 15:24:31 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// the color of area,default use serie color.
|
2022-03-24 08:37:06 +08:00
|
|
|
|
/// |区域填充的颜色,如果toColor不是默认值,则表示渐变色的起点颜色。
|
2019-08-04 15:24:31 +08:00
|
|
|
|
/// </summary>
|
2020-08-23 14:31:26 +08:00
|
|
|
|
public Color32 color
|
2020-03-05 20:25:19 +08:00
|
|
|
|
{
|
|
|
|
|
|
get { return m_Color; }
|
2021-01-11 08:54:28 +08:00
|
|
|
|
set { if (PropertyUtil.SetColor(ref m_Color, value)) SetVerticesDirty(); }
|
2020-03-05 20:25:19 +08:00
|
|
|
|
}
|
2019-08-04 15:24:31 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Gradient color, start color to toColor.
|
2022-03-24 08:37:06 +08:00
|
|
|
|
/// |渐变色的终点颜色。
|
2019-08-04 15:24:31 +08:00
|
|
|
|
/// </summary>
|
2020-08-23 14:31:26 +08:00
|
|
|
|
public Color32 toColor
|
2020-03-05 20:25:19 +08:00
|
|
|
|
{
|
|
|
|
|
|
get { return m_ToColor; }
|
2021-01-11 08:54:28 +08:00
|
|
|
|
set { if (PropertyUtil.SetColor(ref m_ToColor, value)) SetVerticesDirty(); }
|
2020-03-05 20:25:19 +08:00
|
|
|
|
}
|
2019-08-04 15:24:31 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Opacity of the component. Supports value from 0 to 1, and the component will not be drawn when set to 0.
|
2022-03-24 08:37:06 +08:00
|
|
|
|
/// |图形透明度。支持从 0 到 1 的数字,为 0 时不绘制该图形。
|
2019-08-04 15:24:31 +08:00
|
|
|
|
/// </summary>
|
2020-03-05 20:25:19 +08:00
|
|
|
|
public float opacity
|
|
|
|
|
|
{
|
|
|
|
|
|
get { return m_Opacity; }
|
2021-01-11 08:54:28 +08:00
|
|
|
|
set { if (PropertyUtil.SetStruct(ref m_Opacity, value)) SetVerticesDirty(); }
|
2020-03-05 20:25:19 +08:00
|
|
|
|
}
|
2022-08-09 08:29:06 +08:00
|
|
|
|
/// <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(); }
|
|
|
|
|
|
}
|
2019-08-04 15:24:31 +08:00
|
|
|
|
|
2021-01-11 08:54:28 +08:00
|
|
|
|
public Color32 GetColor()
|
|
|
|
|
|
{
|
2021-11-23 13:20:07 +08:00
|
|
|
|
if (m_Opacity == 1)
|
|
|
|
|
|
return m_Color;
|
|
|
|
|
|
|
2021-01-11 08:54:28 +08:00
|
|
|
|
var color = m_Color;
|
2022-05-22 22:17:38 +08:00
|
|
|
|
color.a = (byte) (color.a * m_Opacity);
|
2021-01-11 08:54:28 +08:00
|
|
|
|
return color;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public Color32 GetColor(Color32 themeColor)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (!ChartHelper.IsClearColor(color))
|
|
|
|
|
|
{
|
|
|
|
|
|
return GetColor();
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
var color = themeColor;
|
2022-05-22 22:17:38 +08:00
|
|
|
|
color.a = (byte) (color.a * opacity);
|
2021-01-11 08:54:28 +08:00
|
|
|
|
return color;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2019-08-04 15:24:31 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|