增加AxisMinMaxAuto范围类型

This commit is contained in:
monitor1394
2023-05-10 23:29:31 +08:00
parent 29c9f59762
commit fab683f5e1
8 changed files with 29 additions and 9 deletions

View File

@@ -421,8 +421,10 @@ Inherits or Implemented: [BaseChart](#basechart)
|GetFullName()||public static string GetFullName(Transform transform)|
|GetHighlightColor()||public static Color32 GetHighlightColor(Color32 color, float rate = 0.8f)|
|GetLastValue()||public static Vector3 GetLastValue(List<Vector3> list)|
|GetMaxCeilRate()||public static double GetMaxCeilRate(double value, double ceilRate)|
|GetMaxDivisibleValue()||public static double GetMaxDivisibleValue(double max, double ceilRate)|
|GetMaxLogValue()||public static double GetMaxLogValue(double value, float logBase, bool isLogBaseE, out int splitNumber)|
|GetMinCeilRate()||public static double GetMinCeilRate(double value, double ceilRate)|
|GetMinDivisibleValue()||public static double GetMinDivisibleValue(double min, double ceilRate)|
|GetMinLogValue()||public static double GetMinLogValue(double value, float logBase, bool isLogBaseE, out int splitNumber)|
|GetOrAddComponent<T>()||public static T GetOrAddComponent<T>(GameObject gameObject) where T : Component|
@@ -1171,6 +1173,7 @@ Inherits or Implemented: [MaskableGraphic](#maskablegraphic)
|GetBezier2()||public static Vector3 GetBezier2(float t, Vector3 sp, Vector3 p1, Vector3 p2, Vector3 ep)|
|GetBezierList()||public static List<Vector3> GetBezierList(Vector3 sp, Vector3 ep, int segment, Vector3 cp)|
|GetDire()||public static Vector3 GetDire(float angle, bool isDegree = false)|
|GetIntersection()||public static bool GetIntersection(Vector3 p1, Vector3 p2, Vector3 p3, Vector3 p4, ref List&lt;Vector3&gt; intersection)<br/>获得两直线的交点 |
|GetIntersection()||public static bool GetIntersection(Vector3 p1, Vector3 p2, Vector3 p3, Vector3 p4, ref Vector3 intersection)<br/>获得两直线的交点 |
|GetPos()||public static Vector3 GetPos(Vector3 center, float radius, float angle, bool isDegree = false)|
|GetVertialDire()||public static Vector3 GetVertialDire(Vector3 dire)|

View File

@@ -252,7 +252,7 @@ The axis in rectangular coordinate.
|--|--|--|--|
|show|true||Whether to show axis.
|type|||the type of axis.<br/>`Axis.AxisType`:<br/>- `Value`: Numerical axis, suitable for continuous data.<br/>- `Category`: Category axis, suitable for discrete category data. Data should only be set via data for this type.<br/>- `Log`: Log axis, suitable for log data.<br/>- `Time`: Time axis, suitable for continuous time series data.<br/>|
|minMaxType|||the type of axis minmax.<br/>`Axis.AxisMinMaxType`:<br/>- `Default`: 0 - maximum.<br/>- `MinMax`: minimum - maximum.<br/>- `Custom`: Customize the minimum and maximum.<br/>|
|minMaxType|||the type of axis minmax.<br/>`Axis.AxisMinMaxType`:<br/>- `Default`: 0 - maximum.<br/>- `MinMax`: minimum - maximum.<br/>- `Custom`: Customize the minimum and maximum.<br/>- `MinMaxAuto`: [since("v3.7.0")]minimum - maximum, automatically calculate the appropriate values.<br/>|
|gridIndex|||The index of the grid on which the axis are located, by default, is in the first grid.
|polarIndex|||The index of the polar on which the axis are located, by default, is in the first polar.
|parallelIndex|||The index of the parallel on which the axis are located, by default, is in the first parallel.
@@ -567,7 +567,7 @@ DataZoom component is used for zooming a specific area, which enables user to in
|rangeMode|||Use absolute value or percent value in DataZoom.start and DataZoom.end.<br/>`DataZoom.RangeMode`:<br/>- `//Value`: The value type of start and end.取值类型<br/>- `Percent`: percent value.<br/>|
|start|||The start percentage of the window out of the data extent, in the range of 0 ~ 100.
|end|||The end percentage of the window out of the data extent, in the range of 0 ~ 100.
|minShowNum|1||Minimum number of display data. Minimum number of data displayed when DataZoom is enlarged to maximum.
|minShowNum|2||Minimum number of display data. Minimum number of data displayed when DataZoom is enlarged to maximum.
|scrollSensitivity|1.1f||The sensitivity of dataZoom scroll. The larger the number, the more sensitive it is.
|orient|||Specify whether the layout of dataZoom component is horizontal or vertical. What's more, it indicates whether the horizontal axis or vertical axis is controlled by default in catesian coordinate system.<br/>`Orient`:<br/>- `Horizonal`: 水平<br/>- `Vertical`: 垂直<br/>|
|labelStyle|||label style. [LabelStyle](#labelstyle)|

View File

@@ -421,8 +421,10 @@ Inherits or Implemented: [BaseChart](#basechart)
|GetFullName()||public static string GetFullName(Transform transform)|
|GetHighlightColor()||public static Color32 GetHighlightColor(Color32 color, float rate = 0.8f)|
|GetLastValue()||public static Vector3 GetLastValue(List&lt;Vector3&gt; list)|
|GetMaxCeilRate()||public static double GetMaxCeilRate(double value, double ceilRate)|
|GetMaxDivisibleValue()||public static double GetMaxDivisibleValue(double max, double ceilRate)|
|GetMaxLogValue()||public static double GetMaxLogValue(double value, float logBase, bool isLogBaseE, out int splitNumber)|
|GetMinCeilRate()||public static double GetMinCeilRate(double value, double ceilRate)|
|GetMinDivisibleValue()||public static double GetMinDivisibleValue(double min, double ceilRate)|
|GetMinLogValue()||public static double GetMinLogValue(double value, float logBase, bool isLogBaseE, out int splitNumber)|
|GetOrAddComponent&lt;T&gt;()||public static T GetOrAddComponent&lt;T&gt;(GameObject gameObject) where T : Component|
@@ -1171,6 +1173,7 @@ Inherits or Implemented: [MaskableGraphic](#maskablegraphic)
|GetBezier2()||public static Vector3 GetBezier2(float t, Vector3 sp, Vector3 p1, Vector3 p2, Vector3 ep)|
|GetBezierList()||public static List&lt;Vector3&gt; GetBezierList(Vector3 sp, Vector3 ep, int segment, Vector3 cp)|
|GetDire()||public static Vector3 GetDire(float angle, bool isDegree = false)|
|GetIntersection()||public static bool GetIntersection(Vector3 p1, Vector3 p2, Vector3 p3, Vector3 p4, ref List&lt;Vector3&gt; intersection)<br/>获得两直线的交点 |
|GetIntersection()||public static bool GetIntersection(Vector3 p1, Vector3 p2, Vector3 p3, Vector3 p4, ref Vector3 intersection)<br/>获得两直线的交点 |
|GetPos()||public static Vector3 GetPos(Vector3 center, float radius, float angle, bool isDegree = false)|
|GetVertialDire()||public static Vector3 GetVertialDire(Vector3 dire)|

View File

@@ -66,6 +66,8 @@ slug: /changelog
## master
* (2023.05.10) 增加`Axis``MinMaxAuto`范围类型
* (2023.05.10) 增加`Line``Clip`的支持
* (2023.05.04) 优化`Axis`在-1到1范围时设置`CeilRate`不生效的问题
* (2023.05.04) 优化`Axis``MinMax`类型范围计算
* (2023.05.04) 修复`AxisLabel`在数据都是小于1的浮点数时显示`Label`格式不对的问题

View File

@@ -252,7 +252,7 @@ Inherits or Implemented: [MainComponent](#maincomponent)
|--|--|--|--|
|show|true||是否显示坐标轴。
|type|||坐标轴类型。<br/>`Axis.AxisType`:<br/>- `Value`: 数值轴。适用于连续数据。<br/>- `Category`: 类目轴。适用于离散的类目数据,为该类型时必须通过 data 设置类目数据。serie的数据第0维数据对应坐标轴data的index。<br/>- `Log`: 对数轴。适用于对数数据。<br/>- `Time`: 时间轴。适用于连续的时序数据。<br/>|
|minMaxType|||坐标轴刻度最大最小值显示类型。<br/>`Axis.AxisMinMaxType`:<br/>- `Default`: 0-最大值。<br/>- `MinMax`: 最小值-最大值。<br/>- `Custom`: 自定义最小值最大值。<br/>|
|minMaxType|||坐标轴刻度最大最小值显示类型。<br/>`Axis.AxisMinMaxType`:<br/>- `Default`: 0-最大值。<br/>- `MinMax`: 最小值-最大值。<br/>- `Custom`: 自定义最小值最大值。<br/>- `MinMaxAuto`: [since("v3.7.0")]最小值-最大值。自动计算合适的值。<br/>|
|gridIndex|||坐标轴所在的 grid 的索引,默认位于第一个 grid。
|polarIndex|||坐标轴所在的 ploar 的索引,默认位于第一个 polar。
|parallelIndex|||坐标轴所在的 parallel 的索引,默认位于第一个 parallel。
@@ -567,7 +567,7 @@ DataZoom 组件 用于区域缩放,从而能自由关注细节的数据信息
|rangeMode|||取绝对值还是百分比。<br/>`DataZoom.RangeMode`:<br/>- `//Value`: The value type of start and end.取值类型<br/>- `Percent`: 百分比。<br/>|
|start|||数据窗口范围的起始百分比。范围是0 ~ 100。
|end|||数据窗口范围的结束百分比。范围是0 ~ 100。
|minShowNum|1||最小显示数据个数。当DataZoom放大到最大时最小显示的数据个数。
|minShowNum|2||最小显示数据个数。当DataZoom放大到最大时最小显示的数据个数。
|scrollSensitivity|1.1f||缩放区域组件的敏感度。值越高每次缩放所代表的数据越多。
|orient|||布局方式是横还是竖。不仅是布局方式,对于直角坐标系而言,也决定了,缺省情况控制横向数轴还是纵向数轴。<br/>`Orient`:<br/>- `Horizonal`: 水平<br/>- `Vertical`: 垂直<br/>|
|labelStyle|||文本标签格式。 [LabelStyle](#labelstyle)|

View File

@@ -59,7 +59,12 @@ namespace XCharts.Runtime
/// Customize the minimum and maximum.
/// |自定义最小值最大值。
/// </summary>
Custom
Custom,
/// <summary>
/// [since("v3.7.0")]minimum - maximum, automatically calculate the appropriate values.
/// |[since("v3.7.0")]最小值-最大值。自动计算合适的值。
/// </summary>
MinMaxAuto,
}
/// <summary>
/// the position of axis in grid.

View File

@@ -393,7 +393,14 @@ namespace XCharts.Runtime
break;
case Axis.AxisMinMaxType.MinMax:
if (ceilRate != 0)
{
minValue = ChartHelper.GetMinCeilRate(minValue, ceilRate);
maxValue = ChartHelper.GetMaxCeilRate(maxValue, ceilRate);
}
break;
case Axis.AxisMinMaxType.MinMaxAuto:
minValue = needFormat ? ChartHelper.GetMinDivisibleValue(minValue, ceilRate) : minValue;
maxValue = needFormat ? ChartHelper.GetMaxDivisibleValue(maxValue, ceilRate) : maxValue;
break;

View File

@@ -692,8 +692,8 @@ namespace XCharts.Runtime
intvalue = (int)(max * Mathf.Pow(10, count));
}
var pow = Mathf.Pow(10, count);
var value = (max > 0) ? (int)((max * pow + 1)) / pow :
(int)((max * pow - 1)) / pow;
var value = max > 0 ? (int)((max * (pow + 1))) / pow :
(int)((max * (pow - 1))) / pow;
return GetMaxCeilRate(value, ceilRate);
}
if (ceilRate == 0)
@@ -757,8 +757,8 @@ namespace XCharts.Runtime
intvalue = (int)(min * Mathf.Pow(10, count));
}
var pow = Mathf.Pow(10, count);
var value = (min > 0) ? (int)((min * pow + 1)) / pow :
(int)((min * pow - 1)) / pow;
var value = min > 0 ? ((int)(min * (pow - 1))) / pow :
((int)(min * (pow + 1))) / pow;
return GetMinCeilRate(value, ceilRate);
}
if (ceilRate == 0)