mirror of
https://github.com/XCharts-Team/XCharts.git
synced 2026-05-21 07:50:16 +00:00
增加RadarCoord的startAngle可设置Radar起始角度
This commit is contained in:
@@ -108,6 +108,7 @@ namespace XCharts.Runtime
|
||||
[SerializeField] private Color32 m_OutRangeColor = Color.red;
|
||||
[SerializeField] private bool m_ConnectCenter = false;
|
||||
[SerializeField] private bool m_LineGradient = true;
|
||||
[SerializeField][Since("v3.4.0")] private float m_StartAngle;
|
||||
[SerializeField] private List<Indicator> m_IndicatorList = new List<Indicator>();
|
||||
|
||||
public RadarCoordContext context = new RadarCoordContext();
|
||||
@@ -264,6 +265,14 @@ namespace XCharts.Runtime
|
||||
set { if (PropertyUtil.SetStruct(ref m_LineGradient, value)) SetAllDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// 起始角度。和时钟一样,12点钟位置是0度,顺时针到360度。
|
||||
/// </summary>
|
||||
public float startAngle
|
||||
{
|
||||
get { return m_StartAngle; }
|
||||
set { if (PropertyUtil.SetStruct(ref m_StartAngle, value)) SetVerticesDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// the indicator list.
|
||||
/// |指示器列表。
|
||||
/// </summary>
|
||||
|
||||
@@ -124,7 +124,8 @@ namespace XCharts.Runtime
|
||||
int indicatorNum = radar.indicatorList.Count;
|
||||
Vector3 p1, p2, p3, p4;
|
||||
Vector3 p = radar.context.center;
|
||||
float angle = 2 * Mathf.PI / indicatorNum;
|
||||
var startAngle = radar.startAngle * Mathf.PI / 180;
|
||||
var angle = 2 * Mathf.PI / indicatorNum;
|
||||
var lineColor = radar.axisLine.GetColor(chart.theme.axis.splitLineColor);
|
||||
var lineWidth = radar.axisLine.GetWidth(chart.theme.axis.lineWidth);
|
||||
var lineType = radar.axisLine.GetType(chart.theme.axis.lineType);
|
||||
@@ -135,11 +136,11 @@ namespace XCharts.Runtime
|
||||
{
|
||||
var color = radar.splitArea.GetColor(i, chart.theme.axis);
|
||||
outsideRadius = insideRadius + block;
|
||||
p1 = new Vector3(p.x + insideRadius * Mathf.Sin(0), p.y + insideRadius * Mathf.Cos(0));
|
||||
p2 = new Vector3(p.x + outsideRadius * Mathf.Sin(0), p.y + outsideRadius * Mathf.Cos(0));
|
||||
p1 = new Vector3(p.x + insideRadius * Mathf.Sin(startAngle), p.y + insideRadius * Mathf.Cos(startAngle));
|
||||
p2 = new Vector3(p.x + outsideRadius * Mathf.Sin(startAngle), p.y + outsideRadius * Mathf.Cos(startAngle));
|
||||
for (int j = 0; j <= indicatorNum; j++)
|
||||
{
|
||||
float currAngle = j * angle;
|
||||
float currAngle = startAngle + j * angle;
|
||||
p3 = new Vector3(p.x + outsideRadius * Mathf.Sin(currAngle),
|
||||
p.y + outsideRadius * Mathf.Cos(currAngle));
|
||||
p4 = new Vector3(p.x + insideRadius * Mathf.Sin(currAngle),
|
||||
@@ -161,7 +162,7 @@ namespace XCharts.Runtime
|
||||
{
|
||||
for (int j = 0; j <= indicatorNum; j++)
|
||||
{
|
||||
float currAngle = j * angle;
|
||||
float currAngle = startAngle + j * angle;
|
||||
p3 = new Vector3(p.x + outsideRadius * Mathf.Sin(currAngle),
|
||||
p.y + outsideRadius * Mathf.Cos(currAngle));
|
||||
ChartDrawer.DrawLineStyle(vh, lineType, lineWidth, p, p3, lineColor);
|
||||
|
||||
Reference in New Issue
Block a user