mirror of
https://github.com/XCharts-Team/XCharts.git
synced 2026-05-25 02:10:16 +00:00
增加AxisTick的width参数可单独设置坐标轴刻度的宽度
This commit is contained in:
@@ -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`可单独配置数据项样式的支持
|
||||||
|
|||||||
@@ -720,6 +720,7 @@
|
|||||||
* `alignWithLabel`:类目轴中在 boundaryGap 为 true 的时候有效,可以保证刻度线和标签对齐。
|
* `alignWithLabel`:类目轴中在 boundaryGap 为 true 的时候有效,可以保证刻度线和标签对齐。
|
||||||
* `inside`:坐标轴刻度是否朝内,默认朝外。
|
* `inside`:坐标轴刻度是否朝内,默认朝外。
|
||||||
* `length`:坐标轴刻度的长度。
|
* `length`:坐标轴刻度的长度。
|
||||||
|
* `width`:坐标轴刻度的宽度。默认为0时宽度和坐标轴一致。
|
||||||
|
|
||||||
## `Emphasis`
|
## `Emphasis`
|
||||||
|
|
||||||
|
|||||||
@@ -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;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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;
|
||||||
|
|||||||
19
Assets/XCharts/Runtime/Helper/AxisHelper.cs
Normal file
19
Assets/XCharts/Runtime/Helper/AxisHelper.cs
Normal 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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
11
Assets/XCharts/Runtime/Helper/AxisHelper.cs.meta
Normal file
11
Assets/XCharts/Runtime/Helper/AxisHelper.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: ada7d0edfc97b432db026ca5eecea8ac
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
@@ -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];
|
||||||
|
|||||||
Reference in New Issue
Block a user