Files
XCharts/Runtime/Component/Main/Polar.cs

94 lines
3.4 KiB
C#
Raw Normal View History

2021-01-11 08:54:28 +08:00
/************************************************/
/* */
/* Copyright (c) 2018 - 2021 monitor1394 */
/* https://github.com/monitor1394 */
/* */
/************************************************/
2020-07-01 09:38:00 +08:00
using System;
using UnityEngine;
namespace XCharts
{
/// <summary>
/// Polar coordinate can be used in scatter and line chart. Every polar coordinate has an angleAxis and a radiusAxis.
/// <para>
/// 极坐标系组件。
/// 极坐标系,可以用于散点图和折线图。每个极坐标系拥有一个角度轴和一个半径轴。
/// </para>
/// </summary>
[Serializable]
public class Polar : MainComponent
{
[SerializeField] private bool m_Show = true;
[SerializeField] private float[] m_Center = new float[2] { 0.5f, 0.5f };
[SerializeField] private float m_Radius = 100;
[SerializeField] private Color m_BackgroundColor;
/// <summary>
2020-07-10 09:13:26 +08:00
/// Whether to show the polor component.
/// 是否显示极坐标。
2020-07-01 09:38:00 +08:00
/// </summary>
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-07-01 09:38:00 +08:00
}
/// <summary>
2020-07-10 09:13:26 +08:00
/// [default:[0.5f,0.45f]]The center of ploar. The center[0] is the x-coordinate, and the center[1] is the y-coordinate.
/// When value between 0 and 1 represents a percentage relative to the chart.
2020-07-01 09:38:00 +08:00
/// 极坐标的中心点。数组的第一项是横坐标,第二项是纵坐标。
/// 当值为0-1之间时表示百分比设置成百分比时第一项是相对于容器宽度第二项是相对于容器高度。
/// </summary>
public float[] center
{
get { return m_Center; }
set { if (value != null) { m_Center = value; SetAllDirty(); } }
}
/// <summary>
2020-07-10 09:13:26 +08:00
/// [default:0.35f]the radius of polar.
2020-07-01 09:38:00 +08:00
/// 极坐标的半径。
/// </summary>
public float radius
{
get { return m_Radius; }
2021-01-11 08:54:28 +08:00
set { if (PropertyUtil.SetStruct(ref m_Radius, value)) SetAllDirty(); }
2020-07-01 09:38:00 +08:00
}
/// <summary>
2020-07-10 09:13:26 +08:00
/// [default:Color.clear]Background color of polar, which is transparent by default.
2020-07-01 09:38:00 +08:00
/// 极坐标的背景色,默认透明。
/// </summary>
public Color backgroundColor
{
get { return m_BackgroundColor; }
2021-01-11 08:54:28 +08:00
set { if (PropertyUtil.SetColor(ref m_BackgroundColor, value)) SetVerticesDirty(); }
2020-07-01 09:38:00 +08:00
}
2021-01-11 08:54:28 +08:00
public int index { get; internal set; }
2020-07-01 09:38:00 +08:00
/// <summary>
/// the center position of polar in container.
/// 极坐标在容器中的具体中心点。
/// </summary>
public Vector3 runtimeCenterPos { get; internal set; }
/// <summary>
/// the true radius of polar.
/// 极坐标的运行时实际半径。
/// </summary>
public float runtimeRadius { get; internal set; }
2020-07-10 09:13:26 +08:00
2020-07-01 09:38:00 +08:00
public static Polar defaultPolar
{
get
{
var polar = new Polar
{
m_Show = true,
m_Radius = 0.35f,
};
polar.center[0] = 0.5f;
polar.center[1] = 0.45f;
return polar;
}
}
}
}