mirror of
https://github.com/XCharts-Team/XCharts.git
synced 2026-05-23 09:20:08 +00:00
增加GridCoord3D3D坐标系
This commit is contained in:
@@ -75,7 +75,8 @@ namespace XCharts.Runtime
|
||||
Left,
|
||||
Right,
|
||||
Bottom,
|
||||
Top
|
||||
Top,
|
||||
Center
|
||||
}
|
||||
|
||||
[SerializeField] protected bool m_Show = true;
|
||||
@@ -729,10 +730,14 @@ namespace XCharts.Runtime
|
||||
/// <param name="value"></param>
|
||||
/// <param name="axisLength"></param>
|
||||
/// <returns></returns>
|
||||
public float GetDistance(double value, float axisLength)
|
||||
public float GetDistance(double value, float axisLength = 0)
|
||||
{
|
||||
if (context.minMaxRange == 0)
|
||||
return 0;
|
||||
if (axisLength == 0)
|
||||
{
|
||||
axisLength = context.length;
|
||||
}
|
||||
|
||||
if (IsCategory() && boundaryGap)
|
||||
{
|
||||
|
||||
160
Runtime/Component/Axis/Axis3DHelper.cs
Normal file
160
Runtime/Component/Axis/Axis3DHelper.cs
Normal file
@@ -0,0 +1,160 @@
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
using XUGL;
|
||||
|
||||
namespace XCharts.Runtime
|
||||
{
|
||||
public static class Axis3DHelper
|
||||
{
|
||||
public static Vector3 Get3DGridPosition(GridCoord3D grid, XAxis3D xAxis, YAxis3D yAxis, ZAxis3D zAxis, double xValue, double yValue, double zValue)
|
||||
{
|
||||
var x = xAxis.GetDistance(xValue);
|
||||
var y = yAxis.GetDistance(yValue);
|
||||
var z = zAxis.GetDistance(zValue);
|
||||
|
||||
var dest = grid.context.pointA;
|
||||
dest += xAxis.context.dire * x;
|
||||
dest += yAxis.context.dire * y;
|
||||
dest += zAxis.context.dire * z;
|
||||
return dest;
|
||||
}
|
||||
|
||||
public static Vector3 Get3DGridPosition(GridCoord3D grid, XAxis3D xAxis, YAxis3D yAxis, double xValue, double yValue)
|
||||
{
|
||||
var x = xAxis.GetDistance(xValue);
|
||||
var y = yAxis.GetDistance(yValue);
|
||||
|
||||
var dest = grid.context.pointA;
|
||||
dest += xAxis.context.dire * x;
|
||||
dest += yAxis.context.dire * y;
|
||||
return dest;
|
||||
}
|
||||
|
||||
internal static void DrawAxisTick(VertexHelper vh, Axis axis, AxisTheme theme, DataZoom dataZoom,
|
||||
Vector3 start, Vector3 end, Vector3 relativedDire)
|
||||
{
|
||||
var tickLength = axis.axisTick.GetLength(theme.tickLength);
|
||||
var axisLength = Vector3.Distance(start, end);
|
||||
var axisDire = (end - start).normalized;
|
||||
|
||||
if (axis.position == Axis.AxisPosition.Right)
|
||||
{
|
||||
relativedDire = -relativedDire;
|
||||
}
|
||||
|
||||
if (AxisHelper.NeedShowSplit(axis))
|
||||
{
|
||||
var size = AxisHelper.GetScaleNumber(axis, axisLength, dataZoom);
|
||||
if (axis.IsTime())
|
||||
{
|
||||
size += 1;
|
||||
if (!ChartHelper.IsEquals(axis.GetLastLabelValue(), axis.context.maxValue))
|
||||
size += 1;
|
||||
}
|
||||
var tickWidth = axis.axisTick.GetWidth(theme.tickWidth);
|
||||
var tickColor = axis.axisTick.GetColor(theme.tickColor);
|
||||
var current = start;
|
||||
for (int i = 0; i < size; i++)
|
||||
{
|
||||
var scaleWidth = AxisHelper.GetScaleWidth(axis, axisLength, i + 1, dataZoom);
|
||||
var hideTick = (i == 0 && (!axis.axisTick.showStartTick || axis.axisTick.alignWithLabel)) ||
|
||||
(i == size - 1 && !axis.axisTick.showEndTick);
|
||||
if (axis.axisTick.show && !hideTick)
|
||||
{
|
||||
UGL.DrawLine(vh, current, current + relativedDire * tickLength, tickWidth, tickColor);
|
||||
}
|
||||
current += axisDire * scaleWidth;
|
||||
}
|
||||
}
|
||||
if (axis.show && axis.axisLine.show && axis.axisLine.showArrow)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public static void DrawAxisSplit(VertexHelper vh, Axis axis, AxisTheme theme, DataZoom dataZoom,
|
||||
Vector3 start, Vector3 end, Axis relativedAxis)
|
||||
{
|
||||
if (relativedAxis == null) return;
|
||||
var axisLength = Vector3.Distance(start, end);
|
||||
var axisDire = (end - start).normalized;
|
||||
var splitLength = relativedAxis.context.length;
|
||||
var relativeDire = relativedAxis.context.dire;
|
||||
var axisLineWidth = axis.axisLine.GetWidth(theme.lineWidth);
|
||||
splitLength -= axisLineWidth;
|
||||
var lineColor = axis.splitLine.GetColor(theme.splitLineColor);
|
||||
var lineWidth = axis.splitLine.GetWidth(theme.lineWidth);
|
||||
var lineType = axis.splitLine.GetType(theme.splitLineType);
|
||||
|
||||
var size = AxisHelper.GetScaleNumber(axis, axisLength, dataZoom);
|
||||
if (axis.IsTime())
|
||||
{
|
||||
size += 1;
|
||||
if (!ChartHelper.IsEquals(axis.GetLastLabelValue(), axis.context.maxValue))
|
||||
size += 1;
|
||||
}
|
||||
|
||||
var current = start;
|
||||
for (int i = 0; i < size; i++)
|
||||
{
|
||||
var scaleWidth = AxisHelper.GetScaleWidth(axis, axisLength, axis.IsTime() ? i : i + 1, dataZoom);
|
||||
if (axis.boundaryGap && axis.axisTick.alignWithLabel)
|
||||
current -= axisDire * scaleWidth / 2;
|
||||
|
||||
if (axis.splitArea.show && i <= size - 1)
|
||||
{
|
||||
var p1 = current;
|
||||
var p2 = current + relativeDire * splitLength;
|
||||
var p3 = p2 + axisDire * scaleWidth;
|
||||
var p4 = p1 + axisDire * scaleWidth;
|
||||
UGL.DrawQuadrilateral(vh, p1, p2, p3, p4, axis.splitArea.GetColor(i, theme));
|
||||
}
|
||||
if (axis.splitLine.show)
|
||||
{
|
||||
if (axis.splitLine.NeedShow(i, size))
|
||||
{
|
||||
if (relativedAxis == null || !relativedAxis.axisLine.show
|
||||
|| (Vector3.Distance(current, relativedAxis.context.start) > 0.5f && Vector3.Distance(current, relativedAxis.context.end) > 0.5f))
|
||||
{
|
||||
ChartDrawer.DrawLineStyle(vh,
|
||||
lineType,
|
||||
lineWidth,
|
||||
current,
|
||||
current + relativeDire * splitLength,
|
||||
lineColor);
|
||||
}
|
||||
}
|
||||
}
|
||||
current += axisDire * scaleWidth;
|
||||
}
|
||||
}
|
||||
|
||||
public static Vector3 GetLabelPosition(int i, Axis axis, Axis relativedAxis, AxisTheme theme, float scaleWid)
|
||||
{
|
||||
var axisStart = axis.context.start;
|
||||
var axisEnd = axis.context.end;
|
||||
var axisDire = axis.context.dire;
|
||||
var relativedDire = relativedAxis != null ? relativedAxis.context.dire : Vector3.zero;
|
||||
var axisLength = Vector3.Distance(axisStart, axisEnd);
|
||||
var inside = axis.axisLabel.inside;
|
||||
var fontSize = axis.axisLabel.textStyle.GetFontSize(theme);
|
||||
var current = axis.offset;
|
||||
|
||||
if (axis.position == Axis.AxisPosition.Right)
|
||||
{
|
||||
relativedDire = -relativedDire;
|
||||
}
|
||||
|
||||
if (axis.IsTime() || axis.IsValue())
|
||||
{
|
||||
scaleWid = axis.context.minMaxRange != 0 ?
|
||||
axis.GetDistance(axis.GetLabelValue(i), axisLength) :
|
||||
0;
|
||||
}
|
||||
|
||||
return axisStart + axisDire * scaleWid + axis.axisLabel.offset - relativedDire * (axis.axisLabel.distance + fontSize / 2);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
11
Runtime/Component/Axis/Axis3DHelper.cs.meta
Normal file
11
Runtime/Component/Axis/Axis3DHelper.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 52469636872044a81a291bb00b71a140
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -15,6 +15,9 @@ namespace XCharts.Runtime
|
||||
/// 坐标轴的起点Y
|
||||
/// </summary>
|
||||
public float y;
|
||||
public Vector3 start;
|
||||
public Vector3 end;
|
||||
public Vector3 dire;
|
||||
/// <summary>
|
||||
/// 坐标轴原点X
|
||||
/// </summary>
|
||||
@@ -25,6 +28,7 @@ namespace XCharts.Runtime
|
||||
public float zeroY;
|
||||
public float width;
|
||||
public float height;
|
||||
public float length;
|
||||
public Vector3 position;
|
||||
public float left;
|
||||
public float right;
|
||||
|
||||
@@ -369,6 +369,116 @@ namespace XCharts
|
||||
}
|
||||
}
|
||||
|
||||
protected void InitAxis3D(Axis relativedAxis, Orient orient)
|
||||
{
|
||||
Axis axis = component;
|
||||
var axisLength = (axis.context.end - axis.context.start).magnitude;
|
||||
chart.InitAxisRuntimeData(axis);
|
||||
|
||||
var objName = ChartCached.GetComponentObjectName(axis);
|
||||
var axisObj = ChartHelper.AddObject(objName,
|
||||
chart.transform,
|
||||
chart.chartMinAnchor,
|
||||
chart.chartMaxAnchor,
|
||||
chart.chartPivot,
|
||||
chart.chartSizeDelta);
|
||||
|
||||
axisObj.SetActive(axis.show);
|
||||
axisObj.hideFlags = chart.chartHideFlags;
|
||||
ChartHelper.HideAllObject(axisObj);
|
||||
|
||||
axis.gameObject = axisObj;
|
||||
axis.context.labelObjectList.Clear();
|
||||
|
||||
if (!axis.show)
|
||||
return;
|
||||
|
||||
var axisLabelTextStyle = axis.axisLabel.textStyle;
|
||||
var dataZoom = chart.GetDataZoomOfAxis(axis);
|
||||
var splitNumber = AxisHelper.GetScaleNumber(axis, axisLength, dataZoom);
|
||||
var totalWidth = 0f;
|
||||
var eachWidth = AxisHelper.GetEachWidth(axis, axisLength, dataZoom);
|
||||
var gapWidth = axis.boundaryGap ? eachWidth / 2 : 0;
|
||||
|
||||
var textWidth = axis.axisLabel.width > 0 ?
|
||||
axis.axisLabel.width :
|
||||
AxisHelper.GetScaleWidth(axis, axisLength, 0, dataZoom);
|
||||
|
||||
var textHeight = axis.axisLabel.height > 0 ?
|
||||
axis.axisLabel.height :
|
||||
20f;
|
||||
|
||||
var isPercentStack = SeriesHelper.IsPercentStack<Bar>(chart.series);
|
||||
var inside = axis.axisLabel.inside;
|
||||
var defaultAlignment = orient == Orient.Horizonal ? TextAnchor.MiddleCenter :
|
||||
((inside && axis.IsLeft()) || (!inside && axis.IsRight()) ?
|
||||
TextAnchor.MiddleLeft :
|
||||
TextAnchor.MiddleRight);
|
||||
if (axis.IsCategory() && axis.boundaryGap)
|
||||
splitNumber -= 1;
|
||||
axis.context.aligment = defaultAlignment;
|
||||
for (int i = 0; i < splitNumber; i++)
|
||||
{
|
||||
var labelWidth = AxisHelper.GetScaleWidth(axis, axisLength, i + 1, dataZoom);
|
||||
var labelName = AxisHelper.GetLabelName(axis, axisLength, i,
|
||||
axis.context.destMinValue,
|
||||
axis.context.destMaxValue,
|
||||
dataZoom, isPercentStack);
|
||||
|
||||
var label = ChartHelper.AddAxisLabelObject(splitNumber, i,
|
||||
ChartCached.GetAxisLabelName(i),
|
||||
axisObj.transform,
|
||||
new Vector2(textWidth, textHeight),
|
||||
axis, chart.theme.axis, labelName,
|
||||
Color.clear,
|
||||
defaultAlignment,
|
||||
chart.theme.GetColor(i));
|
||||
|
||||
if (i == 0)
|
||||
axis.axisLabel.SetRelatedText(label.text, labelWidth);
|
||||
|
||||
var pos = GetLabelPosition(totalWidth + gapWidth, i);
|
||||
label.SetPosition(pos);
|
||||
//CheckValueLabelActive(axis, i, label, pos);
|
||||
|
||||
axis.context.labelObjectList.Add(label);
|
||||
|
||||
totalWidth += labelWidth;
|
||||
}
|
||||
if (axis.axisName.show)
|
||||
{
|
||||
ChartLabel label = null;
|
||||
var offset = axis.axisName.labelStyle.offset;
|
||||
var autoColor = axis.axisLine.GetColor(chart.theme.axis.lineColor);
|
||||
switch (axis.axisName.labelStyle.position)
|
||||
{
|
||||
case LabelStyle.Position.Start:
|
||||
|
||||
label = ChartHelper.AddChartLabel(s_DefaultAxisName, axisObj.transform, axis.axisName.labelStyle,
|
||||
chart.theme.axis, axis.axisName.name, autoColor, TextAnchor.MiddleCenter);
|
||||
label.SetActive(axis.axisName.labelStyle.show);
|
||||
label.SetPosition(axis.context.start + offset);
|
||||
break;
|
||||
|
||||
case LabelStyle.Position.Middle:
|
||||
|
||||
label = ChartHelper.AddChartLabel(s_DefaultAxisName, axisObj.transform, axis.axisName.labelStyle,
|
||||
chart.theme.axis, axis.axisName.name, autoColor, TextAnchor.MiddleCenter);
|
||||
label.SetActive(axis.axisName.labelStyle.show);
|
||||
label.SetPosition((axis.context.start + axis.context.end) / 2 + offset);
|
||||
break;
|
||||
|
||||
default:
|
||||
|
||||
label = ChartHelper.AddChartLabel(s_DefaultAxisName, axisObj.transform, axis.axisName.labelStyle,
|
||||
chart.theme.axis, axis.axisName.name, autoColor, TextAnchor.MiddleCenter);
|
||||
label.SetActive(axis.axisName.labelStyle.show);
|
||||
label.SetPosition(axis.context.end + offset);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected void InitAxis(Axis relativedAxis, Orient orient,
|
||||
float axisStartX, float axisStartY, float axisLength, float relativedLength)
|
||||
{
|
||||
|
||||
@@ -15,6 +15,7 @@ namespace XCharts.Runtime
|
||||
[SerializeField] private bool m_AutoColor;
|
||||
[SerializeField][Since("v3.3.0")] private bool m_ShowStartLine = true;
|
||||
[SerializeField][Since("v3.3.0")] private bool m_ShowEndLine = true;
|
||||
[SerializeField][Since("v3.11.0")] private bool m_ShowZLine = true;
|
||||
|
||||
/// <summary>
|
||||
/// The distance between the split line and axis line.
|
||||
@@ -53,6 +54,15 @@ namespace XCharts.Runtime
|
||||
get { return m_ShowEndLine; }
|
||||
set { if (PropertyUtil.SetStruct(ref m_ShowEndLine, value)) SetVerticesDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// Whether to show the Z axis part of the split line. Generally used for 3D coordinate systems.
|
||||
/// ||是否显示Z轴部分分割线。一般用于3D坐标系。
|
||||
/// </summary>
|
||||
public bool showZLine
|
||||
{
|
||||
get { return m_ShowZLine; }
|
||||
set { if (PropertyUtil.SetStruct(ref m_ShowZLine, value)) SetVerticesDirty(); }
|
||||
}
|
||||
|
||||
public override bool vertsDirty { get { return m_VertsDirty || m_LineStyle.anyDirty; } }
|
||||
public override void ClearVerticesDirty()
|
||||
|
||||
@@ -45,6 +45,7 @@ namespace XCharts.Runtime
|
||||
axis.context.x = parallel.context.x;
|
||||
axis.context.y = parallel.context.y + (axis.index) * each;
|
||||
axis.context.width = parallel.context.width;
|
||||
axis.context.length = parallel.context.width;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -52,6 +53,7 @@ namespace XCharts.Runtime
|
||||
axis.context.x = parallel.context.x + (axis.index) * each;
|
||||
axis.context.y = parallel.context.y;
|
||||
axis.context.width = parallel.context.height;
|
||||
axis.context.length = parallel.context.height;
|
||||
}
|
||||
axis.context.orient = m_Orient;
|
||||
axis.context.height = 0;
|
||||
|
||||
@@ -123,6 +123,12 @@ namespace XCharts.Runtime
|
||||
else
|
||||
context.y = chartY + context.bottom;
|
||||
|
||||
context.start = new Vector3(context.x, context.y);
|
||||
if (m_Orient == Orient.Horizonal)
|
||||
context.end = new Vector3(context.x + context.width, context.y);
|
||||
else
|
||||
context.end = new Vector3(context.x, context.y + context.height);
|
||||
context.length = (context.end - context.start).magnitude;
|
||||
context.position = new Vector3(context.x, context.y);
|
||||
}
|
||||
|
||||
|
||||
@@ -57,6 +57,11 @@ namespace XCharts.Runtime
|
||||
var relativedAxis = chart.GetChartComponent<YAxis>(axis.gridIndex);
|
||||
axis.context.x = grid.context.x;
|
||||
axis.context.y = AxisHelper.GetXAxisXOrY(grid, axis, relativedAxis);
|
||||
axis.context.start = new Vector3(grid.context.x, axis.context.y);
|
||||
axis.context.end = new Vector3(grid.context.x + grid.context.width, axis.context.y);
|
||||
var vec = axis.context.end - axis.context.start;
|
||||
axis.context.dire = vec.normalized;
|
||||
axis.context.length = vec.magnitude;
|
||||
axis.context.zeroY = grid.context.y;
|
||||
axis.context.zeroX = grid.context.x + axis.context.offset;
|
||||
}
|
||||
|
||||
8
Runtime/Component/Axis/XAxis3D.meta
Normal file
8
Runtime/Component/Axis/XAxis3D.meta
Normal file
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 6350e9983955e49c5b48704d3866cbfe
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
36
Runtime/Component/Axis/XAxis3D/XAxis3D.cs
Normal file
36
Runtime/Component/Axis/XAxis3D/XAxis3D.cs
Normal file
@@ -0,0 +1,36 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
namespace XCharts.Runtime
|
||||
{
|
||||
/// <summary>
|
||||
/// The x axis in cartesian(rectangular) coordinate.
|
||||
/// ||直角坐标系 grid 中的 x 轴。
|
||||
/// </summary>
|
||||
[Since("v3.11.0")]
|
||||
[System.Serializable]
|
||||
[RequireChartComponent(typeof(GridCoord3D))]
|
||||
[ComponentHandler(typeof(XAxis3DHander), true)]
|
||||
public class XAxis3D : Axis
|
||||
{
|
||||
public override void SetDefaultValue()
|
||||
{
|
||||
m_Show = true;
|
||||
m_Type = AxisType.Category;
|
||||
m_Min = 0;
|
||||
m_Max = 0;
|
||||
m_SplitNumber = 0;
|
||||
m_BoundaryGap = true;
|
||||
m_Position = AxisPosition.Bottom;
|
||||
m_Offset = 0;
|
||||
m_Data = new List<string>() { "x1", "x2", "x3", "x4", "x5" };
|
||||
m_Icons = new List<Sprite>(5);
|
||||
splitLine.show = false;
|
||||
splitLine.lineStyle.type = LineStyle.Type.None;
|
||||
axisLabel.textLimit.enable = true;
|
||||
axisName.name = "X";
|
||||
axisName.labelStyle.position = LabelStyle.Position.Middle;
|
||||
}
|
||||
}
|
||||
}
|
||||
11
Runtime/Component/Axis/XAxis3D/XAxis3D.cs.meta
Normal file
11
Runtime/Component/Axis/XAxis3D/XAxis3D.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 9129bca9c2a864e1ea337d7eb74d1024
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
190
Runtime/Component/Axis/XAxis3D/XAxis3DHander.cs
Normal file
190
Runtime/Component/Axis/XAxis3D/XAxis3DHander.cs
Normal file
@@ -0,0 +1,190 @@
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
using UnityEngine.EventSystems;
|
||||
|
||||
namespace XCharts.Runtime
|
||||
{
|
||||
[UnityEngine.Scripting.Preserve]
|
||||
internal sealed class XAxis3DHander : AxisHandler<XAxis3D>
|
||||
{
|
||||
protected override Orient orient { get { return Orient.Horizonal; } }
|
||||
|
||||
public override void InitComponent()
|
||||
{
|
||||
InitXAxis(component);
|
||||
}
|
||||
|
||||
public override void Update()
|
||||
{
|
||||
UpdateAxisMinMaxValue(component.index, component);
|
||||
if (!chart.isTriggerOnClick)
|
||||
{
|
||||
UpdatePointerValue(component);
|
||||
}
|
||||
}
|
||||
|
||||
public override void OnPointerClick(PointerEventData eventData)
|
||||
{
|
||||
base.OnPointerClick(eventData);
|
||||
if (chart.isTriggerOnClick)
|
||||
{
|
||||
UpdatePointerValue(component);
|
||||
}
|
||||
}
|
||||
|
||||
public override void OnPointerExit(PointerEventData eventData)
|
||||
{
|
||||
base.OnPointerExit(eventData);
|
||||
if (chart.isTriggerOnClick)
|
||||
{
|
||||
component.context.pointerValue = double.PositiveInfinity;
|
||||
}
|
||||
}
|
||||
|
||||
public override void DrawBase(VertexHelper vh)
|
||||
{
|
||||
UpdatePosition(component);
|
||||
DrawXAxisSplit(vh, component);
|
||||
DrawXAxisLine(vh, component);
|
||||
DrawXAxisTick(vh, component);
|
||||
}
|
||||
|
||||
private void UpdatePosition(XAxis3D axis)
|
||||
{
|
||||
var grid = chart.GetChartComponent<GridCoord3D>(axis.gridIndex);
|
||||
if (grid != null)
|
||||
{
|
||||
if (axis.position == Axis.AxisPosition.Right || axis.position == Axis.AxisPosition.Top)
|
||||
{
|
||||
axis.context.start = grid.xyExchanged ? grid.context.pointD : grid.context.pointB;
|
||||
axis.context.end = grid.context.pointC;
|
||||
}
|
||||
else
|
||||
{
|
||||
axis.context.start = grid.context.pointA;
|
||||
axis.context.end = grid.xyExchanged ? grid.context.pointB : grid.context.pointD;
|
||||
}
|
||||
var vect = axis.context.end - axis.context.start;
|
||||
axis.context.x = axis.context.start.x;
|
||||
axis.context.y = axis.context.start.y;
|
||||
axis.context.dire = vect.normalized;
|
||||
axis.context.length = vect.magnitude;
|
||||
}
|
||||
}
|
||||
|
||||
private void InitXAxis(XAxis3D xAxis)
|
||||
{
|
||||
var theme = chart.theme;
|
||||
var xAxisIndex = xAxis.index;
|
||||
xAxis.painter = chart.painter;
|
||||
xAxis.refreshComponent = delegate ()
|
||||
{
|
||||
var yAxis = chart.GetChartComponent<YAxis3D>(xAxis.index);
|
||||
InitAxis3D(yAxis, orient);
|
||||
};
|
||||
xAxis.refreshComponent();
|
||||
}
|
||||
|
||||
internal override void UpdateAxisLabelText(Axis axis)
|
||||
{
|
||||
base.UpdateAxisLabelText(axis);
|
||||
if (axis.IsTime() || axis.IsValue())
|
||||
{
|
||||
for (int i = 0; i < axis.context.labelObjectList.Count; i++)
|
||||
{
|
||||
var label = axis.context.labelObjectList[i];
|
||||
if (label != null)
|
||||
{
|
||||
var pos = GetLabelPosition(0, i);
|
||||
label.SetPosition(pos);
|
||||
CheckValueLabelActive(component, i, label, pos);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected override Vector3 GetLabelPosition(float scaleWid, int i)
|
||||
{
|
||||
var yAxis = chart.GetChartComponent<YAxis3D>(component.index);
|
||||
return Axis3DHelper.GetLabelPosition(i, component, yAxis, chart.theme.axis, scaleWid);
|
||||
}
|
||||
|
||||
private void DrawXAxisSplit(VertexHelper vh, XAxis3D xAxis)
|
||||
{
|
||||
if (AxisHelper.NeedShowSplit(xAxis))
|
||||
{
|
||||
var grid = chart.GetChartComponent<GridCoord3D>(xAxis.gridIndex);
|
||||
var relativedAxis = chart.GetChartComponent<YAxis3D>(xAxis.gridIndex);
|
||||
var dataZoom = chart.GetDataZoomOfAxis(xAxis);
|
||||
var isLeft = grid.IsLeft();
|
||||
if (grid.xyExchanged)
|
||||
{
|
||||
Axis3DHelper.DrawAxisSplit(vh, xAxis, chart.theme.axis, dataZoom,
|
||||
grid.context.pointA,
|
||||
grid.context.pointB,
|
||||
relativedAxis);
|
||||
if (xAxis.splitLine.showZLine)
|
||||
{
|
||||
var relativedAxis2 = chart.GetChartComponent<ZAxis3D>(xAxis.gridIndex);
|
||||
Axis3DHelper.DrawAxisSplit(vh, xAxis, chart.theme.axis, dataZoom,
|
||||
isLeft ? grid.context.pointD : grid.context.pointA,
|
||||
isLeft ? grid.context.pointC : grid.context.pointB,
|
||||
relativedAxis2);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Axis3DHelper.DrawAxisSplit(vh, xAxis, chart.theme.axis, dataZoom,
|
||||
grid.context.pointA,
|
||||
grid.context.pointD,
|
||||
relativedAxis);
|
||||
if (xAxis.splitLine.showZLine)
|
||||
{
|
||||
var relativedAxis2 = chart.GetChartComponent<ZAxis3D>(xAxis.gridIndex);
|
||||
Axis3DHelper.DrawAxisSplit(vh, xAxis, chart.theme.axis, dataZoom,
|
||||
grid.context.pointB,
|
||||
grid.context.pointC,
|
||||
relativedAxis2);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void DrawXAxisTick(VertexHelper vh, XAxis3D xAxis)
|
||||
{
|
||||
if (AxisHelper.NeedShowSplit(xAxis))
|
||||
{
|
||||
var grid = chart.GetChartComponent<GridCoord3D>(xAxis.gridIndex);
|
||||
if (grid == null)
|
||||
return;
|
||||
|
||||
var dataZoom = chart.GetDataZoomOfAxis(xAxis);
|
||||
var relativedAxis = chart.GetChartComponent<YAxis3D>(xAxis.gridIndex);
|
||||
Axis3DHelper.DrawAxisTick(vh, xAxis, chart.theme.axis, dataZoom,
|
||||
xAxis.context.start,
|
||||
xAxis.context.end,
|
||||
-relativedAxis.context.dire);
|
||||
}
|
||||
}
|
||||
|
||||
private void DrawXAxisLine(VertexHelper vh, XAxis3D axis)
|
||||
{
|
||||
if (axis.show && axis.axisLine.show)
|
||||
{
|
||||
var theme = chart.theme.axis;
|
||||
var lineWidth = axis.axisLine.GetWidth(theme.lineWidth);
|
||||
var lineType = axis.axisLine.GetType(theme.lineType);
|
||||
var lineColor = axis.axisLine.GetColor(theme.lineColor);
|
||||
|
||||
var start = axis.context.start;
|
||||
var end = axis.context.end;
|
||||
ChartDrawer.DrawLineStyle(vh, lineType, lineWidth, start, end, lineColor);
|
||||
}
|
||||
}
|
||||
|
||||
internal override float GetAxisLineXOrY()
|
||||
{
|
||||
return component.context.y;
|
||||
}
|
||||
}
|
||||
}
|
||||
11
Runtime/Component/Axis/XAxis3D/XAxis3DHander.cs.meta
Normal file
11
Runtime/Component/Axis/XAxis3D/XAxis3DHander.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: fc1147481a423494d963df29b423f3a0
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -35,6 +35,11 @@ namespace XCharts.Runtime
|
||||
var relativedAxis = chart.GetChartComponent<XAxis>(axis.gridIndex);
|
||||
axis.context.x = AxisHelper.GetYAxisXOrY(grid, axis, relativedAxis);
|
||||
axis.context.y = grid.context.y;
|
||||
axis.context.start = new Vector3(axis.context.x, grid.context.y);
|
||||
axis.context.end = new Vector3(axis.context.x, grid.context.y + grid.context.height);
|
||||
var vect = axis.context.end - axis.context.start;
|
||||
axis.context.dire = vect.normalized;
|
||||
axis.context.length = vect.magnitude;
|
||||
axis.context.zeroX = axis.context.x;
|
||||
axis.context.zeroY = axis.context.y + axis.context.offset;
|
||||
}
|
||||
|
||||
8
Runtime/Component/Axis/YAxis3D.meta
Normal file
8
Runtime/Component/Axis/YAxis3D.meta
Normal file
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: aa26616789b6b4903aae479a4c552b89
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
33
Runtime/Component/Axis/YAxis3D/YAxis3D.cs
Normal file
33
Runtime/Component/Axis/YAxis3D/YAxis3D.cs
Normal file
@@ -0,0 +1,33 @@
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace XCharts.Runtime
|
||||
{
|
||||
/// <summary>
|
||||
/// The x axis in cartesian(rectangular) coordinate.
|
||||
/// ||直角坐标系 grid 中的 y 轴。
|
||||
/// </summary>
|
||||
[Since("v3.11.0")]
|
||||
[System.Serializable]
|
||||
[RequireChartComponent(typeof(GridCoord3D), typeof(XAxis3D))]
|
||||
[ComponentHandler(typeof(YAxis3DHander), true)]
|
||||
public class YAxis3D : Axis
|
||||
{
|
||||
public override void SetDefaultValue()
|
||||
{
|
||||
m_Show = true;
|
||||
m_Type = AxisType.Value;
|
||||
m_Min = 0;
|
||||
m_Max = 0;
|
||||
m_SplitNumber = 0;
|
||||
m_BoundaryGap = false;
|
||||
m_Position = AxisPosition.Left;
|
||||
m_Data = new List<string>(5);
|
||||
splitLine.show = true;
|
||||
splitLine.lineStyle.type = LineStyle.Type.None;
|
||||
axisLabel.textLimit.enable = false;
|
||||
axisTick.showStartTick = true;
|
||||
axisName.name = "Y";
|
||||
axisName.labelStyle.position = LabelStyle.Position.Middle;
|
||||
}
|
||||
}
|
||||
}
|
||||
11
Runtime/Component/Axis/YAxis3D/YAxis3D.cs.meta
Normal file
11
Runtime/Component/Axis/YAxis3D/YAxis3D.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a3cb4a6657aaf473bbae7162eb189cc0
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
176
Runtime/Component/Axis/YAxis3D/YAxis3DHander.cs
Normal file
176
Runtime/Component/Axis/YAxis3D/YAxis3DHander.cs
Normal file
@@ -0,0 +1,176 @@
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
namespace XCharts.Runtime
|
||||
{
|
||||
[UnityEngine.Scripting.Preserve]
|
||||
internal sealed class YAxis3DHander : AxisHandler<YAxis3D>
|
||||
{
|
||||
protected override Orient orient { get { return Orient.Vertical; } }
|
||||
|
||||
public override void InitComponent()
|
||||
{
|
||||
InitYAxis(component);
|
||||
}
|
||||
|
||||
public override void Update()
|
||||
{
|
||||
UpdateAxisMinMaxValue(component.index, component);
|
||||
UpdatePointerValue(component);
|
||||
}
|
||||
|
||||
public override void DrawBase(VertexHelper vh)
|
||||
{
|
||||
UpdatePosition(component);
|
||||
DrawYAxisSplit(vh, component.index, component);
|
||||
DrawYAxisLine(vh, component.index, component);
|
||||
DrawYAxisTick(vh, component.index, component);
|
||||
}
|
||||
|
||||
private void UpdatePosition(YAxis3D axis)
|
||||
{
|
||||
var grid = chart.GetChartComponent<GridCoord3D>(axis.gridIndex);
|
||||
if (grid != null)
|
||||
{
|
||||
if (axis.position == Axis.AxisPosition.Right)
|
||||
{
|
||||
axis.context.start = grid.xyExchanged ? grid.context.pointB : grid.context.pointD;
|
||||
axis.context.end = grid.context.pointC;
|
||||
}
|
||||
else
|
||||
{
|
||||
axis.context.start = grid.context.pointA;
|
||||
axis.context.end = grid.xyExchanged ? grid.context.pointD : grid.context.pointB;
|
||||
}
|
||||
axis.context.x = axis.context.start.x;
|
||||
axis.context.y = axis.context.start.y;
|
||||
var vect = axis.context.end - axis.context.start;
|
||||
axis.context.dire = vect.normalized;
|
||||
axis.context.length = vect.magnitude;
|
||||
}
|
||||
}
|
||||
|
||||
private void InitYAxis(YAxis3D yAxis)
|
||||
{
|
||||
var theme = chart.theme;
|
||||
var yAxisIndex = yAxis.index;
|
||||
yAxis.painter = chart.painter;
|
||||
yAxis.refreshComponent = delegate ()
|
||||
{
|
||||
var grid = chart.GetChartComponent<GridCoord3D>(yAxis.gridIndex);
|
||||
if (grid != null)
|
||||
{
|
||||
var xAxis = chart.GetChartComponent<YAxis3D>(yAxis.index);
|
||||
InitAxis3D(xAxis, orient);
|
||||
}
|
||||
};
|
||||
yAxis.refreshComponent();
|
||||
}
|
||||
|
||||
internal override void UpdateAxisLabelText(Axis axis)
|
||||
{
|
||||
base.UpdateAxisLabelText(axis);
|
||||
if (axis.IsTime() || axis.IsValue())
|
||||
{
|
||||
for (int i = 0; i < axis.context.labelObjectList.Count; i++)
|
||||
{
|
||||
var label = axis.context.labelObjectList[i];
|
||||
if (label != null)
|
||||
{
|
||||
var pos = GetLabelPosition(0, i);
|
||||
label.SetPosition(pos);
|
||||
CheckValueLabelActive(axis, i, label, pos);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected override Vector3 GetLabelPosition(float scaleWid, int i)
|
||||
{
|
||||
var xAxis = chart.GetChartComponent<XAxis3D>(component.index);
|
||||
return Axis3DHelper.GetLabelPosition(i, component, xAxis, chart.theme.axis, scaleWid);
|
||||
}
|
||||
|
||||
private void DrawYAxisSplit(VertexHelper vh, int yAxisIndex, YAxis3D yAxis)
|
||||
{
|
||||
if (AxisHelper.NeedShowSplit(yAxis))
|
||||
{
|
||||
var grid = chart.GetChartComponent<GridCoord3D>(yAxis.gridIndex);
|
||||
var relativedAxis = chart.GetChartComponent<XAxis3D>(yAxis.gridIndex);
|
||||
var dataZoom = chart.GetDataZoomOfAxis(yAxis);
|
||||
var isLeft = grid.IsLeft();
|
||||
if (grid.xyExchanged)
|
||||
{
|
||||
Axis3DHelper.DrawAxisSplit(vh, yAxis, chart.theme.axis, dataZoom,
|
||||
grid.context.pointA,
|
||||
grid.context.pointD,
|
||||
relativedAxis);
|
||||
if (yAxis.splitLine.showZLine)
|
||||
{
|
||||
var relativedAxis2 = chart.GetChartComponent<ZAxis3D>(yAxis.gridIndex);
|
||||
Axis3DHelper.DrawAxisSplit(vh, yAxis, chart.theme.axis, dataZoom,
|
||||
grid.context.pointB, grid.context.pointC, relativedAxis2);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Axis3DHelper.DrawAxisSplit(vh, yAxis, chart.theme.axis, dataZoom,
|
||||
grid.context.pointA,
|
||||
grid.context.pointB,
|
||||
relativedAxis);
|
||||
if (yAxis.splitLine.showZLine)
|
||||
{
|
||||
var relativedAxis2 = chart.GetChartComponent<ZAxis3D>(yAxis.gridIndex);
|
||||
Axis3DHelper.DrawAxisSplit(vh, yAxis, chart.theme.axis, dataZoom,
|
||||
isLeft ? grid.context.pointD : grid.context.pointA,
|
||||
isLeft ? grid.context.pointC : grid.context.pointB,
|
||||
relativedAxis2);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void DrawYAxisTick(VertexHelper vh, int yAxisIndex, YAxis3D yAxis)
|
||||
{
|
||||
if (AxisHelper.NeedShowSplit(yAxis))
|
||||
{
|
||||
var grid = chart.GetChartComponent<GridCoord3D>(yAxis.gridIndex);
|
||||
if (grid == null)
|
||||
return;
|
||||
|
||||
var dataZoom = chart.GetDataZoomOfAxis(yAxis);
|
||||
var relativedAxis = chart.GetChartComponent<XAxis3D>(yAxis.gridIndex);
|
||||
|
||||
Axis3DHelper.DrawAxisTick(vh, yAxis, chart.theme.axis, dataZoom,
|
||||
yAxis.context.start,
|
||||
yAxis.context.end,
|
||||
-relativedAxis.context.dire);
|
||||
}
|
||||
}
|
||||
|
||||
private void DrawYAxisLine(VertexHelper vh, int axisIndex, YAxis3D axis)
|
||||
{
|
||||
if (axis.show && axis.axisLine.show)
|
||||
{
|
||||
var grid = chart.GetChartComponent<GridCoord3D>(axis.gridIndex);
|
||||
if (grid == null)
|
||||
return;
|
||||
|
||||
var theme = chart.theme.axis;
|
||||
|
||||
var lineWidth = axis.axisLine.GetWidth(theme.lineWidth);
|
||||
var lineType = axis.axisLine.GetType(theme.lineType);
|
||||
var lineColor = axis.axisLine.GetColor(theme.lineColor);
|
||||
|
||||
var start = axis.context.start;
|
||||
var end = axis.context.end;
|
||||
ChartDrawer.DrawLineStyle(vh, lineType, lineWidth, start, end, lineColor);
|
||||
}
|
||||
}
|
||||
|
||||
internal override float GetAxisLineXOrY()
|
||||
{
|
||||
return component.context.x;
|
||||
}
|
||||
}
|
||||
}
|
||||
11
Runtime/Component/Axis/YAxis3D/YAxis3DHander.cs.meta
Normal file
11
Runtime/Component/Axis/YAxis3D/YAxis3DHander.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 56b4be734c61645e1bf91c22a6e3da6c
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
8
Runtime/Component/Axis/ZAxis3D.meta
Normal file
8
Runtime/Component/Axis/ZAxis3D.meta
Normal file
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 378448672ed084b0798c7ad343314693
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
33
Runtime/Component/Axis/ZAxis3D/ZAxis3D.cs
Normal file
33
Runtime/Component/Axis/ZAxis3D/ZAxis3D.cs
Normal file
@@ -0,0 +1,33 @@
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace XCharts.Runtime
|
||||
{
|
||||
/// <summary>
|
||||
/// The x axis in cartesian(rectangular) coordinate.
|
||||
/// ||直角坐标系 grid 中的 y 轴。
|
||||
/// </summary>
|
||||
[Since("v3.11.0")]
|
||||
[System.Serializable]
|
||||
[RequireChartComponent(typeof(GridCoord3D), typeof(XAxis3D))]
|
||||
[ComponentHandler(typeof(ZAxis3DHander), true)]
|
||||
public class ZAxis3D : Axis
|
||||
{
|
||||
public override void SetDefaultValue()
|
||||
{
|
||||
m_Show = true;
|
||||
m_Type = AxisType.Value;
|
||||
m_Min = 0;
|
||||
m_Max = 0;
|
||||
m_SplitNumber = 0;
|
||||
m_BoundaryGap = false;
|
||||
m_Position = AxisPosition.Left;
|
||||
m_Data = new List<string>(5);
|
||||
splitLine.show = true;
|
||||
splitLine.lineStyle.type = LineStyle.Type.None;
|
||||
axisLabel.textLimit.enable = false;
|
||||
axisTick.showStartTick = true;
|
||||
axisName.name = "Z";
|
||||
axisName.labelStyle.position = LabelStyle.Position.Middle;
|
||||
}
|
||||
}
|
||||
}
|
||||
11
Runtime/Component/Axis/ZAxis3D/ZAxis3D.cs.meta
Normal file
11
Runtime/Component/Axis/ZAxis3D/ZAxis3D.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 65aa8ae88610c431ebdab86935af2379
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
198
Runtime/Component/Axis/ZAxis3D/ZAxis3DHander.cs
Normal file
198
Runtime/Component/Axis/ZAxis3D/ZAxis3DHander.cs
Normal file
@@ -0,0 +1,198 @@
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
namespace XCharts.Runtime
|
||||
{
|
||||
[UnityEngine.Scripting.Preserve]
|
||||
internal sealed class ZAxis3DHander : AxisHandler<ZAxis3D>
|
||||
{
|
||||
protected override Orient orient { get { return Orient.Vertical; } }
|
||||
|
||||
public override void InitComponent()
|
||||
{
|
||||
InitYAxis(component);
|
||||
}
|
||||
|
||||
public override void Update()
|
||||
{
|
||||
UpdateAxisMinMaxValue(component.index, component);
|
||||
UpdatePointerValue(component);
|
||||
}
|
||||
|
||||
public override void DrawBase(VertexHelper vh)
|
||||
{
|
||||
UpdatePosition(component);
|
||||
DrawZAxisSplit(vh, component.index, component);
|
||||
DrawZAxisLine(vh, component.index, component);
|
||||
DrawZAxisTick(vh, component.index, component);
|
||||
}
|
||||
|
||||
private void UpdatePosition(ZAxis3D axis)
|
||||
{
|
||||
var grid = chart.GetChartComponent<GridCoord3D>(axis.gridIndex);
|
||||
if (grid != null)
|
||||
{
|
||||
if (grid.context.pointB.x < grid.context.pointA.x)
|
||||
{
|
||||
axis.context.start = grid.context.pointD;
|
||||
axis.context.end = grid.context.pointH;
|
||||
}
|
||||
else if (axis.position == Axis.AxisPosition.Center)
|
||||
{
|
||||
axis.context.start = grid.context.pointB;
|
||||
axis.context.end = grid.context.pointF;
|
||||
}
|
||||
else if (axis.position == Axis.AxisPosition.Right)
|
||||
{
|
||||
axis.context.start = grid.context.pointC;
|
||||
axis.context.end = grid.context.pointG;
|
||||
}
|
||||
else
|
||||
{
|
||||
axis.context.start = grid.context.pointA;
|
||||
axis.context.end = grid.context.pointE;
|
||||
}
|
||||
axis.context.x = axis.context.start.x;
|
||||
axis.context.y = axis.context.start.y;
|
||||
var vect = axis.context.end - axis.context.start;
|
||||
axis.context.dire = vect.normalized;
|
||||
axis.context.length = vect.magnitude;
|
||||
}
|
||||
}
|
||||
|
||||
private void InitYAxis(ZAxis3D yAxis)
|
||||
{
|
||||
var theme = chart.theme;
|
||||
var yAxisIndex = yAxis.index;
|
||||
yAxis.painter = chart.painter;
|
||||
yAxis.refreshComponent = delegate ()
|
||||
{
|
||||
var grid = chart.GetChartComponent<GridCoord3D>(yAxis.gridIndex);
|
||||
if (grid != null)
|
||||
{
|
||||
var relativedAxis = chart.GetChartComponent<ZAxis3D>(yAxis.index);
|
||||
InitAxis3D(relativedAxis, orient);
|
||||
}
|
||||
};
|
||||
yAxis.refreshComponent();
|
||||
}
|
||||
|
||||
internal override void UpdateAxisLabelText(Axis axis)
|
||||
{
|
||||
base.UpdateAxisLabelText(axis);
|
||||
if (axis.IsTime() || axis.IsValue())
|
||||
{
|
||||
for (int i = 0; i < axis.context.labelObjectList.Count; i++)
|
||||
{
|
||||
var label = axis.context.labelObjectList[i];
|
||||
if (label != null)
|
||||
{
|
||||
var pos = GetLabelPosition(0, i);
|
||||
label.SetPosition(pos);
|
||||
CheckValueLabelActive(axis, i, label, pos);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected override Vector3 GetLabelPosition(float scaleWid, int i)
|
||||
{
|
||||
var grid = chart.GetChartComponent<GridCoord3D>(component.gridIndex);
|
||||
if (grid == null)
|
||||
return Vector3.zero;
|
||||
|
||||
var yAxis = chart.GetChartComponent<XAxis3D>(component.index);
|
||||
return Axis3DHelper.GetLabelPosition(i, component, yAxis,
|
||||
chart.theme.axis,
|
||||
scaleWid);
|
||||
}
|
||||
|
||||
private void DrawZAxisSplit(VertexHelper vh, int yAxisIndex, ZAxis3D yAxis)
|
||||
{
|
||||
if (AxisHelper.NeedShowSplit(yAxis))
|
||||
{
|
||||
var grid = chart.GetChartComponent<GridCoord3D>(yAxis.gridIndex);
|
||||
if (grid == null)
|
||||
return;
|
||||
|
||||
var isLeft = grid.IsLeft();
|
||||
if (grid.xyExchanged)
|
||||
{
|
||||
var relativedAxis = chart.GetChartComponent<XAxis3D>(yAxis.gridIndex);
|
||||
var dataZoom = chart.GetDataZoomOfAxis(yAxis);
|
||||
Axis3DHelper.DrawAxisSplit(vh, yAxis, chart.theme.axis, dataZoom,
|
||||
isLeft ? grid.context.pointD : grid.context.pointA,
|
||||
isLeft ? grid.context.pointH : grid.context.pointE,
|
||||
relativedAxis);
|
||||
if (yAxis.splitLine.showZLine)
|
||||
{
|
||||
var relativedAxis2 = chart.GetChartComponent<YAxis3D>(yAxis.gridIndex);
|
||||
Axis3DHelper.DrawAxisSplit(vh, yAxis, chart.theme.axis, dataZoom,
|
||||
grid.context.pointB,
|
||||
grid.context.pointF,
|
||||
relativedAxis2);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
var relativedAxis = chart.GetChartComponent<YAxis3D>(yAxis.gridIndex);
|
||||
var dataZoom = chart.GetDataZoomOfAxis(yAxis);
|
||||
Axis3DHelper.DrawAxisSplit(vh, yAxis, chart.theme.axis, dataZoom,
|
||||
isLeft ? grid.context.pointD : grid.context.pointA,
|
||||
isLeft ? grid.context.pointH : grid.context.pointE,
|
||||
relativedAxis);
|
||||
if (yAxis.splitLine.showZLine)
|
||||
{
|
||||
var relativedAxis2 = chart.GetChartComponent<XAxis3D>(yAxis.gridIndex);
|
||||
Axis3DHelper.DrawAxisSplit(vh, yAxis, chart.theme.axis, dataZoom,
|
||||
grid.context.pointB,
|
||||
grid.context.pointF,
|
||||
relativedAxis2);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void DrawZAxisTick(VertexHelper vh, int yAxisIndex, ZAxis3D zAxis)
|
||||
{
|
||||
if (AxisHelper.NeedShowSplit(zAxis))
|
||||
{
|
||||
var grid = chart.GetChartComponent<GridCoord3D>(zAxis.gridIndex);
|
||||
if (grid == null)
|
||||
return;
|
||||
|
||||
var dataZoom = chart.GetDataZoomOfAxis(zAxis);
|
||||
var relativedDire = grid.context.pointA - grid.context.pointB;
|
||||
Axis3DHelper.DrawAxisTick(vh, zAxis, chart.theme.axis, dataZoom,
|
||||
zAxis.context.start,
|
||||
zAxis.context.end,
|
||||
relativedDire.normalized);
|
||||
}
|
||||
}
|
||||
|
||||
private void DrawZAxisLine(VertexHelper vh, int axisIndex, ZAxis3D axis)
|
||||
{
|
||||
if (axis.show && axis.axisLine.show)
|
||||
{
|
||||
var grid = chart.GetChartComponent<GridCoord3D>(axis.gridIndex);
|
||||
if (grid == null)
|
||||
return;
|
||||
|
||||
var theme = chart.theme.axis;
|
||||
|
||||
var lineWidth = axis.axisLine.GetWidth(theme.lineWidth);
|
||||
var lineType = axis.axisLine.GetType(theme.lineType);
|
||||
var lineColor = axis.axisLine.GetColor(theme.lineColor);
|
||||
|
||||
var start = axis.context.start;
|
||||
var end = axis.context.end;
|
||||
ChartDrawer.DrawLineStyle(vh, lineType, lineWidth, start, end, lineColor);
|
||||
}
|
||||
}
|
||||
|
||||
internal override float GetAxisLineXOrY()
|
||||
{
|
||||
return component.context.x;
|
||||
}
|
||||
}
|
||||
}
|
||||
11
Runtime/Component/Axis/ZAxis3D/ZAxis3DHander.cs.meta
Normal file
11
Runtime/Component/Axis/ZAxis3D/ZAxis3DHander.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 67fb4be32885d4915979719c676aac5a
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -386,8 +386,8 @@ namespace XCharts.Runtime
|
||||
}
|
||||
}
|
||||
|
||||
public float runtimeRangeMinHeight { get { return (float) ((rangeMin - min) / (max - min) * itemHeight); } }
|
||||
public float runtimeRangeMaxHeight { get { return (float) ((rangeMax - min) / (max - min) * itemHeight); } }
|
||||
public float runtimeRangeMinHeight { get { return (float)((rangeMin - min) / (max - min) * itemHeight); } }
|
||||
public float runtimeRangeMaxHeight { get { return (float)((rangeMax - min) / (max - min) * itemHeight); } }
|
||||
|
||||
public void AddColors(List<Color32> colors)
|
||||
{
|
||||
@@ -413,6 +413,25 @@ namespace XCharts.Runtime
|
||||
}
|
||||
}
|
||||
|
||||
public Color32 GetColor(double xValue, double yValue, double zValue, byte alpha = 255)
|
||||
{
|
||||
Color32 color;
|
||||
if (m_Dimension == 0)
|
||||
{
|
||||
color = GetColor(xValue);
|
||||
}
|
||||
else if (m_Dimension == 1)
|
||||
{
|
||||
color = GetColor(yValue);
|
||||
}
|
||||
else
|
||||
{
|
||||
color = GetColor(zValue);
|
||||
}
|
||||
color.a = alpha;
|
||||
return color;
|
||||
}
|
||||
|
||||
public Color32 GetColor(double value)
|
||||
{
|
||||
int index = GetIndex(value);
|
||||
@@ -437,7 +456,7 @@ namespace XCharts.Runtime
|
||||
if (index == splitNumber - 1)
|
||||
return m_InRange[index].color;
|
||||
else
|
||||
return Color32.Lerp(m_InRange[index].color, m_InRange[index + 1].color, (float) rate);
|
||||
return Color32.Lerp(m_InRange[index].color, m_InRange[index + 1].color, (float)rate);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user