mirror of
https://github.com/XCharts-Team/XCharts.git
synced 2026-05-26 02:40:13 +00:00
3.0 - unitypackage
This commit is contained in:
414
Runtime/Component/Radar/RadarCoord.cs
Normal file
414
Runtime/Component/Radar/RadarCoord.cs
Normal file
@@ -0,0 +1,414 @@
|
||||
|
||||
using UnityEngine;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine.UI;
|
||||
|
||||
namespace XCharts
|
||||
{
|
||||
/// <summary>
|
||||
/// Radar coordinate conponnet for radar charts.
|
||||
/// 雷达图坐标系组件,只适用于雷达图。
|
||||
/// </summary>
|
||||
[System.Serializable]
|
||||
[ComponentHandler(typeof(RadarCoordHandler), true)]
|
||||
[CoordOptions(typeof(RadarCoord))]
|
||||
public class RadarCoord : CoordSystem, ISerieContainer
|
||||
{
|
||||
/// <summary>
|
||||
/// Radar render type, in which 'Polygon' and 'Circle' are supported.
|
||||
/// 雷达图绘制类型,支持 'Polygon' 和 'Circle'。
|
||||
/// </summary>
|
||||
public enum Shape
|
||||
{
|
||||
Polygon,
|
||||
Circle
|
||||
}
|
||||
/// <summary>
|
||||
/// The position type of radar.
|
||||
/// 显示位置。
|
||||
/// </summary>
|
||||
public enum PositionType
|
||||
{
|
||||
/// <summary>
|
||||
/// Display at the vertex.
|
||||
/// 显示在顶点处。
|
||||
/// </summary>
|
||||
Vertice,
|
||||
/// <summary>
|
||||
/// Display at the middle of line.
|
||||
/// 显示在两者之间。
|
||||
/// </summary>
|
||||
Between,
|
||||
}
|
||||
/// <summary>
|
||||
/// Indicator of radar chart, which is used to assign multiple variables(dimensions) in radar chart.
|
||||
/// 雷达图的指示器,用来指定雷达图中的多个变量(维度)。
|
||||
/// </summary>
|
||||
[System.Serializable]
|
||||
public class Indicator
|
||||
{
|
||||
[SerializeField] private string m_Name;
|
||||
[SerializeField] private double m_Max;
|
||||
[SerializeField] private double m_Min;
|
||||
[SerializeField] private double[] m_Range = new double[2] { 0, 0 };
|
||||
[SerializeField] private TextStyle m_TextStyle = new TextStyle();
|
||||
|
||||
/// <summary>
|
||||
/// The name of indicator.
|
||||
/// 指示器名称。
|
||||
/// </summary>
|
||||
public string name { get { return FormatterHelper.TrimAndReplaceLine(m_Name); } set { m_Name = value; } }
|
||||
/// <summary>
|
||||
/// The maximum value of indicator, with default value of 0, but we recommend to set it manually.
|
||||
/// 指示器的最大值,默认为 0 无限制。
|
||||
/// </summary>
|
||||
public double max { get { return m_Max; } set { m_Max = value; } }
|
||||
/// <summary>
|
||||
/// The minimum value of indicator, with default value of 0.
|
||||
/// 指示器的最小值,默认为 0 无限制。
|
||||
/// </summary>
|
||||
public double min { get { return m_Min; } set { m_Min = value; } }
|
||||
/// <summary>
|
||||
/// the style of text.
|
||||
/// 文本样式。
|
||||
/// </summary>
|
||||
public TextStyle textStyle { get { return m_TextStyle; } set { m_TextStyle = value; } }
|
||||
/// <summary>
|
||||
/// the text conponent of indicator.
|
||||
/// 指示器的文本组件。
|
||||
/// </summary>
|
||||
public Text text { get; set; }
|
||||
/// <summary>
|
||||
/// Normal range. When the value is outside this range, the display color is automatically changed.
|
||||
/// 正常值范围。当数值不在这个范围时,会自动变更显示颜色。
|
||||
/// </summary>
|
||||
public double[] range
|
||||
{
|
||||
get { return m_Range; }
|
||||
set { if (value != null && value.Length == 2) { m_Range = value; } }
|
||||
}
|
||||
|
||||
public bool IsInRange(double value)
|
||||
{
|
||||
if (m_Range == null || m_Range.Length < 2) return true;
|
||||
if (m_Range[0] != 0 || m_Range[1] != 0)
|
||||
return value >= m_Range[0] && value <= m_Range[1];
|
||||
else
|
||||
return true;
|
||||
}
|
||||
}
|
||||
[SerializeField] private bool m_Show;
|
||||
[SerializeField] private Shape m_Shape;
|
||||
[SerializeField] private float m_Radius = 100;
|
||||
[SerializeField] private int m_SplitNumber = 5;
|
||||
[SerializeField] private float[] m_Center = new float[2] { 0.5f, 0.5f };
|
||||
[SerializeField] private AxisLine m_AxisLine = AxisLine.defaultAxisLine;
|
||||
[SerializeField] private AxisSplitLine m_SplitLine = AxisSplitLine.defaultSplitLine;
|
||||
[SerializeField] private AxisSplitArea m_SplitArea = AxisSplitArea.defaultSplitArea;
|
||||
[SerializeField] private bool m_Indicator = true;
|
||||
[SerializeField] private PositionType m_PositionType = PositionType.Vertice;
|
||||
[SerializeField] private float m_IndicatorGap = 10;
|
||||
[SerializeField] private int m_CeilRate = 0;
|
||||
[SerializeField] private bool m_IsAxisTooltip;
|
||||
[SerializeField] private Color32 m_OutRangeColor = Color.red;
|
||||
[SerializeField] private bool m_ConnectCenter = false;
|
||||
[SerializeField] private bool m_LineGradient = true;
|
||||
[SerializeField] private List<Indicator> m_IndicatorList = new List<Indicator>();
|
||||
|
||||
public RadarCoordContext context = new RadarCoordContext();
|
||||
|
||||
/// <summary>
|
||||
/// [default:true]
|
||||
/// Set this to false to prevent the radar from showing.
|
||||
/// 是否显示雷达坐标系组件。
|
||||
/// </summary>
|
||||
public bool show { get { return m_Show; } set { if (PropertyUtil.SetStruct(ref m_Show, value)) SetComponentDirty(); } }
|
||||
/// <summary>
|
||||
/// Radar render type, in which 'Polygon' and 'Circle' are supported.
|
||||
/// 雷达图绘制类型,支持 'Polygon' 和 'Circle'。
|
||||
/// </summary>
|
||||
/// <value></value>
|
||||
public Shape shape
|
||||
{
|
||||
get { return m_Shape; }
|
||||
set { if (PropertyUtil.SetStruct(ref m_Shape, value)) SetAllDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// the radius of radar.
|
||||
/// 雷达图的半径。
|
||||
/// </summary>
|
||||
public float radius
|
||||
{
|
||||
get { return m_Radius; }
|
||||
set { if (PropertyUtil.SetStruct(ref m_Radius, value)) SetAllDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// Segments of indicator axis.
|
||||
/// 指示器轴的分割段数。
|
||||
/// </summary>
|
||||
public int splitNumber
|
||||
{
|
||||
get { return m_SplitNumber; }
|
||||
set { if (PropertyUtil.SetStruct(ref m_SplitNumber, value)) SetAllDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// the center of radar chart.
|
||||
/// 雷达图的中心点。数组的第一项是横坐标,第二项是纵坐标。
|
||||
/// 当值为0-1之间时表示百分比,设置成百分比时第一项是相对于容器宽度,第二项是相对于容器高度。
|
||||
/// </summary>
|
||||
public float[] center
|
||||
{
|
||||
get { return m_Center; }
|
||||
set { if (value != null) { m_Center = value; SetAllDirty(); } }
|
||||
}
|
||||
/// <summary>
|
||||
/// axis line.
|
||||
/// 轴线。
|
||||
/// </summary>
|
||||
public AxisLine axisLine
|
||||
{
|
||||
get { return m_AxisLine; }
|
||||
set { if (PropertyUtil.SetClass(ref m_AxisLine, value, true)) SetAllDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// split line.
|
||||
/// 分割线。
|
||||
/// </summary>
|
||||
public AxisSplitLine splitLine
|
||||
{
|
||||
get { return m_SplitLine; }
|
||||
set { if (PropertyUtil.SetClass(ref m_SplitLine, value, true)) SetAllDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// Split area of axis in grid area.
|
||||
/// 分割区域。
|
||||
/// </summary>
|
||||
public AxisSplitArea splitArea
|
||||
{
|
||||
get { return m_SplitArea; }
|
||||
set { if (PropertyUtil.SetClass(ref m_SplitArea, value, true)) SetAllDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// Whether to show indicator.
|
||||
/// 是否显示指示器。
|
||||
/// </summary>
|
||||
public bool indicator
|
||||
{
|
||||
get { return m_Indicator; }
|
||||
set { if (PropertyUtil.SetStruct(ref m_Indicator, value)) SetComponentDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// The gap of indicator and radar.
|
||||
/// 指示器和雷达的间距。
|
||||
/// </summary>
|
||||
public float indicatorGap
|
||||
{
|
||||
get { return m_IndicatorGap; }
|
||||
set { if (PropertyUtil.SetStruct(ref m_IndicatorGap, value)) SetComponentDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// The ratio of maximum and minimum values rounded upward. The default is 0, which is automatically calculated.
|
||||
/// 最大最小值向上取整的倍率。默认为0时自动计算。
|
||||
/// </summary>
|
||||
public int ceilRate
|
||||
{
|
||||
get { return m_CeilRate; }
|
||||
set { if (PropertyUtil.SetStruct(ref m_CeilRate, value < 0 ? 0 : value)) SetAllDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// 是否Tooltip显示轴线上的所有数据。
|
||||
/// </summary>
|
||||
public bool isAxisTooltip
|
||||
{
|
||||
get { return m_IsAxisTooltip; }
|
||||
set { if (PropertyUtil.SetStruct(ref m_IsAxisTooltip, value)) SetAllDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// The position type of indicator.
|
||||
/// 显示位置类型。
|
||||
/// </summary>
|
||||
public PositionType positionType
|
||||
{
|
||||
get { return m_PositionType; }
|
||||
set { if (PropertyUtil.SetStruct(ref m_PositionType, value)) SetAllDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// The color displayed when data out of range.
|
||||
/// 数值超出范围时显示的颜色。
|
||||
/// </summary>
|
||||
public Color32 outRangeColor
|
||||
{
|
||||
get { return m_OutRangeColor; }
|
||||
set { if (PropertyUtil.SetStruct(ref m_OutRangeColor, value)) SetAllDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// Whether serie data connect to radar center with line.
|
||||
/// 数值是否连线到中心点。
|
||||
/// </summary>
|
||||
public bool connectCenter
|
||||
{
|
||||
get { return m_ConnectCenter; }
|
||||
set { if (PropertyUtil.SetStruct(ref m_ConnectCenter, value)) SetAllDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// Whether need gradient for data line.
|
||||
/// 数值线段是否需要渐变。
|
||||
/// </summary>
|
||||
public bool lineGradient
|
||||
{
|
||||
get { return m_LineGradient; }
|
||||
set { if (PropertyUtil.SetStruct(ref m_LineGradient, value)) SetAllDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// the indicator list.
|
||||
/// 指示器列表。
|
||||
/// </summary>
|
||||
public List<Indicator> indicatorList { get { return m_IndicatorList; } }
|
||||
|
||||
public bool IsPointerEnter()
|
||||
{
|
||||
return context.isPointerEnter;
|
||||
}
|
||||
|
||||
public override void SetDefaultValue()
|
||||
{
|
||||
m_Show = true;
|
||||
m_Shape = Shape.Polygon;
|
||||
m_Radius = 0.35f;
|
||||
m_SplitNumber = 5;
|
||||
m_Indicator = true;
|
||||
m_IndicatorList = new List<Indicator>(5){
|
||||
new Indicator(){name="indicator1",max = 0},
|
||||
new Indicator(){name="indicator2",max = 0},
|
||||
new Indicator(){name="indicator3",max = 0},
|
||||
new Indicator(){name="indicator4",max = 0},
|
||||
new Indicator(){name="indicator5",max = 0},
|
||||
};
|
||||
center[0] = 0.5f;
|
||||
center[1] = 0.4f;
|
||||
splitLine.show = true;
|
||||
splitArea.show = true;
|
||||
}
|
||||
|
||||
private bool IsEqualsIndicatorList(List<Indicator> indicators1, List<Indicator> indicators2)
|
||||
{
|
||||
if (indicators1.Count != indicators2.Count) return false;
|
||||
for (int i = 0; i < indicators1.Count; i++)
|
||||
{
|
||||
var indicator1 = indicators1[i];
|
||||
var indicator2 = indicators2[i];
|
||||
if (!indicator1.Equals(indicator2)) return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public bool IsInIndicatorRange(int index, double value)
|
||||
{
|
||||
var indicator = GetIndicator(index);
|
||||
return indicator == null ? true : indicator.IsInRange(value);
|
||||
}
|
||||
|
||||
public double GetIndicatorMin(int index)
|
||||
{
|
||||
if (index >= 0 && index < m_IndicatorList.Count)
|
||||
{
|
||||
return m_IndicatorList[index].min;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
public double GetIndicatorMax(int index)
|
||||
{
|
||||
if (index >= 0 && index < m_IndicatorList.Count)
|
||||
{
|
||||
return m_IndicatorList[index].max;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
internal void UpdateRadarCenter(Vector3 chartPosition, float chartWidth, float chartHeight)
|
||||
{
|
||||
if (center.Length < 2) return;
|
||||
var centerX = center[0] <= 1 ? chartWidth * center[0] : center[0];
|
||||
var centerY = center[1] <= 1 ? chartHeight * center[1] : center[1];
|
||||
context.center = chartPosition + new Vector3(centerX, centerY);
|
||||
if (radius <= 0)
|
||||
{
|
||||
context.radius = 0;
|
||||
}
|
||||
else if (radius <= 1)
|
||||
{
|
||||
context.radius = Mathf.Min(chartWidth, chartHeight) * radius;
|
||||
}
|
||||
else
|
||||
{
|
||||
context.radius = radius;
|
||||
}
|
||||
if (shape == RadarCoord.Shape.Polygon && positionType == PositionType.Between)
|
||||
{
|
||||
var angle = Mathf.PI / indicatorList.Count;
|
||||
context.dataRadius = context.radius * Mathf.Cos(angle);
|
||||
}
|
||||
else
|
||||
{
|
||||
context.dataRadius = context.radius;
|
||||
}
|
||||
}
|
||||
|
||||
public Vector3 GetIndicatorPosition(int index)
|
||||
{
|
||||
int indicatorNum = indicatorList.Count;
|
||||
var angle = 0f;
|
||||
switch (positionType)
|
||||
{
|
||||
case PositionType.Vertice:
|
||||
angle = 2 * Mathf.PI / indicatorNum * index;
|
||||
break;
|
||||
case PositionType.Between:
|
||||
angle = 2 * Mathf.PI / indicatorNum * (index + 0.5f);
|
||||
break;
|
||||
}
|
||||
var x = context.center.x + (context.radius + indicatorGap) * Mathf.Sin(angle);
|
||||
var y = context.center.y + (context.radius + indicatorGap) * Mathf.Cos(angle);
|
||||
return new Vector3(x, y);
|
||||
}
|
||||
|
||||
public void AddIndicator(RadarCoord.Indicator indicator)
|
||||
{
|
||||
indicatorList.Add(indicator);
|
||||
SetAllDirty();
|
||||
}
|
||||
|
||||
public RadarCoord.Indicator AddIndicator(string name, float min, float max)
|
||||
{
|
||||
var indicator = new RadarCoord.Indicator();
|
||||
indicator.name = name;
|
||||
indicator.min = min;
|
||||
indicator.max = max;
|
||||
indicatorList.Add(indicator);
|
||||
SetAllDirty();
|
||||
return indicator;
|
||||
}
|
||||
|
||||
public bool UpdateIndicator(int indicatorIndex, string name, float min, float max)
|
||||
{
|
||||
var indicator = GetIndicator(indicatorIndex);
|
||||
if (indicator == null) return false;
|
||||
indicator.name = name;
|
||||
indicator.min = min;
|
||||
indicator.max = max;
|
||||
SetAllDirty();
|
||||
return true;
|
||||
}
|
||||
|
||||
public RadarCoord.Indicator GetIndicator(int indicatorIndex)
|
||||
{
|
||||
if (indicatorIndex < 0 || indicatorIndex > indicatorList.Count - 1) return null;
|
||||
return indicatorList[indicatorIndex];
|
||||
}
|
||||
|
||||
public override void ClearData()
|
||||
{
|
||||
indicatorList.Clear();
|
||||
}
|
||||
}
|
||||
}
|
||||
11
Runtime/Component/Radar/RadarCoord.cs.meta
Normal file
11
Runtime/Component/Radar/RadarCoord.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 876512c564bd144be99d0acbe079cf8b
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
23
Runtime/Component/Radar/RadarCoordContext.cs
Normal file
23
Runtime/Component/Radar/RadarCoordContext.cs
Normal file
@@ -0,0 +1,23 @@
|
||||
|
||||
using UnityEngine;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine.UI;
|
||||
|
||||
namespace XCharts
|
||||
{
|
||||
public class RadarCoordContext : MainComponentContext
|
||||
{
|
||||
/// <summary>
|
||||
/// the center position of radar in container.
|
||||
/// 雷达图在容器中的具体中心点。
|
||||
/// </summary>
|
||||
public Vector3 center { get; internal set; }
|
||||
/// <summary>
|
||||
/// the true radius of radar.
|
||||
/// 雷达图的运行时实际半径。
|
||||
/// </summary>
|
||||
public float radius { get; internal set; }
|
||||
public float dataRadius { get; internal set; }
|
||||
public bool isPointerEnter { get; set; }
|
||||
}
|
||||
}
|
||||
11
Runtime/Component/Radar/RadarCoordContext.cs.meta
Normal file
11
Runtime/Component/Radar/RadarCoordContext.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 5f7419e8466e048cb9689ab85d20e4de
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
173
Runtime/Component/Radar/RadarCoordHandler.cs
Normal file
173
Runtime/Component/Radar/RadarCoordHandler.cs
Normal file
@@ -0,0 +1,173 @@
|
||||
|
||||
using UnityEngine;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine.UI;
|
||||
using XUGL;
|
||||
|
||||
namespace XCharts
|
||||
{
|
||||
[UnityEngine.Scripting.Preserve]
|
||||
internal sealed class RadarCoordHandler : MainComponentHandler<RadarCoord>
|
||||
{
|
||||
private const string INDICATOR_TEXT = "indicator";
|
||||
|
||||
public override void InitComponent()
|
||||
{
|
||||
InitRadarCoord(component);
|
||||
}
|
||||
|
||||
public override void Update()
|
||||
{
|
||||
if (!chart.isPointerInChart)
|
||||
{
|
||||
component.context.isPointerEnter = false;
|
||||
return;
|
||||
}
|
||||
var radar = component;
|
||||
radar.context.isPointerEnter = radar.show
|
||||
&& Vector3.Distance(radar.context.center, chart.pointerPos) <= radar.context.radius;
|
||||
}
|
||||
|
||||
public override void DrawBase(VertexHelper vh)
|
||||
{
|
||||
DrawRadarCoord(vh, component);
|
||||
}
|
||||
|
||||
private void InitRadarCoord(RadarCoord radar)
|
||||
{
|
||||
float txtWid = 100;
|
||||
float txtHig = 20;
|
||||
radar.painter = chart.GetPainter(radar.index);
|
||||
radar.refreshComponent = delegate ()
|
||||
{
|
||||
ChartHelper.HideAllObject(chart.transform, INDICATOR_TEXT + "_" + radar.index);
|
||||
radar.UpdateRadarCenter(chart.chartPosition, chart.chartWidth, chart.chartHeight);
|
||||
for (int i = 0; i < radar.indicatorList.Count; i++)
|
||||
{
|
||||
var indicator = radar.indicatorList[i];
|
||||
var pos = radar.GetIndicatorPosition(i);
|
||||
var textStyle = indicator.textStyle;
|
||||
var objName = INDICATOR_TEXT + "_" + radar.index + "_" + i;
|
||||
var txt = ChartHelper.AddTextObject(objName, chart.transform, new Vector2(0.5f, 0.5f),
|
||||
new Vector2(0.5f, 0.5f), new Vector2(0.5f, 0.5f), new Vector2(txtWid, txtHig),
|
||||
textStyle, chart.theme.axis);
|
||||
txt.gameObject.hideFlags = chart.chartHideFlags;
|
||||
txt.SetAlignment(textStyle.GetAlignment(TextAnchor.MiddleCenter));
|
||||
txt.SetText(radar.indicatorList[i].name);
|
||||
txt.SetActive(radar.indicator);
|
||||
var offset = new Vector3(textStyle.offset.x, textStyle.offset.y);
|
||||
AxisHelper.AdjustCircleLabelPos(txt, pos, radar.context.center, txtHig, offset);
|
||||
}
|
||||
chart.RefreshBasePainter();
|
||||
};
|
||||
radar.refreshComponent.Invoke();
|
||||
}
|
||||
|
||||
private void DrawRadarCoord(VertexHelper vh, RadarCoord radar)
|
||||
{
|
||||
if (!radar.show) return;
|
||||
radar.UpdateRadarCenter(chart.chartPosition, chart.chartWidth, chart.chartHeight);
|
||||
if (radar.shape == RadarCoord.Shape.Circle)
|
||||
{
|
||||
DrawCricleRadar(vh, radar);
|
||||
}
|
||||
else
|
||||
{
|
||||
DrawPolygonRadar(vh, radar);
|
||||
}
|
||||
}
|
||||
|
||||
private void DrawCricleRadar(VertexHelper vh, RadarCoord radar)
|
||||
{
|
||||
float insideRadius = 0, outsideRadius = 0;
|
||||
float block = radar.context.radius / radar.splitNumber;
|
||||
int indicatorNum = radar.indicatorList.Count;
|
||||
Vector3 p = radar.context.center;
|
||||
Vector3 p1;
|
||||
float 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);
|
||||
var splitLineColor = radar.splitLine.GetColor(chart.theme.axis.splitLineColor);
|
||||
var splitLineWidth = radar.splitLine.GetWidth(chart.theme.axis.splitLineWidth);
|
||||
for (int i = 0; i < radar.splitNumber; i++)
|
||||
{
|
||||
var color = radar.splitArea.GetColor(i, chart.theme.axis);
|
||||
outsideRadius = insideRadius + block;
|
||||
if (radar.splitArea.show)
|
||||
{
|
||||
UGL.DrawDoughnut(vh, p, insideRadius, outsideRadius, color, Color.clear,
|
||||
0, 360, chart.settings.cicleSmoothness);
|
||||
}
|
||||
if (radar.splitLine.show)
|
||||
{
|
||||
UGL.DrawEmptyCricle(vh, p, outsideRadius, splitLineWidth, splitLineColor,
|
||||
Color.clear, chart.settings.cicleSmoothness);
|
||||
}
|
||||
insideRadius = outsideRadius;
|
||||
}
|
||||
if (radar.axisLine.show)
|
||||
{
|
||||
for (int j = 0; j <= indicatorNum; j++)
|
||||
{
|
||||
float currAngle = j * angle;
|
||||
p1 = new Vector3(p.x + outsideRadius * Mathf.Sin(currAngle),
|
||||
p.y + outsideRadius * Mathf.Cos(currAngle));
|
||||
ChartDrawer.DrawLineStyle(vh, lineType, lineWidth, p, p1, lineColor);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void DrawPolygonRadar(VertexHelper vh, RadarCoord radar)
|
||||
{
|
||||
float insideRadius = 0, outsideRadius = 0;
|
||||
float block = radar.context.radius / radar.splitNumber;
|
||||
int indicatorNum = radar.indicatorList.Count;
|
||||
Vector3 p1, p2, p3, p4;
|
||||
Vector3 p = radar.context.center;
|
||||
float 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);
|
||||
var splitLineColor = radar.splitLine.GetColor(chart.theme.axis.splitLineColor);
|
||||
var splitLineWidth = radar.splitLine.GetWidth(chart.theme.axis.splitLineWidth);
|
||||
var splitLineType = radar.splitLine.GetType(chart.theme.axis.splitLineType);
|
||||
for (int i = 0; i < radar.splitNumber; i++)
|
||||
{
|
||||
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));
|
||||
for (int j = 0; j <= indicatorNum; j++)
|
||||
{
|
||||
float currAngle = 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),
|
||||
p.y + insideRadius * Mathf.Cos(currAngle));
|
||||
if (radar.splitArea.show)
|
||||
{
|
||||
UGL.DrawQuadrilateral(vh, p1, p2, p3, p4, color);
|
||||
}
|
||||
if (radar.splitLine.NeedShow(i))
|
||||
{
|
||||
ChartDrawer.DrawLineStyle(vh, splitLineType, splitLineWidth, p2, p3, splitLineColor);
|
||||
}
|
||||
p1 = p4;
|
||||
p2 = p3;
|
||||
}
|
||||
insideRadius = outsideRadius;
|
||||
}
|
||||
if (radar.axisLine.show)
|
||||
{
|
||||
for (int j = 0; j <= indicatorNum; j++)
|
||||
{
|
||||
float currAngle = 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
11
Runtime/Component/Radar/RadarCoordHandler.cs.meta
Normal file
11
Runtime/Component/Radar/RadarCoordHandler.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 27622e3c95fec42daafff901970daf8f
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user