增加AxisTickwidth参数可单独设置坐标轴刻度的宽度

This commit is contained in:
monitor1394
2020-03-20 08:47:34 +08:00
parent a1018801d4
commit 541bc421b7
7 changed files with 52 additions and 6 deletions

View File

@@ -1,6 +1,7 @@
# 更新日志 # 更新日志
* (2020.03.20) 增加`AxisTick``width`参数可单独设置坐标轴刻度的宽度
* (2020.03.20) 增加`Serie``radarType`参数设置`多圈``单圈`雷达图 * (2020.03.20) 增加`Serie``radarType`参数设置`多圈``单圈`雷达图
* (2020.03.17) 增加`BarChart`可用`ItemStyle``backgroundColor`设置数据项背景颜色 * (2020.03.17) 增加`BarChart`可用`ItemStyle``backgroundColor`设置数据项背景颜色
* (2020.03.17) 增加`SerieData``ItemStyle``Emphasis`可单独配置数据项样式的支持 * (2020.03.17) 增加`SerieData``ItemStyle``Emphasis`可单独配置数据项样式的支持

View File

@@ -720,6 +720,7 @@
* `alignWithLabel`:类目轴中在 boundaryGap 为 true 的时候有效,可以保证刻度线和标签对齐。 * `alignWithLabel`:类目轴中在 boundaryGap 为 true 的时候有效,可以保证刻度线和标签对齐。
* `inside`:坐标轴刻度是否朝内,默认朝外。 * `inside`:坐标轴刻度是否朝内,默认朝外。
* `length`:坐标轴刻度的长度。 * `length`:坐标轴刻度的长度。
* `width`坐标轴刻度的宽度。默认为0时宽度和坐标轴一致。
## `Emphasis` ## `Emphasis`

View File

@@ -23,6 +23,7 @@ namespace XCharts
SerializedProperty m_AlignWithLabel = prop.FindPropertyRelative("m_AlignWithLabel"); SerializedProperty m_AlignWithLabel = prop.FindPropertyRelative("m_AlignWithLabel");
SerializedProperty m_Inside = prop.FindPropertyRelative("m_Inside"); SerializedProperty m_Inside = prop.FindPropertyRelative("m_Inside");
SerializedProperty m_Length = prop.FindPropertyRelative("m_Length"); SerializedProperty m_Length = prop.FindPropertyRelative("m_Length");
SerializedProperty m_Width = prop.FindPropertyRelative("m_Width");
ChartEditorHelper.MakeFoldout(ref drawRect, ref m_AxisTickToggle, "Axis Tick", show, false); ChartEditorHelper.MakeFoldout(ref drawRect, ref m_AxisTickToggle, "Axis Tick", show, false);
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing; drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
@@ -35,6 +36,8 @@ namespace XCharts
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing; drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
EditorGUI.PropertyField(drawRect, m_Length); EditorGUI.PropertyField(drawRect, m_Length);
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing; drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
EditorGUI.PropertyField(drawRect, m_Width);
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
--EditorGUI.indentLevel; --EditorGUI.indentLevel;
} }
} }
@@ -44,7 +47,7 @@ namespace XCharts
float height = 0; float height = 0;
if (m_AxisTickToggle) if (m_AxisTickToggle)
{ {
height += 3 * EditorGUIUtility.singleLineHeight + 2 * EditorGUIUtility.standardVerticalSpacing; height += 4 * EditorGUIUtility.singleLineHeight + 3 * EditorGUIUtility.standardVerticalSpacing;
} }
return height; return height;
} }

View File

@@ -21,6 +21,7 @@ namespace XCharts
[SerializeField] private bool m_AlignWithLabel; [SerializeField] private bool m_AlignWithLabel;
[SerializeField] private bool m_Inside; [SerializeField] private bool m_Inside;
[SerializeField] private float m_Length; [SerializeField] private float m_Length;
[SerializeField] private float m_Width;
/// <summary> /// <summary>
/// Set this to false to prevent the axis tick from showing. /// Set this to false to prevent the axis tick from showing.
@@ -58,6 +59,15 @@ namespace XCharts
get { return m_Length; } get { return m_Length; }
set { if (PropertyUtility.SetStruct(ref m_Length, value)) SetVerticesDirty(); } set { if (PropertyUtility.SetStruct(ref m_Length, value)) SetVerticesDirty(); }
} }
/// <summary>
/// The width of the axis tick.Keep the same width with axis line when default 0.
/// 坐标轴刻度的宽度。默认为0时宽度和坐标轴一致。
/// </summary>
public float width
{
get { return m_Width; }
set { if (PropertyUtility.SetStruct(ref m_Width, value)) SetVerticesDirty(); }
}
public static AxisTick defaultTick public static AxisTick defaultTick
{ {
@@ -68,6 +78,7 @@ namespace XCharts
m_Show = true, m_Show = true,
m_AlignWithLabel = false, m_AlignWithLabel = false,
m_Inside = false, m_Inside = false,
m_Width = 0f,
m_Length = 5f m_Length = 5f
}; };
return tick; return tick;

View File

@@ -0,0 +1,19 @@
/******************************************/
/* */
/* Copyright (c) 2018 monitor1394 */
/* https://github.com/monitor1394 */
/* */
/******************************************/
using UnityEngine;
using UnityEngine.UI;
namespace XCharts
{
internal static class AxisHelper
{
public static float GetTickWidth(Axis axis)
{
return axis.axisTick.width != 0 ? axis.axisTick.width : axis.axisLine.width;
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: ada7d0edfc97b432db026ca5eecea8ac
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -1027,7 +1027,7 @@ namespace XCharts
pX += startX - yAxis.axisTick.length; pX += startX - yAxis.axisTick.length;
} }
ChartDrawer.DrawLine(vh, new Vector3(startX, pY), new Vector3(pX, pY), ChartDrawer.DrawLine(vh, new Vector3(startX, pY), new Vector3(pX, pY),
yAxis.axisLine.width, m_ThemeInfo.axisLineColor); AxisHelper.GetTickWidth(yAxis), m_ThemeInfo.axisLineColor);
} }
totalWidth += scaleWidth; totalWidth += scaleWidth;
} }
@@ -1117,7 +1117,7 @@ namespace XCharts
pY += startY - xAxis.axisTick.length; pY += startY - xAxis.axisTick.length;
} }
ChartDrawer.DrawLine(vh, new Vector3(pX, startY), new Vector3(pX, pY), ChartDrawer.DrawLine(vh, new Vector3(pX, startY), new Vector3(pX, pY),
xAxis.axisLine.width, m_ThemeInfo.axisLineColor); AxisHelper.GetTickWidth(xAxis), m_ThemeInfo.axisLineColor);
} }
totalWidth += scaleWidth; totalWidth += scaleWidth;
} }
@@ -1430,12 +1430,12 @@ namespace XCharts
for (int j = 0; j < serie.data.Count; j++) for (int j = 0; j < serie.data.Count; j++)
{ {
var serieData = serie.data[j]; var serieData = serie.data[j];
var serieLabel = SerieHelper.GetSerieLabel(serie,serieData,serieData.highlighted); var serieLabel = SerieHelper.GetSerieLabel(serie, serieData, serieData.highlighted);
serieData.index = j; serieData.index = j;
if ((serieLabel.show || serieData.iconStyle.show)) if ((serieLabel.show || serieData.iconStyle.show))
{ {
var pos = serie.dataPoints[j]; var pos = serie.dataPoints[j];
var isIngore = ChartHelper.IsIngore(pos); var isIngore = ChartHelper.IsIngore(pos);
if (isIngore) if (isIngore)
{ {
@@ -1519,7 +1519,7 @@ namespace XCharts
dimension = m_VisualMap.enable && m_VisualMap.dimension > 0 ? m_VisualMap.dimension - 1 : dimension = m_VisualMap.enable && m_VisualMap.dimension > 0 ? m_VisualMap.dimension - 1 :
serieData.data.Count - 1; serieData.data.Count - 1;
} }
SerieLabelHelper.ResetLabel(serieData, serieLabel, themeInfo, i); SerieLabelHelper.ResetLabel(serieData, serieLabel, themeInfo, i);
value = serieData.data[dimension]; value = serieData.data[dimension];