3.0 - unitypackage

This commit is contained in:
monitor1394
2022-01-05 21:40:48 +08:00
parent c160867765
commit 228a4b2840
846 changed files with 105 additions and 467693 deletions

View File

@@ -0,0 +1,67 @@

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]
[ComponentHandler(typeof(PolarCoordHandler), true)]
[RequireChartComponent(typeof(AngleAxis), typeof(RadiusAxis))]
public class PolarCoord : CoordSystem
{
[SerializeField] private bool m_Show = true;
[SerializeField] private float[] m_Center = new float[2] { 0.5f, 0.45f };
[SerializeField] private float m_Radius = 0.35f;
[SerializeField] private Color m_BackgroundColor;
public PolarCoordContext context = new PolarCoordContext();
/// <summary>
/// Whether to show the polor component.
/// 是否显示极坐标。
/// </summary>
public bool show
{
get { return m_Show; }
set { if (PropertyUtil.SetStruct(ref m_Show, value)) SetVerticesDirty(); }
}
/// <summary>
/// [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.
/// 极坐标的中心点。数组的第一项是横坐标,第二项是纵坐标。
/// 当值为0-1之间时表示百分比设置成百分比时第一项是相对于容器宽度第二项是相对于容器高度。
/// </summary>
public float[] center
{
get { return m_Center; }
set { if (value != null) { m_Center = value; SetAllDirty(); } }
}
/// <summary>
/// [default:0.35f]the radius of polar.
/// 极坐标的半径。
/// </summary>
public float radius
{
get { return m_Radius; }
set { if (PropertyUtil.SetStruct(ref m_Radius, value)) SetAllDirty(); }
}
/// <summary>
/// [default:Color.clear]Background color of polar, which is transparent by default.
/// 极坐标的背景色,默认透明。
/// </summary>
public Color backgroundColor
{
get { return m_BackgroundColor; }
set { if (PropertyUtil.SetColor(ref m_BackgroundColor, value)) SetVerticesDirty(); }
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: ec567fac460994411a8aadcb5e0f9b68
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,20 @@
using System;
using UnityEngine;
namespace XCharts
{
public class PolarCoordContext : MainComponentContext
{
/// <summary>
/// the center position of polar in container.
/// 极坐标在容器中的具体中心点。
/// </summary>
public Vector3 center { get; internal set; }
/// <summary>
/// the true radius of polar.
/// 极坐标的运行时实际半径。
/// </summary>
public float radius { get; internal set; }
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 2eaaaa315fbae4fc3a9976f51a1396b3
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,32 @@
using System;
using UnityEngine;
using UnityEngine.UI;
using XUGL;
namespace XCharts
{
[UnityEngine.Scripting.Preserve]
internal sealed class PolarCoordHandler : MainComponentHandler<PolarCoord>
{
public override void Update()
{
PolarHelper.UpdatePolarCenter(component, chart.chartPosition, chart.chartWidth, chart.chartHeight);
}
public override void DrawBase(VertexHelper vh)
{
DrawPolar(vh, component);
}
private void DrawPolar(VertexHelper vh, PolarCoord polar)
{
PolarHelper.UpdatePolarCenter(polar, chart.chartPosition, chart.chartWidth, chart.chartHeight);
if (!ChartHelper.IsClearColor(polar.backgroundColor))
{
UGL.DrawCricle(vh, polar.context.center, polar.context.radius, polar.backgroundColor);
}
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: af4b941946def4928b416260dec7ac9b
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,28 @@
using UnityEngine;
namespace XCharts
{
internal static class PolarHelper
{
public static void UpdatePolarCenter(PolarCoord polar, Vector3 chartPosition, float chartWidth, float chartHeight)
{
if (polar.center.Length < 2) return;
var centerX = polar.center[0] <= 1 ? chartWidth * polar.center[0] : polar.center[0];
var centerY = polar.center[1] <= 1 ? chartHeight * polar.center[1] : polar.center[1];
polar.context.center = chartPosition + new Vector3(centerX, centerY);
if (polar.radius <= 0)
{
polar.context.radius = 0;
}
else if (polar.radius <= 1)
{
polar.context.radius = Mathf.Min(chartWidth, chartHeight) * polar.radius;
}
else
{
polar.context.radius = polar.radius;
}
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: feb363cc2ae0846b89612143ce4535ae
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant: