diff --git a/Assets/XCharts/Scripts/Editor/PropertyDrawers/AxisNameDrawer.cs b/Assets/XCharts/Scripts/Editor/PropertyDrawers/AxisNameDrawer.cs
index 5b8319ac..1c10eaf1 100644
--- a/Assets/XCharts/Scripts/Editor/PropertyDrawers/AxisNameDrawer.cs
+++ b/Assets/XCharts/Scripts/Editor/PropertyDrawers/AxisNameDrawer.cs
@@ -16,7 +16,7 @@ namespace XCharts
SerializedProperty show = prop.FindPropertyRelative("m_Show");
SerializedProperty m_Name = prop.FindPropertyRelative("m_Name");
SerializedProperty m_Location = prop.FindPropertyRelative("m_Location");
- SerializedProperty m_Gap = prop.FindPropertyRelative("m_Gap");
+ SerializedProperty m_Offset = prop.FindPropertyRelative("m_Offset");
SerializedProperty m_Rotate = prop.FindPropertyRelative("m_Rotate");
SerializedProperty m_Color = prop.FindPropertyRelative("m_Color");
SerializedProperty m_FontSize = prop.FindPropertyRelative("m_FontSize");
@@ -31,8 +31,17 @@ namespace XCharts
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
EditorGUI.PropertyField(drawRect, m_Location);
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
- EditorGUI.PropertyField(drawRect, m_Gap);
- drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
+ EditorGUI.PropertyField(drawRect, m_Offset);
+ drawRect.y += EditorGUI.GetPropertyHeight(m_Offset);
+ // EditorGUI.LabelField(drawRect, "Offset");
+ // var startX = drawRect.x + EditorGUIUtility.labelWidth - EditorGUI.indentLevel * 15;
+ // var tempWidth = (pos.width - startX + 35) / 2;
+ // var xRect = new Rect(startX, drawRect.y, tempWidth, drawRect.height);
+ // var yRect = new Rect(xRect.x + tempWidth - 20, drawRect.y, tempWidth, drawRect.height);
+ // var x = EditorGUI.FloatField(xRect, m_Offset.vector2Value.x);
+ // var y = EditorGUI.FloatField(yRect, m_Offset.vector2Value.y);
+ // m_Offset.vector2Value = new Vector2(x,y);
+ // drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
EditorGUI.PropertyField(drawRect, m_Rotate);
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
EditorGUI.PropertyField(drawRect, m_Color);
diff --git a/Assets/XCharts/Scripts/UI/Internal/AxisName.cs b/Assets/XCharts/Scripts/UI/Internal/AxisName.cs
index 0216aaa3..cecdcc82 100644
--- a/Assets/XCharts/Scripts/UI/Internal/AxisName.cs
+++ b/Assets/XCharts/Scripts/UI/Internal/AxisName.cs
@@ -23,7 +23,7 @@ namespace XCharts
[SerializeField] private bool m_Show;
[SerializeField] private string m_Name;
[SerializeField] private Location m_Location;
- [SerializeField] private float m_Gap;
+ [SerializeField] private Vector2 m_Offset;
[SerializeField] private float m_Rotate;
[SerializeField] private Color m_Color;
[SerializeField] private int m_FontSize;
@@ -45,10 +45,10 @@ namespace XCharts
///
public Location location { get { return m_Location; } set { m_Location = value; } }
///
- /// Gap between axis name and axis line.
- /// 坐标轴名称与轴线之间的距离。
+ /// the offset of axis name and axis line.
+ /// 坐标轴名称与轴线之间的偏移。
///
- public float gap { get { return m_Gap; } set { m_Gap = value; } }
+ public Vector2 offset { get { return m_Offset; } set { m_Offset = value; } }
///
/// Rotation of axis name.
/// 坐标轴名字旋转,角度值。
@@ -79,7 +79,6 @@ namespace XCharts
m_Show = false,
m_Name = "axisName",
m_Location = Location.End,
- m_Gap = 5,
m_Rotate = 0,
m_Color = Color.clear,
m_FontSize = 18,
@@ -93,7 +92,7 @@ namespace XCharts
m_Show = other.show;
m_Name = other.name;
m_Location = other.location;
- m_Gap = other.gap;
+ m_Offset = other.offset;
m_Rotate = other.rotate;
m_Color = other.color;
m_FontSize = other.fontSize;
@@ -110,9 +109,9 @@ namespace XCharts
return m_Show == other.show &&
m_Name.Equals(other.name) &&
m_Location == other.location &&
- m_Gap == other.gap &&
m_Rotate == other.rotate &&
m_Color == other.color &&
+ m_Offset == other.offset &&
m_FontSize == other.fontSize &&
m_FontStyle == other.fontStyle;
}
diff --git a/Assets/XCharts/Scripts/UI/Internal/CoordinateChart.cs b/Assets/XCharts/Scripts/UI/Internal/CoordinateChart.cs
index f41fb7e5..5860d1d8 100644
--- a/Assets/XCharts/Scripts/UI/Internal/CoordinateChart.cs
+++ b/Assets/XCharts/Scripts/UI/Internal/CoordinateChart.cs
@@ -387,8 +387,9 @@ namespace XCharts
var color = yAxis.axisName.color == Color.clear ? (Color)m_ThemeInfo.axisTextColor :
yAxis.axisName.color;
var fontSize = yAxis.axisName.fontSize;
- var gap = yAxis.axisName.gap;
+ var offset = yAxis.axisName.offset;
Text axisName = null;
+ var zeroPos = new Vector3(coordinateX + m_XAxises[yAxisIndex].zeroXOffset, coordinateY);
switch (yAxis.axisName.location)
{
case AxisName.Location.Start:
@@ -397,8 +398,8 @@ namespace XCharts
new Vector2(0.5f, 0.5f), new Vector2(0.5f, 0.5f), new Vector2(100, 20), fontSize,
yAxis.axisName.rotate, yAxis.axisName.fontStyle);
axisName.transform.localPosition = yAxisIndex > 0 ?
- new Vector2(coordinateX + coordinateWid, coordinateY - gap) :
- new Vector2(coordinateX, coordinateY - gap);
+ new Vector2(coordinateX + coordinateWid + offset.x, coordinateY - offset.y) :
+ new Vector2(zeroPos.x + offset.x, coordinateY - offset.y);
break;
case AxisName.Location.Middle:
axisName = ChartHelper.AddTextObject(objName + "_name", axisObj.transform,
@@ -406,8 +407,8 @@ namespace XCharts
new Vector2(1, 0.5f), new Vector2(1, 0.5f), new Vector2(100, 20), fontSize,
yAxis.axisName.rotate, yAxis.axisName.fontStyle);
axisName.transform.localPosition = yAxisIndex > 0 ?
- new Vector2(coordinateX + coordinateWid - gap, coordinateY + coordinateHig / 2) :
- new Vector2(coordinateX - gap, coordinateY + coordinateHig / 2);
+ new Vector2(coordinateX + coordinateWid - offset.x, coordinateY + coordinateHig / 2 + offset.y) :
+ new Vector2(coordinateX - offset.x, coordinateY + coordinateHig / 2 + offset.y);
break;
case AxisName.Location.End:
axisName = ChartHelper.AddTextObject(objName + "_name", axisObj.transform,
@@ -415,8 +416,8 @@ namespace XCharts
new Vector2(0.5f, 0.5f), new Vector2(0.5f, 0.5f), new Vector2(100, 20), fontSize,
yAxis.axisName.rotate, yAxis.axisName.fontStyle);
axisName.transform.localPosition = yAxisIndex > 0 ?
- new Vector2(coordinateX + coordinateWid, coordinateY + coordinateHig + gap) :
- new Vector2(coordinateX, coordinateY + coordinateHig + gap);
+ new Vector2(coordinateX + coordinateWid + offset.x, coordinateY + coordinateHig + offset.y) :
+ new Vector2(zeroPos.x + offset.x, coordinateY + coordinateHig + offset.y);
break;
}
axisName.text = yAxis.axisName.name;
@@ -475,8 +476,9 @@ namespace XCharts
var color = xAxis.axisName.color == Color.clear ? (Color)m_ThemeInfo.axisTextColor :
xAxis.axisName.color;
var fontSize = xAxis.axisName.fontSize;
- var gap = xAxis.axisName.gap;
+ var offset = xAxis.axisName.offset;
Text axisName = null;
+ var zeroPos = new Vector3(coordinateX, coordinateY + m_YAxises[xAxisIndex].zeroYOffset);
switch (xAxis.axisName.location)
{
case AxisName.Location.Start:
@@ -485,8 +487,8 @@ namespace XCharts
new Vector2(1, 0.5f), new Vector2(1, 0.5f), new Vector2(100, 20), fontSize,
xAxis.axisName.rotate, xAxis.axisName.fontStyle);
axisName.transform.localPosition = xAxisIndex > 0 ?
- new Vector2(coordinateX - gap, coordinateY + coordinateHig) :
- new Vector2(coordinateX - gap, coordinateY);
+ new Vector2(zeroPos.x - offset.x, coordinateY + coordinateHig + offset.y) :
+ new Vector2(zeroPos.x - offset.x, zeroPos.y + offset.y);
break;
case AxisName.Location.Middle:
axisName = ChartHelper.AddTextObject(ChartHelper.Cancat(objName, "_name"), axisObj.transform,
@@ -494,8 +496,8 @@ namespace XCharts
new Vector2(0.5f, 0.5f), new Vector2(0.5f, 0.5f), new Vector2(100, 20), fontSize,
xAxis.axisName.rotate, xAxis.axisName.fontStyle);
axisName.transform.localPosition = xAxisIndex > 0 ?
- new Vector2(coordinateX + coordinateWid / 2, coordinateY + coordinateHig - gap) :
- new Vector2(coordinateX + coordinateWid / 2, coordinateY - gap);
+ new Vector2(coordinateX + coordinateWid / 2 + offset.x, coordinateY + coordinateHig - offset.y) :
+ new Vector2(coordinateX + coordinateWid / 2 + offset.x, coordinateY - offset.y);
break;
case AxisName.Location.End:
axisName = ChartHelper.AddTextObject(ChartHelper.Cancat(objName, "_name"), axisObj.transform,
@@ -503,8 +505,8 @@ namespace XCharts
new Vector2(0, 0.5f), new Vector2(0, 0.5f), new Vector2(100, 20), fontSize,
xAxis.axisName.rotate, xAxis.axisName.fontStyle);
axisName.transform.localPosition = xAxisIndex > 0 ?
- new Vector2(coordinateX + coordinateWid + gap, coordinateY + coordinateHig) :
- new Vector2(coordinateX + coordinateWid + gap, coordinateY);
+ new Vector2(coordinateX + coordinateWid + offset.x, coordinateY + coordinateHig + offset.y) :
+ new Vector2(coordinateX + coordinateWid + offset.x, zeroPos.y + offset.y);
break;
}
axisName.text = xAxis.axisName.name;
@@ -662,7 +664,7 @@ namespace XCharts
m_Series.GetYMinMaxValue(m_DataZoom, axisIndex, out tempMinValue, out tempMaxValue);
}
axis.AdjustMinMaxValue(ref tempMinValue, ref tempMaxValue);
-
+
if (tempMinValue != axis.minValue || tempMaxValue != axis.maxValue)
{
axis.minValue = tempMinValue;