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:
8
Runtime/Coord/Calendar.meta
Normal file
8
Runtime/Coord/Calendar.meta
Normal file
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: da5534d24de514e54911c0efb7b7b2ba
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
20
Runtime/Coord/Calendar/CalendarCoord.cs
Normal file
20
Runtime/Coord/Calendar/CalendarCoord.cs
Normal file
@@ -0,0 +1,20 @@
|
||||
|
||||
using System;
|
||||
using UnityEngine;
|
||||
|
||||
namespace XCharts
|
||||
{
|
||||
[Serializable]
|
||||
[ComponentHandler(typeof(CalendarCoordHandler), true)]
|
||||
public class CalendarCoord : CoordSystem, IUpdateRuntimeData, ISerieContainer
|
||||
{
|
||||
public bool IsPointerEnter()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
public void UpdateRuntimeData(float chartX, float chartY, float chartWidth, float chartHeight)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
11
Runtime/Coord/Calendar/CalendarCoord.cs.meta
Normal file
11
Runtime/Coord/Calendar/CalendarCoord.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: eccc042d880064df8a2a99be68969918
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
11
Runtime/Coord/Calendar/CalendarCoordHandler.cs
Normal file
11
Runtime/Coord/Calendar/CalendarCoordHandler.cs
Normal file
@@ -0,0 +1,11 @@
|
||||
|
||||
using System;
|
||||
using UnityEngine;
|
||||
|
||||
namespace XCharts
|
||||
{
|
||||
[UnityEngine.Scripting.Preserve]
|
||||
internal sealed class CalendarCoordHandler : MainComponentHandler<CalendarCoord>
|
||||
{
|
||||
}
|
||||
}
|
||||
11
Runtime/Coord/Calendar/CalendarCoordHandler.cs.meta
Normal file
11
Runtime/Coord/Calendar/CalendarCoordHandler.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 57a6c8647580846888712d387da72d1a
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
8
Runtime/Coord/Grid.meta
Normal file
8
Runtime/Coord/Grid.meta
Normal file
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 7d09a247055fa44dcab4eb4c61401a9b
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
116
Runtime/Coord/Grid/GridCoord.cs
Normal file
116
Runtime/Coord/Grid/GridCoord.cs
Normal file
@@ -0,0 +1,116 @@
|
||||
|
||||
using System;
|
||||
using UnityEngine;
|
||||
|
||||
namespace XCharts
|
||||
{
|
||||
/// <summary>
|
||||
/// Grid component.
|
||||
/// Drawing grid in rectangular coordinate. Line chart, bar chart, and scatter chart can be drawn in grid.
|
||||
/// <para>
|
||||
/// 网格组件。
|
||||
/// 直角坐标系内绘图网格。可以在网格上绘制折线图,柱状图,散点图。
|
||||
/// </para>
|
||||
/// </summary>
|
||||
[Serializable]
|
||||
[ComponentHandler(typeof(GridCoordHandler), true)]
|
||||
public class GridCoord : CoordSystem, IUpdateRuntimeData, ISerieContainer
|
||||
{
|
||||
[SerializeField] private bool m_Show = true;
|
||||
[SerializeField] private float m_Left = 0.1f;
|
||||
[SerializeField] private float m_Right = 0.08f;
|
||||
[SerializeField] private float m_Top = 0.22f;
|
||||
[SerializeField] private float m_Bottom = 0.12f;
|
||||
[SerializeField] private Color m_BackgroundColor;
|
||||
|
||||
public GridCoordContext context = new GridCoordContext();
|
||||
|
||||
/// <summary>
|
||||
/// Whether to show the grid in rectangular coordinate.
|
||||
/// 是否显示直角坐标系网格。
|
||||
/// </summary>
|
||||
public bool show
|
||||
{
|
||||
get { return m_Show; }
|
||||
set { if (PropertyUtil.SetStruct(ref m_Show, value)) SetVerticesDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// Distance between grid component and the left side of the container.
|
||||
/// grid 组件离容器左侧的距离。
|
||||
/// </summary>
|
||||
public float left
|
||||
{
|
||||
get { return m_Left; }
|
||||
set { if (PropertyUtil.SetStruct(ref m_Left, value)) SetAllDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// Distance between grid component and the right side of the container.
|
||||
/// grid 组件离容器右侧的距离。
|
||||
/// </summary>
|
||||
public float right
|
||||
{
|
||||
get { return m_Right; }
|
||||
set { if (PropertyUtil.SetStruct(ref m_Right, value)) SetAllDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// Distance between grid component and the top side of the container.
|
||||
/// grid 组件离容器上侧的距离。
|
||||
/// </summary>
|
||||
public float top
|
||||
{
|
||||
get { return m_Top; }
|
||||
set { if (PropertyUtil.SetStruct(ref m_Top, value)) SetAllDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// Distance between grid component and the bottom side of the container.
|
||||
/// grid 组件离容器下侧的距离。
|
||||
/// </summary>
|
||||
public float bottom
|
||||
{
|
||||
get { return m_Bottom; }
|
||||
set { if (PropertyUtil.SetStruct(ref m_Bottom, value)) SetAllDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// Background color of grid, which is transparent by default.
|
||||
/// 网格背景色,默认透明。
|
||||
/// </summary>
|
||||
public Color backgroundColor
|
||||
{
|
||||
get { return m_BackgroundColor; }
|
||||
set { if (PropertyUtil.SetColor(ref m_BackgroundColor, value)) SetVerticesDirty(); }
|
||||
}
|
||||
|
||||
public bool IsPointerEnter()
|
||||
{
|
||||
return context.isPointerEnter;
|
||||
}
|
||||
|
||||
public void UpdateRuntimeData(float chartX, float chartY, float chartWidth, float chartHeight)
|
||||
{
|
||||
context.left = left <= 1 ? left * chartWidth : left;
|
||||
context.bottom = bottom <= 1 ? bottom * chartHeight : bottom;
|
||||
context.top = top <= 1 ? top * chartHeight : top;
|
||||
context.right = right <= 1 ? right * chartWidth : right;
|
||||
context.x = chartX + context.left;
|
||||
context.y = chartY + context.bottom;
|
||||
context.width = chartWidth - context.left - context.right;
|
||||
context.height = chartHeight - context.top - context.bottom;
|
||||
context.position = new Vector3(context.x, context.y);
|
||||
}
|
||||
|
||||
public bool Contains(Vector3 pos)
|
||||
{
|
||||
return Contains(pos.x, pos.y);
|
||||
}
|
||||
|
||||
public bool Contains(float x, float y)
|
||||
{
|
||||
if (x < context.x - 1 || x > context.x + context.width + 1 ||
|
||||
y < context.y - 1 || y > context.y + context.height + 1)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
11
Runtime/Coord/Grid/GridCoord.cs.meta
Normal file
11
Runtime/Coord/Grid/GridCoord.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f99c74cc7f2c44bfcae9f5c40e6b7c46
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
19
Runtime/Coord/Grid/GridCoordContext.cs
Normal file
19
Runtime/Coord/Grid/GridCoordContext.cs
Normal file
@@ -0,0 +1,19 @@
|
||||
|
||||
using UnityEngine;
|
||||
|
||||
namespace XCharts
|
||||
{
|
||||
public class GridCoordContext : MainComponentContext, IRectContext
|
||||
{
|
||||
public float x { get; internal set; }
|
||||
public float y { get; internal set; }
|
||||
public float width { get; internal set; }
|
||||
public float height { get; internal set; }
|
||||
public Vector3 position { get; internal set; }
|
||||
public float left { get; internal set; }
|
||||
public float right { get; internal set; }
|
||||
public float bottom { get; internal set; }
|
||||
public float top { get; internal set; }
|
||||
public bool isPointerEnter { get; set; }
|
||||
}
|
||||
}
|
||||
11
Runtime/Coord/Grid/GridCoordContext.cs.meta
Normal file
11
Runtime/Coord/Grid/GridCoordContext.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 6a7c139761fe64d93be4c65619a0fd38
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
82
Runtime/Coord/Grid/GridCoordHandler.cs
Normal file
82
Runtime/Coord/Grid/GridCoordHandler.cs
Normal file
@@ -0,0 +1,82 @@
|
||||
|
||||
using System;
|
||||
using System.Text;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
using XUGL;
|
||||
|
||||
namespace XCharts
|
||||
{
|
||||
[UnityEngine.Scripting.Preserve]
|
||||
internal sealed class GridCoordHandler : MainComponentHandler<GridCoord>
|
||||
{
|
||||
public override void InitComponent()
|
||||
{
|
||||
var grid = component;
|
||||
grid.painter = chart.painter;
|
||||
grid.refreshComponent = delegate ()
|
||||
{
|
||||
grid.UpdateRuntimeData(chart.chartX, chart.chartY, chart.chartWidth, chart.chartHeight);
|
||||
chart.OnCoordinateChanged();
|
||||
};
|
||||
grid.refreshComponent();
|
||||
}
|
||||
|
||||
public override void CheckComponent(StringBuilder sb)
|
||||
{
|
||||
var grid = component;
|
||||
if (grid.left >= chart.chartWidth)
|
||||
sb.Append("warning:grid->left > chartWidth\n");
|
||||
if (grid.right >= chart.chartWidth)
|
||||
sb.Append("warning:grid->right > chartWidth\n");
|
||||
if (grid.top >= chart.chartHeight)
|
||||
sb.Append("warning:grid->top > chartHeight\n");
|
||||
if (grid.bottom >= chart.chartHeight)
|
||||
sb.Append("warning:grid->bottom > chartHeight\n");
|
||||
if (grid.left + grid.right >= chart.chartWidth)
|
||||
sb.Append("warning:grid.left + grid.right > chartWidth\n");
|
||||
if (grid.top + grid.bottom >= chart.chartHeight)
|
||||
sb.Append("warning:grid.top + grid.bottom > chartHeight\n");
|
||||
}
|
||||
|
||||
public override void Update()
|
||||
{
|
||||
if (chart.isPointerInChart)
|
||||
{
|
||||
component.context.isPointerEnter = component.Contains(chart.pointerPos);
|
||||
}
|
||||
else
|
||||
{
|
||||
component.context.isPointerEnter = false;
|
||||
}
|
||||
}
|
||||
|
||||
public override void DrawBase(VertexHelper vh)
|
||||
{
|
||||
if (!SeriesHelper.IsAnyClipSerie(chart.series))
|
||||
{
|
||||
DrawCoord(vh);
|
||||
}
|
||||
}
|
||||
public override void DrawTop(VertexHelper vh)
|
||||
{
|
||||
if (SeriesHelper.IsAnyClipSerie(chart.series))
|
||||
{
|
||||
DrawCoord(vh);
|
||||
}
|
||||
}
|
||||
|
||||
private void DrawCoord(VertexHelper vh)
|
||||
{
|
||||
var grid = component;
|
||||
if (grid.show && !ChartHelper.IsClearColor(grid.backgroundColor))
|
||||
{
|
||||
var p1 = new Vector2(grid.context.x, grid.context.y);
|
||||
var p2 = new Vector2(grid.context.x, grid.context.y + grid.context.height);
|
||||
var p3 = new Vector2(grid.context.x + grid.context.width, grid.context.y + grid.context.height);
|
||||
var p4 = new Vector2(grid.context.x + grid.context.width, grid.context.y);
|
||||
UGL.DrawQuadrilateral(vh, p1, p2, p3, p4, grid.backgroundColor);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
11
Runtime/Coord/Grid/GridCoordHandler.cs.meta
Normal file
11
Runtime/Coord/Grid/GridCoordHandler.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 7e22a9b603e57459f97040b285f3936a
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
8
Runtime/Coord/Parallel.meta
Normal file
8
Runtime/Coord/Parallel.meta
Normal file
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 30b1519a34fcc4ca3a56834527584719
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
126
Runtime/Coord/Parallel/ParallelCoord.cs
Normal file
126
Runtime/Coord/Parallel/ParallelCoord.cs
Normal file
@@ -0,0 +1,126 @@
|
||||
|
||||
using System;
|
||||
using UnityEngine;
|
||||
|
||||
namespace XCharts
|
||||
{
|
||||
/// <summary>
|
||||
/// Grid component.
|
||||
/// Drawing grid in rectangular coordinate. Line chart, bar chart, and scatter chart can be drawn in grid.
|
||||
/// <para>
|
||||
/// 网格组件。
|
||||
/// 直角坐标系内绘图网格。可以在网格上绘制折线图,柱状图,散点图。
|
||||
/// </para>
|
||||
/// </summary>
|
||||
[Serializable]
|
||||
[ComponentHandler(typeof(ParallelCoordHandler), true)]
|
||||
public class ParallelCoord : CoordSystem, IUpdateRuntimeData, ISerieContainer
|
||||
{
|
||||
[SerializeField] private bool m_Show = true;
|
||||
[SerializeField] protected Orient m_Orient = Orient.Vertical;
|
||||
[SerializeField] private float m_Left = 0.1f;
|
||||
[SerializeField] private float m_Right = 0.08f;
|
||||
[SerializeField] private float m_Top = 0.22f;
|
||||
[SerializeField] private float m_Bottom = 0.12f;
|
||||
[SerializeField] private Color m_BackgroundColor;
|
||||
|
||||
public ParallelCoordContext context = new ParallelCoordContext();
|
||||
|
||||
/// <summary>
|
||||
/// Whether to show the grid in rectangular coordinate.
|
||||
/// 是否显示直角坐标系网格。
|
||||
/// </summary>
|
||||
public bool show
|
||||
{
|
||||
get { return m_Show; }
|
||||
set { if (PropertyUtil.SetStruct(ref m_Show, value)) SetVerticesDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// Orientation of the axis. By default, it's 'Vertical'. You can set it to be 'Horizonal' to make a vertical axis.
|
||||
/// 坐标轴朝向。默认为垂直朝向。
|
||||
/// </summary>
|
||||
public Orient orient
|
||||
{
|
||||
get { return m_Orient; }
|
||||
set { if (PropertyUtil.SetStruct(ref m_Orient, value)) SetAllDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// Distance between grid component and the left side of the container.
|
||||
/// grid 组件离容器左侧的距离。
|
||||
/// </summary>
|
||||
public float left
|
||||
{
|
||||
get { return m_Left; }
|
||||
set { if (PropertyUtil.SetStruct(ref m_Left, value)) SetAllDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// Distance between grid component and the right side of the container.
|
||||
/// grid 组件离容器右侧的距离。
|
||||
/// </summary>
|
||||
public float right
|
||||
{
|
||||
get { return m_Right; }
|
||||
set { if (PropertyUtil.SetStruct(ref m_Right, value)) SetAllDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// Distance between grid component and the top side of the container.
|
||||
/// grid 组件离容器上侧的距离。
|
||||
/// </summary>
|
||||
public float top
|
||||
{
|
||||
get { return m_Top; }
|
||||
set { if (PropertyUtil.SetStruct(ref m_Top, value)) SetAllDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// Distance between grid component and the bottom side of the container.
|
||||
/// grid 组件离容器下侧的距离。
|
||||
/// </summary>
|
||||
public float bottom
|
||||
{
|
||||
get { return m_Bottom; }
|
||||
set { if (PropertyUtil.SetStruct(ref m_Bottom, value)) SetAllDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// Background color of grid, which is transparent by default.
|
||||
/// 网格背景色,默认透明。
|
||||
/// </summary>
|
||||
public Color backgroundColor
|
||||
{
|
||||
get { return m_BackgroundColor; }
|
||||
set { if (PropertyUtil.SetColor(ref m_BackgroundColor, value)) SetVerticesDirty(); }
|
||||
}
|
||||
|
||||
public bool IsPointerEnter()
|
||||
{
|
||||
return context.runtimeIsPointerEnter;
|
||||
}
|
||||
|
||||
public void UpdateRuntimeData(float chartX, float chartY, float chartWidth, float chartHeight)
|
||||
{
|
||||
context.left = left <= 1 ? left * chartWidth : left;
|
||||
context.bottom = bottom <= 1 ? bottom * chartHeight : bottom;
|
||||
context.top = top <= 1 ? top * chartHeight : top;
|
||||
context.right = right <= 1 ? right * chartWidth : right;
|
||||
context.x = chartX + context.left;
|
||||
context.y = chartY + context.bottom;
|
||||
context.width = chartWidth - context.left - context.right;
|
||||
context.height = chartHeight - context.top - context.bottom;
|
||||
context.position = new Vector3(context.x, context.y);
|
||||
}
|
||||
|
||||
public bool Contains(Vector3 pos)
|
||||
{
|
||||
return Contains(pos.x, pos.y);
|
||||
}
|
||||
|
||||
public bool Contains(float x, float y)
|
||||
{
|
||||
if (x < context.x - 1 || x > context.x + context.width + 1 ||
|
||||
y < context.y - 1 || y > context.y + context.height + 1)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
11
Runtime/Coord/Parallel/ParallelCoord.cs.meta
Normal file
11
Runtime/Coord/Parallel/ParallelCoord.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a7be31c76736845a9b2c92a7b8051290
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
21
Runtime/Coord/Parallel/ParallelCoordContext.cs
Normal file
21
Runtime/Coord/Parallel/ParallelCoordContext.cs
Normal file
@@ -0,0 +1,21 @@
|
||||
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
namespace XCharts
|
||||
{
|
||||
public class ParallelCoordContext : MainComponentContext
|
||||
{
|
||||
public float x { get; internal set; }
|
||||
public float y { get; internal set; }
|
||||
public float width { get; internal set; }
|
||||
public float height { get; internal set; }
|
||||
public Vector3 position { get; internal set; }
|
||||
public float left { get; internal set; }
|
||||
public float right { get; internal set; }
|
||||
public float bottom { get; internal set; }
|
||||
public float top { get; internal set; }
|
||||
public bool runtimeIsPointerEnter { get; set; }
|
||||
internal List<ParallelAxis> parallelAxes = new List<ParallelAxis>();
|
||||
}
|
||||
}
|
||||
11
Runtime/Coord/Parallel/ParallelCoordContext.cs.meta
Normal file
11
Runtime/Coord/Parallel/ParallelCoordContext.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 14f338556609b48568d2504a1b153be7
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
177
Runtime/Coord/Parallel/ParallelCoordHandler.cs
Normal file
177
Runtime/Coord/Parallel/ParallelCoordHandler.cs
Normal file
@@ -0,0 +1,177 @@
|
||||
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
using XUGL;
|
||||
|
||||
namespace XCharts
|
||||
{
|
||||
[UnityEngine.Scripting.Preserve]
|
||||
internal sealed class ParallelCoordHandler : MainComponentHandler<ParallelCoord>
|
||||
{
|
||||
private Dictionary<int, double> m_SerieDimMin = new Dictionary<int, double>();
|
||||
private Dictionary<int, double> m_SerieDimMax = new Dictionary<int, double>();
|
||||
private float m_LastInterval;
|
||||
private int m_LastSplitNumber;
|
||||
|
||||
public override void InitComponent()
|
||||
{
|
||||
var grid = component;
|
||||
grid.painter = chart.painter;
|
||||
grid.refreshComponent = delegate ()
|
||||
{
|
||||
grid.UpdateRuntimeData(chart.chartX, chart.chartY, chart.chartWidth, chart.chartHeight);
|
||||
chart.OnCoordinateChanged();
|
||||
};
|
||||
grid.refreshComponent();
|
||||
}
|
||||
|
||||
public override void CheckComponent(StringBuilder sb)
|
||||
{
|
||||
var grid = component;
|
||||
if (grid.left >= chart.chartWidth)
|
||||
sb.Append("warning:grid->left > chartWidth\n");
|
||||
if (grid.right >= chart.chartWidth)
|
||||
sb.Append("warning:grid->right > chartWidth\n");
|
||||
if (grid.top >= chart.chartHeight)
|
||||
sb.Append("warning:grid->top > chartHeight\n");
|
||||
if (grid.bottom >= chart.chartHeight)
|
||||
sb.Append("warning:grid->bottom > chartHeight\n");
|
||||
if (grid.left + grid.right >= chart.chartWidth)
|
||||
sb.Append("warning:grid.left + grid.right > chartWidth\n");
|
||||
if (grid.top + grid.bottom >= chart.chartHeight)
|
||||
sb.Append("warning:grid.top + grid.bottom > chartHeight\n");
|
||||
}
|
||||
|
||||
public override void Update()
|
||||
{
|
||||
UpdatePointerEnter();
|
||||
UpdateParallelAxisMinMaxValue();
|
||||
}
|
||||
|
||||
public override void DrawBase(VertexHelper vh)
|
||||
{
|
||||
if (!SeriesHelper.IsAnyClipSerie(chart.series))
|
||||
{
|
||||
DrawCoord(vh);
|
||||
}
|
||||
}
|
||||
public override void DrawTop(VertexHelper vh)
|
||||
{
|
||||
if (SeriesHelper.IsAnyClipSerie(chart.series))
|
||||
{
|
||||
DrawCoord(vh);
|
||||
}
|
||||
}
|
||||
|
||||
private void DrawCoord(VertexHelper vh)
|
||||
{
|
||||
var grid = component;
|
||||
if (grid.show && !ChartHelper.IsClearColor(grid.backgroundColor))
|
||||
{
|
||||
var p1 = new Vector2(grid.context.x, grid.context.y);
|
||||
var p2 = new Vector2(grid.context.x, grid.context.y + grid.context.height);
|
||||
var p3 = new Vector2(grid.context.x + grid.context.width, grid.context.y + grid.context.height);
|
||||
var p4 = new Vector2(grid.context.x + grid.context.width, grid.context.y);
|
||||
UGL.DrawQuadrilateral(vh, p1, p2, p3, p4, grid.backgroundColor);
|
||||
}
|
||||
}
|
||||
|
||||
private void UpdatePointerEnter()
|
||||
{
|
||||
if (chart.isPointerInChart)
|
||||
component.context.runtimeIsPointerEnter = component.Contains(chart.pointerPos);
|
||||
else
|
||||
component.context.runtimeIsPointerEnter = false;
|
||||
}
|
||||
|
||||
private void UpdateParallelAxisMinMaxValue()
|
||||
{
|
||||
var list = chart.GetChartComponents<ParallelAxis>();
|
||||
if (list.Count != component.context.parallelAxes.Count)
|
||||
{
|
||||
component.context.parallelAxes.Clear();
|
||||
foreach (var com in chart.GetChartComponents<ParallelAxis>())
|
||||
{
|
||||
var axis = com as ParallelAxis;
|
||||
if (axis.parallelIndex == component.index)
|
||||
component.context.parallelAxes.Add(axis);
|
||||
}
|
||||
}
|
||||
m_SerieDimMin.Clear();
|
||||
m_SerieDimMax.Clear();
|
||||
foreach (var serie in chart.series)
|
||||
{
|
||||
if ((serie is Parallel) && serie.parallelIndex == component.index)
|
||||
{
|
||||
foreach (var serieData in serie.data)
|
||||
{
|
||||
for (int i = 0; i < serieData.data.Count; i++)
|
||||
{
|
||||
var value = serieData.data[i];
|
||||
if (!m_SerieDimMin.ContainsKey(i))
|
||||
m_SerieDimMin[i] = value;
|
||||
else if (m_SerieDimMin[i] > value)
|
||||
m_SerieDimMin[i] = value;
|
||||
|
||||
if (!m_SerieDimMax.ContainsKey(i))
|
||||
m_SerieDimMax[i] = value;
|
||||
else if (m_SerieDimMax[i] < value)
|
||||
m_SerieDimMax[i] = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
for (int i = 0; i < component.context.parallelAxes.Count; i++)
|
||||
{
|
||||
var axis = component.context.parallelAxes[i];
|
||||
if (axis.IsCategory())
|
||||
{
|
||||
m_SerieDimMax[i] = axis.data.Count > 0 ? axis.data.Count - 1 : 0;
|
||||
m_SerieDimMin[i] = 0;
|
||||
}
|
||||
else if (axis.minMaxType == Axis.AxisMinMaxType.Custom)
|
||||
{
|
||||
m_SerieDimMin[i] = axis.min;
|
||||
m_SerieDimMax[i] = axis.max;
|
||||
}
|
||||
else if (m_SerieDimMax.ContainsKey(i))
|
||||
{
|
||||
|
||||
var tempMinValue = m_SerieDimMin[i];
|
||||
var tempMaxValue = m_SerieDimMax[i];
|
||||
AxisHelper.AdjustMinMaxValue(axis, ref tempMinValue, ref tempMaxValue, true);
|
||||
m_SerieDimMin[i] = tempMinValue;
|
||||
m_SerieDimMax[i] = tempMaxValue;
|
||||
}
|
||||
}
|
||||
for (int i = 0; i < component.context.parallelAxes.Count; i++)
|
||||
{
|
||||
if (m_SerieDimMax.ContainsKey(i))
|
||||
{
|
||||
var axis = component.context.parallelAxes[i];
|
||||
var tempMinValue = m_SerieDimMin[i];
|
||||
var tempMaxValue = m_SerieDimMax[i];
|
||||
|
||||
if (tempMinValue != axis.context.minValue
|
||||
|| tempMaxValue != axis.context.maxValue
|
||||
|| m_LastInterval != axis.interval
|
||||
|| m_LastSplitNumber != axis.splitNumber)
|
||||
{
|
||||
m_LastSplitNumber = axis.splitNumber;
|
||||
m_LastInterval = axis.interval;
|
||||
|
||||
axis.UpdateMinMaxValue(tempMinValue, tempMaxValue);
|
||||
axis.context.offset = 0;
|
||||
axis.context.lastCheckInverse = axis.inverse;
|
||||
|
||||
AxisHandler<ParallelAxis>.UpdateAxisTickValueList(axis);
|
||||
(axis.handler as ParallelAxisHander).UpdateAxisLabelText(axis);
|
||||
chart.RefreshChart();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
11
Runtime/Coord/Parallel/ParallelCoordHandler.cs.meta
Normal file
11
Runtime/Coord/Parallel/ParallelCoordHandler.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: eb7323519e00e4916a9c42c5faa36a38
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
8
Runtime/Coord/Polar.meta
Normal file
8
Runtime/Coord/Polar.meta
Normal file
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 43b3734481ac34ff89708f2edfa473ca
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
67
Runtime/Coord/Polar/PolarCoord.cs
Normal file
67
Runtime/Coord/Polar/PolarCoord.cs
Normal 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(); }
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
11
Runtime/Coord/Polar/PolarCoord.cs.meta
Normal file
11
Runtime/Coord/Polar/PolarCoord.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ec567fac460994411a8aadcb5e0f9b68
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
20
Runtime/Coord/Polar/PolarCoordContext.cs
Normal file
20
Runtime/Coord/Polar/PolarCoordContext.cs
Normal 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; }
|
||||
}
|
||||
}
|
||||
11
Runtime/Coord/Polar/PolarCoordContext.cs.meta
Normal file
11
Runtime/Coord/Polar/PolarCoordContext.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 2eaaaa315fbae4fc3a9976f51a1396b3
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
32
Runtime/Coord/Polar/PolarCoordHandler.cs
Normal file
32
Runtime/Coord/Polar/PolarCoordHandler.cs
Normal 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
11
Runtime/Coord/Polar/PolarCoordHandler.cs.meta
Normal file
11
Runtime/Coord/Polar/PolarCoordHandler.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: af4b941946def4928b416260dec7ac9b
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
28
Runtime/Coord/Polar/PolarHelper.cs
Normal file
28
Runtime/Coord/Polar/PolarHelper.cs
Normal 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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
11
Runtime/Coord/Polar/PolarHelper.cs.meta
Normal file
11
Runtime/Coord/Polar/PolarHelper.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: feb363cc2ae0846b89612143ce4535ae
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
8
Runtime/Coord/SingleAxis.meta
Normal file
8
Runtime/Coord/SingleAxis.meta
Normal file
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 102d61482a6f946cc82f228c88369dfd
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
11
Runtime/Coord/SingleAxis/SingleAxisCoord.cs
Normal file
11
Runtime/Coord/SingleAxis/SingleAxisCoord.cs
Normal file
@@ -0,0 +1,11 @@
|
||||
|
||||
using System;
|
||||
|
||||
namespace XCharts
|
||||
{
|
||||
[Serializable]
|
||||
[ComponentHandler(null)]
|
||||
public class SingleAxisCoord : CoordSystem
|
||||
{
|
||||
}
|
||||
}
|
||||
11
Runtime/Coord/SingleAxis/SingleAxisCoord.cs.meta
Normal file
11
Runtime/Coord/SingleAxis/SingleAxisCoord.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e3e972d6eb5bc45e1ba7b2c5740474fb
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user