mirror of
https://github.com/XCharts-Team/XCharts.git
synced 2026-05-24 18:00:26 +00:00
3.0 - polar chart
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
|
||||
using System;
|
||||
using UnityEngine;
|
||||
using XUGL;
|
||||
|
||||
namespace XCharts
|
||||
{
|
||||
@@ -112,5 +113,33 @@ namespace XCharts
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 给定的线段和Grid边界的交点
|
||||
/// </summary>
|
||||
/// <param name="sp"></param>
|
||||
/// <param name="ep"></param>
|
||||
/// <returns></returns>
|
||||
public bool BoundaryPoint(Vector3 sp, Vector3 ep, ref Vector3 point)
|
||||
{
|
||||
if (Contains(sp) && Contains(ep))
|
||||
{
|
||||
point = ep;
|
||||
return false;
|
||||
}
|
||||
var lb = new Vector3(context.x, context.y);
|
||||
var lt = new Vector3(context.x, context.y + context.height);
|
||||
var rt = new Vector3(context.x + context.width, context.y + context.height);
|
||||
var rb = new Vector3(context.x + context.width, context.y);
|
||||
if (UGLHelper.GetIntersection(sp, ep, rb, rt, ref point))
|
||||
return true;
|
||||
if (UGLHelper.GetIntersection(sp, ep, lt, rt, ref point))
|
||||
return true;
|
||||
if (UGLHelper.GetIntersection(sp, ep, lb, rb, ref point))
|
||||
return true;
|
||||
if (UGLHelper.GetIntersection(sp, ep, lb, lt, ref point))
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -14,7 +14,7 @@ namespace XCharts
|
||||
[Serializable]
|
||||
[ComponentHandler(typeof(PolarCoordHandler), true)]
|
||||
[RequireChartComponent(typeof(AngleAxis), typeof(RadiusAxis))]
|
||||
public class PolarCoord : CoordSystem
|
||||
public class PolarCoord : CoordSystem, ISerieContainer
|
||||
{
|
||||
[SerializeField] private bool m_Show = true;
|
||||
[SerializeField] private float[] m_Center = new float[2] { 0.5f, 0.45f };
|
||||
@@ -63,5 +63,14 @@ namespace XCharts
|
||||
set { if (PropertyUtil.SetColor(ref m_BackgroundColor, value)) SetVerticesDirty(); }
|
||||
}
|
||||
|
||||
public bool IsPointerEnter()
|
||||
{
|
||||
return context.isPointerEnter;
|
||||
}
|
||||
|
||||
public bool Contains(Vector3 pos)
|
||||
{
|
||||
return Vector3.Distance(pos, context.center) < context.radius;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -16,5 +16,6 @@ namespace XCharts
|
||||
/// 极坐标的运行时实际半径。
|
||||
/// </summary>
|
||||
public float radius { get; internal set; }
|
||||
public bool isPointerEnter { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -12,6 +12,11 @@ namespace XCharts
|
||||
public override void Update()
|
||||
{
|
||||
PolarHelper.UpdatePolarCenter(component, chart.chartPosition, chart.chartWidth, chart.chartHeight);
|
||||
|
||||
if (chart.isPointerInChart)
|
||||
component.context.isPointerEnter = component.Contains(chart.pointerPos);
|
||||
else
|
||||
component.context.isPointerEnter = false;
|
||||
}
|
||||
|
||||
public override void DrawBase(VertexHelper vh)
|
||||
|
||||
Reference in New Issue
Block a user