mirror of
https://github.com/XCharts-Team/XCharts.git
synced 2026-05-30 13:28:47 +00:00
增加Axis的m_MinCategorySpacing设置类目轴默认的最小类目间距
This commit is contained in:
@@ -443,6 +443,7 @@ The axis in rectangular coordinate.
|
|||||||
|Clone()||public Axis Clone()|
|
|Clone()||public Axis Clone()|
|
||||||
|Copy()||public void Copy(Axis axis)|
|
|Copy()||public void Copy(Axis axis)|
|
||||||
|GetAddedDataCount()||public int GetAddedDataCount()<br/>get the history data count. |
|
|GetAddedDataCount()||public int GetAddedDataCount()<br/>get the history data count. |
|
||||||
|
|GetCategoryPosition()||public Vector3 GetCategoryPosition(int categoryIndex, int dataCount = 0)|
|
||||||
|GetData()||public string GetData(int index)<br/>获得指定索引的类目数据 |
|
|GetData()||public string GetData(int index)<br/>获得指定索引的类目数据 |
|
||||||
|GetData()||public string GetData(int index, DataZoom dataZoom)<br/>获得在dataZoom范围内指定索引的类目数据 |
|
|GetData()||public string GetData(int index, DataZoom dataZoom)<br/>获得在dataZoom范围内指定索引的类目数据 |
|
||||||
|GetDistance()||public float GetDistance(double value, float axisLength = 0)<br/>获得值在坐标轴上的距离 |
|
|GetDistance()||public float GetDistance(double value, float axisLength = 0)<br/>获得值在坐标轴上的距离 |
|
||||||
|
|||||||
@@ -422,6 +422,7 @@ The axis in rectangular coordinate.
|
|||||||
|inverse|false||Whether the axis are reversed or not. Invalid in `Category` axis.
|
|inverse|false||Whether the axis are reversed or not. Invalid in `Category` axis.
|
||||||
|clockwise|true||Whether the positive position of axis is in clockwise. True for clockwise by default.
|
|clockwise|true||Whether the positive position of axis is in clockwise. True for clockwise by default.
|
||||||
|insertDataToHead|||Whether to add new data at the head or at the end of the list.
|
|insertDataToHead|||Whether to add new data at the head or at the end of the list.
|
||||||
|
|minCategorySpacing|0|v3.11.0|The minimum spacing between categories.
|
||||||
|icons|||类目数据对应的图标。
|
|icons|||类目数据对应的图标。
|
||||||
|data|||Category data, available in type: 'Category' axis.
|
|data|||Category data, available in type: 'Category' axis.
|
||||||
|axisLine|||axis Line. [AxisLine](#axisline)|
|
|axisLine|||axis Line. [AxisLine](#axisline)|
|
||||||
|
|||||||
@@ -443,6 +443,7 @@ slug: /api
|
|||||||
|Clone()||public Axis Clone()|
|
|Clone()||public Axis Clone()|
|
||||||
|Copy()||public void Copy(Axis axis)|
|
|Copy()||public void Copy(Axis axis)|
|
||||||
|GetAddedDataCount()||public int GetAddedDataCount()<br/>获得添加过的历史数据总数 |
|
|GetAddedDataCount()||public int GetAddedDataCount()<br/>获得添加过的历史数据总数 |
|
||||||
|
|GetCategoryPosition()||public Vector3 GetCategoryPosition(int categoryIndex, int dataCount = 0)|
|
||||||
|GetData()||public string GetData(int index)<br/>获得指定索引的类目数据 |
|
|GetData()||public string GetData(int index)<br/>获得指定索引的类目数据 |
|
||||||
|GetData()||public string GetData(int index, DataZoom dataZoom)<br/>获得在dataZoom范围内指定索引的类目数据 |
|
|GetData()||public string GetData(int index, DataZoom dataZoom)<br/>获得在dataZoom范围内指定索引的类目数据 |
|
||||||
|GetDistance()||public float GetDistance(double value, float axisLength = 0)<br/>获得值在坐标轴上的距离 |
|
|GetDistance()||public float GetDistance(double value, float axisLength = 0)<br/>获得值在坐标轴上的距离 |
|
||||||
|
|||||||
@@ -73,6 +73,7 @@ slug: /changelog
|
|||||||
|
|
||||||
## master
|
## master
|
||||||
|
|
||||||
|
* (2024.06.09) 增加`Axis`的`m_MinCategorySpacing`设置类目轴默认的最小类目间距
|
||||||
* (2024.06.09) 修复`Tooltip`的`Cross`在`Axis`是类目轴并且开启`DataZoom`的情况下指示位置不准确的问题
|
* (2024.06.09) 修复`Tooltip`的`Cross`在`Axis`是类目轴并且开启`DataZoom`的情况下指示位置不准确的问题
|
||||||
* (2024.06.06) 修复`Serie`在`Clone`时动画异常问题 (#320)
|
* (2024.06.06) 修复`Serie`在`Clone`时动画异常问题 (#320)
|
||||||
* (2024.06.04) 修复`Serie`的`state`在代码动态设置时不刷新的问题
|
* (2024.06.04) 修复`Serie`的`state`在代码动态设置时不刷新的问题
|
||||||
|
|||||||
@@ -415,6 +415,7 @@ import APITable from '@site/src/components/APITable';
|
|||||||
|inverse|false||是否反向坐标轴。在类目轴中无效。
|
|inverse|false||是否反向坐标轴。在类目轴中无效。
|
||||||
|clockwise|true||刻度增长是否按顺时针,默认顺时针。
|
|clockwise|true||刻度增长是否按顺时针,默认顺时针。
|
||||||
|insertDataToHead|||添加新数据时是在列表的头部还是尾部加入。
|
|insertDataToHead|||添加新数据时是在列表的头部还是尾部加入。
|
||||||
|
|minCategorySpacing|0|v3.11.0|类目之间的最小间距。
|
||||||
|icons|||类目数据对应的图标。
|
|icons|||类目数据对应的图标。
|
||||||
|data|||类目数据,在类目轴(type: 'category')中有效。
|
|data|||类目数据,在类目轴(type: 'category')中有效。
|
||||||
|axisLine|||坐标轴轴线。 [AxisLine](#axisline)|
|
|axisLine|||坐标轴轴线。 [AxisLine](#axisline)|
|
||||||
|
|||||||
@@ -64,6 +64,7 @@ namespace XCharts.Editor
|
|||||||
if (type == Axis.AxisType.Category)
|
if (type == Axis.AxisType.Category)
|
||||||
{
|
{
|
||||||
PropertyField("m_MaxCache");
|
PropertyField("m_MaxCache");
|
||||||
|
PropertyField("m_MinCategorySpacing");
|
||||||
PropertyField("m_BoundaryGap");
|
PropertyField("m_BoundaryGap");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|||||||
@@ -99,6 +99,7 @@ namespace XCharts.Runtime
|
|||||||
[SerializeField] protected bool m_Inverse = false;
|
[SerializeField] protected bool m_Inverse = false;
|
||||||
[SerializeField] private bool m_Clockwise = true;
|
[SerializeField] private bool m_Clockwise = true;
|
||||||
[SerializeField] private bool m_InsertDataToHead;
|
[SerializeField] private bool m_InsertDataToHead;
|
||||||
|
[SerializeField][Since("v3.11.0")] private float m_MinCategorySpacing = 0;
|
||||||
[SerializeField] protected List<Sprite> m_Icons = new List<Sprite>();
|
[SerializeField] protected List<Sprite> m_Icons = new List<Sprite>();
|
||||||
[SerializeField] protected List<string> m_Data = new List<string>();
|
[SerializeField] protected List<string> m_Data = new List<string>();
|
||||||
[SerializeField] protected AxisLine m_AxisLine = AxisLine.defaultAxisLine;
|
[SerializeField] protected AxisLine m_AxisLine = AxisLine.defaultAxisLine;
|
||||||
@@ -406,6 +407,15 @@ namespace XCharts.Runtime
|
|||||||
get { return m_InsertDataToHead; }
|
get { return m_InsertDataToHead; }
|
||||||
set { if (PropertyUtil.SetStruct(ref m_InsertDataToHead, value)) SetAllDirty(); }
|
set { if (PropertyUtil.SetStruct(ref m_InsertDataToHead, value)) SetAllDirty(); }
|
||||||
}
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// The minimum spacing between categories.
|
||||||
|
/// ||类目之间的最小间距。
|
||||||
|
/// </summary>
|
||||||
|
public float minCategorySpacing
|
||||||
|
{
|
||||||
|
get { return m_MinCategorySpacing; }
|
||||||
|
set { if (PropertyUtil.SetStruct(ref m_MinCategorySpacing, value)) SetAllDirty(); }
|
||||||
|
}
|
||||||
|
|
||||||
public override bool vertsDirty
|
public override bool vertsDirty
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -65,8 +65,10 @@ namespace XCharts.Runtime
|
|||||||
if (axis.splitNumber <= 0)
|
if (axis.splitNumber <= 0)
|
||||||
{
|
{
|
||||||
var eachWid = coordinateWid / dataCount;
|
var eachWid = coordinateWid / dataCount;
|
||||||
//var min = ((axis is YAxis) || (axis is ZAxis3D)) ? 20 : 80;
|
|
||||||
var min = 20;
|
var min = axis.minCategorySpacing > 0
|
||||||
|
? axis.minCategorySpacing
|
||||||
|
: (Mathf.Abs(axis.context.dire.y) < 0.01 ? 80 : 20);
|
||||||
if (eachWid > min) return dataCount;
|
if (eachWid > min) return dataCount;
|
||||||
var tick = Mathf.CeilToInt(min / eachWid);
|
var tick = Mathf.CeilToInt(min / eachWid);
|
||||||
return tick <= 1 ? dataCount : (int)(dataCount / tick);
|
return tick <= 1 ? dataCount : (int)(dataCount / tick);
|
||||||
|
|||||||
Reference in New Issue
Block a user