mirror of
https://github.com/XCharts-Team/XCharts.git
synced 2026-05-23 09:20:08 +00:00
增加PolarChart极坐标图表
This commit is contained in:
@@ -805,4 +805,86 @@ namespace XCharts
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Radial axis of polar coordinate.
|
||||
/// 极坐标系的径向轴。
|
||||
/// </summary>
|
||||
[System.Serializable]
|
||||
public class RadiusAxis : Axis
|
||||
{
|
||||
public static RadiusAxis defaultRadiusAxis
|
||||
{
|
||||
get
|
||||
{
|
||||
var axis = new RadiusAxis
|
||||
{
|
||||
m_Show = true,
|
||||
m_Type = AxisType.Value,
|
||||
m_Min = 0,
|
||||
m_Max = 0,
|
||||
m_SplitNumber = 5,
|
||||
m_BoundaryGap = false,
|
||||
m_Data = new List<string>(5),
|
||||
};
|
||||
axis.splitLine.show = true;
|
||||
axis.splitLine.lineStyle.type = LineStyle.Type.Solid;
|
||||
axis.axisLabel.textLimit.enable = false;
|
||||
return axis;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Angle axis of Polar Coordinate.
|
||||
/// 极坐标系的角度轴。
|
||||
/// </summary>
|
||||
[System.Serializable]
|
||||
public class AngleAxis : Axis
|
||||
{
|
||||
[SerializeField] private float m_StartAngle = 90;
|
||||
[SerializeField] private bool m_Clockwise = true;
|
||||
/// <summary>
|
||||
/// Starting angle of axis. 90 degrees by default, standing for top position of center. 0 degree stands for right position of center.
|
||||
/// 起始刻度的角度,默认为 90 度,即圆心的正上方。0 度为圆心的正右方。
|
||||
/// </summary>
|
||||
public float startAngle
|
||||
{
|
||||
get { return m_StartAngle; }
|
||||
set { if (PropertyUtility.SetStruct(ref m_StartAngle, value)) SetAllDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// Whether the positive position of axis is in clockwise. True for clockwise by default.
|
||||
/// 刻度增长是否按顺时针,默认顺时针。
|
||||
/// </summary>
|
||||
public bool clockWise
|
||||
{
|
||||
get { return m_Clockwise; }
|
||||
set { if (PropertyUtility.SetStruct(ref m_Clockwise, value)) SetAllDirty(); }
|
||||
}
|
||||
|
||||
public float runtimeStartAngle { get; set; }
|
||||
|
||||
public static AngleAxis defaultAngleAxis
|
||||
{
|
||||
get
|
||||
{
|
||||
var axis = new AngleAxis
|
||||
{
|
||||
m_Show = true,
|
||||
m_Type = AxisType.Value,
|
||||
m_SplitNumber = 13,
|
||||
m_BoundaryGap = false,
|
||||
m_Data = new List<string>(13),
|
||||
};
|
||||
axis.splitLine.show = true;
|
||||
axis.splitLine.lineStyle.type = LineStyle.Type.Solid;
|
||||
axis.axisLabel.textLimit.enable = false;
|
||||
axis.minMaxType = AxisMinMaxType.Custom;
|
||||
axis.min = 0;
|
||||
axis.max = 360;
|
||||
return axis;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
92
Runtime/Component/Main/Polar.cs
Normal file
92
Runtime/Component/Main/Polar.cs
Normal file
@@ -0,0 +1,92 @@
|
||||
/******************************************/
|
||||
/* */
|
||||
/* Copyright (c) 2018 monitor1394 */
|
||||
/* https://github.com/monitor1394 */
|
||||
/* */
|
||||
/******************************************/
|
||||
|
||||
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>
|
||||
/// Whether to show the grid in rectangular coordinate.
|
||||
/// 是否显示直角坐标系网格。
|
||||
/// </summary>
|
||||
public bool show
|
||||
{
|
||||
get { return m_Show; }
|
||||
set { if (PropertyUtility.SetStruct(ref m_Show, value)) SetVerticesDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// the center of ploar.
|
||||
/// 极坐标的中心点。数组的第一项是横坐标,第二项是纵坐标。
|
||||
/// 当值为0-1之间时表示百分比,设置成百分比时第一项是相对于容器宽度,第二项是相对于容器高度。
|
||||
/// </summary>
|
||||
public float[] center
|
||||
{
|
||||
get { return m_Center; }
|
||||
set { if (value != null) { m_Center = value; SetAllDirty(); } }
|
||||
}
|
||||
/// <summary>
|
||||
/// the radius of polar.
|
||||
/// 极坐标的半径。
|
||||
/// </summary>
|
||||
public float radius
|
||||
{
|
||||
get { return m_Radius; }
|
||||
set { if (PropertyUtility.SetStruct(ref m_Radius, value)) SetAllDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// Background color of polar, which is transparent by default.
|
||||
/// 极坐标的背景色,默认透明。
|
||||
/// </summary>
|
||||
public Color backgroundColor
|
||||
{
|
||||
get { return m_BackgroundColor; }
|
||||
set { if (PropertyUtility.SetColor(ref m_BackgroundColor, value)) SetVerticesDirty(); }
|
||||
}
|
||||
|
||||
/// <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; }
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
11
Runtime/Component/Main/Polar.cs.meta
Normal file
11
Runtime/Component/Main/Polar.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f9eb9ba0a1d154f11ba169fc07ad7a91
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -249,6 +249,10 @@ namespace XCharts
|
||||
/// 提示框的gameObject。
|
||||
/// </summary>
|
||||
public GameObject runtimeGameObject { get { return m_GameObject; } }
|
||||
/// <summary>
|
||||
/// 当前指示的角度。
|
||||
/// </summary>
|
||||
public float runtimeAngle { get; internal set; }
|
||||
|
||||
public static Tooltip defaultTooltip
|
||||
{
|
||||
@@ -389,7 +393,7 @@ namespace XCharts
|
||||
/// <param name="flag"></param>
|
||||
public void SetActive(bool flag)
|
||||
{
|
||||
if(!flag && m_AlwayShow) return;
|
||||
if (!flag && m_AlwayShow) return;
|
||||
lastDataIndex[0] = lastDataIndex[1] = -1;
|
||||
if (m_GameObject && m_GameObject.activeInHierarchy != flag)
|
||||
m_GameObject.SetActive(flag);
|
||||
|
||||
@@ -167,6 +167,7 @@ namespace XCharts
|
||||
/// </summary>
|
||||
public float runtimePieOffsetRadius { get; internal set; }
|
||||
public Vector3 runtimePosition { get; internal set; }
|
||||
public float runtimeAngle { get; internal set; }
|
||||
public Vector3 runtiemPieOffsetCenter { get; internal set; }
|
||||
private List<float> m_PreviousData = new List<float>();
|
||||
private List<float> m_DataUpdateTime = new List<float>();
|
||||
|
||||
Reference in New Issue
Block a user