diff --git a/CHANGELOG.md b/CHANGELOG.md
index f4d8d2f0..e2b7465a 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,6 +1,7 @@
# 更新日志
+* (2020.04.18) 增加`Covert XY Axis`互换XY轴配置
* (2020.04.17) 增加`Axis`可通过`inverse`参数设置坐标轴反转
* (2020.04.16) 修复`Check warning`在`Unity2019.3`上的显示问题
* (2020.04.16) 修复`PieChart`在设置`Space`参数后动画绘制异常的问题
diff --git a/Editor/BaseChartEditor.cs b/Editor/BaseChartEditor.cs
index a7219ddf..6cced927 100644
--- a/Editor/BaseChartEditor.cs
+++ b/Editor/BaseChartEditor.cs
@@ -91,13 +91,12 @@ namespace XCharts
protected virtual void OnEndInspectorGUI()
{
+ EditorGUILayout.Space();
+ EditorGUILayout.Space();
}
-
private void CheckWarning()
{
- EditorGUILayout.Space();
- EditorGUILayout.Space();
if (m_CheckWarning)
{
EditorGUILayout.BeginHorizontal();
diff --git a/Editor/CoordinateChartEditor.cs b/Editor/CoordinateChartEditor.cs
index 23e2cfed..d39944f8 100644
--- a/Editor/CoordinateChartEditor.cs
+++ b/Editor/CoordinateChartEditor.cs
@@ -6,6 +6,7 @@
/******************************************/
using UnityEditor;
+using UnityEngine;
namespace XCharts
{
@@ -52,5 +53,19 @@ namespace XCharts
EditorGUILayout.PropertyField(axis);
}
}
+
+ protected override void OnEndInspectorGUI()
+ {
+ base.OnEndInspectorGUI();
+ CovertXYAxis();
+ }
+
+ private void CovertXYAxis()
+ {
+ if (GUILayout.Button("Covert XY Axis"))
+ {
+ (m_Target as CoordinateChart).CovertXYAxis(0);
+ }
+ }
}
}
\ No newline at end of file
diff --git a/Runtime/API/CoordinateChart_API.cs b/Runtime/API/CoordinateChart_API.cs
index 62bc88b1..7ef770d6 100644
--- a/Runtime/API/CoordinateChart_API.cs
+++ b/Runtime/API/CoordinateChart_API.cs
@@ -212,6 +212,20 @@ namespace XCharts
return np;
}
}
+
+ ///
+ /// 转换X轴和Y轴的配置
+ ///
+ /// 坐标轴索引,0或1
+ public void CovertXYAxis(int index)
+ {
+ if (index >= 0 && index <= 1)
+ {
+ var tempX = m_XAxises[index].Clone();
+ m_XAxises[index].Copy(m_YAxises[index]);
+ m_YAxises[index].Copy(tempX);
+ }
+ }
}
}
diff --git a/Runtime/Component/Main/Axis.cs b/Runtime/Component/Main/Axis.cs
index b7575534..44fc1b51 100644
--- a/Runtime/Component/Main/Axis.cs
+++ b/Runtime/Component/Main/Axis.cs
@@ -358,6 +358,55 @@ namespace XCharts
private bool m_RuntimeMinValueFirstChanged = true;
private bool m_RuntimeMaxValueFirstChanged = true;
+ public Axis Clone()
+ {
+ var axis = new Axis();
+ axis.show = show;
+ axis.type = type;
+ axis.minMaxType = minMaxType;
+ axis.min = min;
+ axis.max = max;
+ axis.splitNumber = splitNumber;
+ axis.interval = interval;
+ axis.boundaryGap = boundaryGap;
+ axis.maxCache = maxCache;
+ axis.logBase = logBase;
+ axis.logBaseE = logBaseE;
+ axis.ceilRate = ceilRate;
+ axis.axisLine = axisLine.Clone();
+ axis.axisName = axisName.Clone();
+ axis.axisTick = axisTick.Clone();
+ axis.axisLabel = axisLabel.Clone();
+ axis.splitLine = splitLine.Clone();
+ axis.splitArea = splitArea.Clone();
+ axis.data = new List();
+ ChartHelper.CopyList(axis.data, data);
+ return axis;
+ }
+
+ public void Copy(Axis axis)
+ {
+ show = axis.show;
+ type = axis.type;
+ minMaxType = axis.minMaxType;
+ min = axis.min;
+ max = axis.max;
+ splitNumber = axis.splitNumber;
+ interval = axis.interval;
+ boundaryGap = axis.boundaryGap;
+ maxCache = axis.maxCache;
+ logBase = axis.logBase;
+ logBaseE = axis.logBaseE;
+ ceilRate = axis.ceilRate;
+ axisLine.Copy(axis.axisLine);
+ axisName.Copy(axis.axisName);
+ axisTick.Copy(axis.axisTick);
+ axisLabel.Copy(axis.axisLabel);
+ splitLine.Copy(axis.splitLine);
+ splitArea.Copy(axis.splitArea);
+ ChartHelper.CopyList(data, axis.data);
+ }
+
///
/// 清空类目数据
///
diff --git a/Runtime/Component/Sub/AxisLabel.cs b/Runtime/Component/Sub/AxisLabel.cs
index 17bb2260..9b3800f3 100644
--- a/Runtime/Component/Sub/AxisLabel.cs
+++ b/Runtime/Component/Sub/AxisLabel.cs
@@ -153,6 +153,36 @@ namespace XCharts
}
}
+ public AxisLabel Clone()
+ {
+ var axisLable = new AxisLabel();
+ axisLable.show = show;
+ axisLable.formatter = formatter;
+ axisLable.interval = interval;
+ axisLable.inside = inside;
+ axisLable.rotate = rotate;
+ axisLable.margin = margin;
+ axisLable.color = color;
+ axisLable.fontSize = fontSize;
+ axisLable.forceENotation = forceENotation;
+ axisLable.textLimit = textLimit.Clone();
+ return axisLable;
+ }
+
+ public void Copy(AxisLabel axisLable)
+ {
+ show = axisLable.show;
+ formatter = axisLable.formatter;
+ interval = axisLable.interval;
+ inside = axisLable.inside;
+ rotate = axisLable.rotate;
+ margin = axisLable.margin;
+ color = axisLable.color;
+ fontSize = axisLable.fontSize;
+ forceENotation = axisLable.forceENotation;
+ textLimit.Copy(axisLable.textLimit);
+ }
+
public void SetRelatedText(Text txt, float labelWidth)
{
m_TextLimit.SetRelatedText(txt, labelWidth);
diff --git a/Runtime/Component/Sub/AxisLine.cs b/Runtime/Component/Sub/AxisLine.cs
index 76462c78..da375095 100644
--- a/Runtime/Component/Sub/AxisLine.cs
+++ b/Runtime/Component/Sub/AxisLine.cs
@@ -41,7 +41,7 @@ namespace XCharts
public bool onZero
{
get { return m_OnZero; }
- set { if (PropertyUtility.SetStruct(ref m_Show, value)) SetVerticesDirty(); }
+ set { if (PropertyUtility.SetStruct(ref m_OnZero, value)) SetVerticesDirty(); }
}
///
/// line style line width.
@@ -116,5 +116,31 @@ namespace XCharts
return axisLine;
}
}
+
+ public AxisLine Clone()
+ {
+ var axisLine = new AxisLine();
+ axisLine.show = show;
+ axisLine.onZero = onZero;
+ axisLine.width = width;
+ axisLine.symbol = symbol;
+ axisLine.symbolWidth = symbolWidth;
+ axisLine.symbolHeight = symbolHeight;
+ axisLine.symbolOffset = symbolOffset;
+ axisLine.symbolDent = symbolDent;
+ return axisLine;
+ }
+
+ public void Copy(AxisLine axisLine)
+ {
+ show = axisLine.show;
+ onZero = axisLine.onZero;
+ width = axisLine.width;
+ symbol = axisLine.symbol;
+ symbolWidth = axisLine.symbolWidth;
+ symbolHeight = axisLine.symbolHeight;
+ symbolOffset = axisLine.symbolOffset;
+ symbolDent = axisLine.symbolDent;
+ }
}
}
\ No newline at end of file
diff --git a/Runtime/Component/Sub/AxisName.cs b/Runtime/Component/Sub/AxisName.cs
index 4282b7c3..b4dbb5b7 100644
--- a/Runtime/Component/Sub/AxisName.cs
+++ b/Runtime/Component/Sub/AxisName.cs
@@ -125,5 +125,31 @@ namespace XCharts
};
}
}
+
+ public AxisName Clone()
+ {
+ var axisName = new AxisName();
+ axisName.show = show;
+ axisName.name = name;
+ axisName.location = location;
+ axisName.offset = offset;
+ axisName.rotate = rotate;
+ axisName.color = color;
+ axisName.fontSize = fontSize;
+ axisName.fontStyle = fontStyle;
+ return axisName;
+ }
+
+ public void Copy(AxisName axisName)
+ {
+ show = axisName.show;
+ name = axisName.name;
+ location = axisName.location;
+ offset = axisName.offset;
+ rotate = axisName.rotate;
+ color = axisName.color;
+ fontSize = axisName.fontSize;
+ fontStyle = axisName.fontStyle;
+ }
}
}
\ No newline at end of file
diff --git a/Runtime/Component/Sub/AxisSplitArea.cs b/Runtime/Component/Sub/AxisSplitArea.cs
index 7e1c68ed..03691e1e 100644
--- a/Runtime/Component/Sub/AxisSplitArea.cs
+++ b/Runtime/Component/Sub/AxisSplitArea.cs
@@ -57,6 +57,22 @@ namespace XCharts
}
}
+ public AxisSplitArea Clone()
+ {
+ var axisSplitArea = new AxisSplitArea();
+ axisSplitArea.show = show;
+ axisSplitArea.color = new List();
+ ChartHelper.CopyList(axisSplitArea.color, color);
+ return axisSplitArea;
+ }
+
+ public void Copy(AxisSplitArea splitArea)
+ {
+ show = splitArea.show;
+ color.Clear();
+ ChartHelper.CopyList(color, splitArea.color);
+ }
+
public Color getColor(int index)
{
var i = index % color.Count;
diff --git a/Runtime/Component/Sub/AxisSplitLine.cs b/Runtime/Component/Sub/AxisSplitLine.cs
index be05397b..9c65975a 100644
--- a/Runtime/Component/Sub/AxisSplitLine.cs
+++ b/Runtime/Component/Sub/AxisSplitLine.cs
@@ -61,6 +61,22 @@ namespace XCharts
}
}
+ public AxisSplitLine Clone()
+ {
+ var axisSplitLine = new AxisSplitLine();
+ axisSplitLine.show = show;
+ axisSplitLine.interval = interval;
+ axisSplitLine.lineStyle = lineStyle.Clone();
+ return axisSplitLine;
+ }
+
+ public void Copy(AxisSplitLine splitLine)
+ {
+ show = splitLine.show;
+ interval = splitLine.interval;
+ lineStyle.Copy(splitLine.lineStyle);
+ }
+
internal Color GetColor(ThemeInfo theme)
{
if (lineStyle.color != Color.clear)
diff --git a/Runtime/Component/Sub/AxisTick.cs b/Runtime/Component/Sub/AxisTick.cs
index e49d68b0..62284d65 100644
--- a/Runtime/Component/Sub/AxisTick.cs
+++ b/Runtime/Component/Sub/AxisTick.cs
@@ -84,5 +84,25 @@ namespace XCharts
return tick;
}
}
+
+ public AxisTick Clone()
+ {
+ var axisTick = new AxisTick();
+ axisTick.show = show;
+ axisTick.alignWithLabel = alignWithLabel;
+ axisTick.inside = inside;
+ axisTick.length = length;
+ axisTick.width = width;
+ return axisTick;
+ }
+
+ public void Copy(AxisTick axisTick)
+ {
+ show = axisTick.show;
+ alignWithLabel = axisTick.alignWithLabel;
+ inside = axisTick.inside;
+ length = axisTick.length;
+ width = axisTick.width;
+ }
}
}
\ No newline at end of file
diff --git a/Runtime/Component/Sub/LineStyle.cs b/Runtime/Component/Sub/LineStyle.cs
index db5babf9..6f67377b 100644
--- a/Runtime/Component/Sub/LineStyle.cs
+++ b/Runtime/Component/Sub/LineStyle.cs
@@ -98,7 +98,6 @@ namespace XCharts
public LineStyle()
{
-
}
public LineStyle(float width)
@@ -112,6 +111,26 @@ namespace XCharts
this.width = width;
}
+ public LineStyle Clone()
+ {
+ var lineStyle = new LineStyle();
+ lineStyle.show = show;
+ lineStyle.type = type;
+ lineStyle.color = color;
+ lineStyle.width = width;
+ lineStyle.opacity = opacity;
+ return lineStyle;
+ }
+
+ public void Copy(LineStyle lineStyle)
+ {
+ show = lineStyle.show;
+ type = lineStyle.type;
+ color = lineStyle.color;
+ width = lineStyle.width;
+ opacity = lineStyle.opacity;
+ }
+
public Color GetColor()
{
var color = m_Color;
diff --git a/Runtime/Component/Sub/TextLimit.cs b/Runtime/Component/Sub/TextLimit.cs
index bb6feb2d..b6d9d133 100644
--- a/Runtime/Component/Sub/TextLimit.cs
+++ b/Runtime/Component/Sub/TextLimit.cs
@@ -60,6 +60,24 @@ namespace XCharts
private TextGenerationSettings m_RelatedTextSettings;
private float m_RelatedTextWidth = 0;
+ public TextLimit Clone()
+ {
+ var textLimit = new TextLimit();
+ textLimit.enable = enable;
+ textLimit.maxWidth = maxWidth;
+ textLimit.gap = gap;
+ textLimit.suffix = suffix;
+ return textLimit;
+ }
+
+ public void Copy(TextLimit textLimit)
+ {
+ enable = textLimit.enable;
+ maxWidth = textLimit.maxWidth;
+ gap = textLimit.gap;
+ suffix = textLimit.suffix;
+ }
+
public void SetRelatedText(Text txt, float labelWidth)
{
m_RelatedText = txt;