mirror of
https://github.com/XCharts-Team/XCharts.git
synced 2026-05-28 12:08:46 +00:00
[optimize][axis] support auto float min-max range
This commit is contained in:
@@ -56,6 +56,7 @@
|
|||||||
|
|
||||||
## master
|
## master
|
||||||
|
|
||||||
|
* (2022.07.07) 优化`Axis`的`minMaxType`指定为`MinMax`时支持精确到小数
|
||||||
* (2022.07.05) 修复`Chart`里有多个坐标系时绘制异常的问题 (#210)
|
* (2022.07.05) 修复`Chart`里有多个坐标系时绘制异常的问题 (#210)
|
||||||
* (2022.07.04) 增加`Settings`的`axisMaxSplitNumber`参数设置`Axis`的最大分隔段数
|
* (2022.07.04) 增加`Settings`的`axisMaxSplitNumber`参数设置`Axis`的最大分隔段数
|
||||||
* (2022.07.04) 修复`Axis`在设置`offset`后`Tick`绘制位置异常的问题 (#209)
|
* (2022.07.04) 修复`Axis`在设置`offset`后`Tick`绘制位置异常的问题 (#209)
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ namespace XCharts.Example
|
|||||||
{
|
{
|
||||||
public int maxCacheDataNumber = 100;
|
public int maxCacheDataNumber = 100;
|
||||||
public float initDataTime = 2;
|
public float initDataTime = 2;
|
||||||
public bool insertDataToHead = true;
|
public bool insertDataToHead = false;
|
||||||
|
|
||||||
private BaseChart chart;
|
private BaseChart chart;
|
||||||
private float updateTime;
|
private float updateTime;
|
||||||
|
|||||||
@@ -89,7 +89,7 @@ namespace XCharts.Runtime
|
|||||||
[SerializeField] protected int m_MaxCache = 0;
|
[SerializeField] protected int m_MaxCache = 0;
|
||||||
[SerializeField] protected float m_LogBase = 10;
|
[SerializeField] protected float m_LogBase = 10;
|
||||||
[SerializeField] protected bool m_LogBaseE = false;
|
[SerializeField] protected bool m_LogBaseE = false;
|
||||||
[SerializeField] protected int m_CeilRate = 0;
|
[SerializeField] protected double m_CeilRate = 0;
|
||||||
[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;
|
||||||
@@ -257,7 +257,7 @@ namespace XCharts.Runtime
|
|||||||
/// The ratio of maximum and minimum values rounded upward. The default is 0, which is automatically calculated.
|
/// The ratio of maximum and minimum values rounded upward. The default is 0, which is automatically calculated.
|
||||||
/// |最大最小值向上取整的倍率。默认为0时自动计算。
|
/// |最大最小值向上取整的倍率。默认为0时自动计算。
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public int ceilRate
|
public double ceilRate
|
||||||
{
|
{
|
||||||
get { return m_CeilRate; }
|
get { return m_CeilRate; }
|
||||||
set { if (PropertyUtil.SetStruct(ref m_CeilRate, value < 0 ? 0 : value)) SetAllDirty(); }
|
set { if (PropertyUtil.SetStruct(ref m_CeilRate, value < 0 ? 0 : value)) SetAllDirty(); }
|
||||||
|
|||||||
@@ -327,7 +327,7 @@ namespace XCharts.Runtime
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="minValue"></param>
|
/// <param name="minValue"></param>
|
||||||
/// <param name="maxValue"></param>
|
/// <param name="maxValue"></param>
|
||||||
public static void AdjustMinMaxValue(Axis axis, ref double minValue, ref double maxValue, bool needFormat, int ceilRate = 0)
|
public static void AdjustMinMaxValue(Axis axis, ref double minValue, ref double maxValue, bool needFormat, double ceilRate = 0)
|
||||||
{
|
{
|
||||||
if (axis.type == Axis.AxisType.Log)
|
if (axis.type == Axis.AxisType.Log)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -103,7 +103,7 @@ namespace XCharts.Runtime
|
|||||||
[SerializeField] private bool m_Indicator = true;
|
[SerializeField] private bool m_Indicator = true;
|
||||||
[SerializeField] private PositionType m_PositionType = PositionType.Vertice;
|
[SerializeField] private PositionType m_PositionType = PositionType.Vertice;
|
||||||
[SerializeField] private float m_IndicatorGap = 10;
|
[SerializeField] private float m_IndicatorGap = 10;
|
||||||
[SerializeField] private int m_CeilRate = 0;
|
[SerializeField] private double m_CeilRate = 0;
|
||||||
[SerializeField] private bool m_IsAxisTooltip;
|
[SerializeField] private bool m_IsAxisTooltip;
|
||||||
[SerializeField] private Color32 m_OutRangeColor = Color.red;
|
[SerializeField] private Color32 m_OutRangeColor = Color.red;
|
||||||
[SerializeField] private bool m_ConnectCenter = false;
|
[SerializeField] private bool m_ConnectCenter = false;
|
||||||
@@ -214,7 +214,7 @@ namespace XCharts.Runtime
|
|||||||
/// The ratio of maximum and minimum values rounded upward. The default is 0, which is automatically calculated.
|
/// The ratio of maximum and minimum values rounded upward. The default is 0, which is automatically calculated.
|
||||||
/// |最大最小值向上取整的倍率。默认为0时自动计算。
|
/// |最大最小值向上取整的倍率。默认为0时自动计算。
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public int ceilRate
|
public double ceilRate
|
||||||
{
|
{
|
||||||
get { return m_CeilRate; }
|
get { return m_CeilRate; }
|
||||||
set { if (PropertyUtil.SetStruct(ref m_CeilRate, value < 0 ? 0 : value)) SetAllDirty(); }
|
set { if (PropertyUtil.SetStruct(ref m_CeilRate, value < 0 ? 0 : value)) SetAllDirty(); }
|
||||||
|
|||||||
@@ -356,20 +356,6 @@ namespace XCharts.Runtime
|
|||||||
var alignment = textStyle.GetAlignment(autoAlignment);
|
var alignment = textStyle.GetAlignment(autoAlignment);
|
||||||
UpdateAnchorAndPivotByTextAlignment(alignment, out anchorMin, out anchorMax, out pivot);
|
UpdateAnchorAndPivotByTextAlignment(alignment, out anchorMin, out anchorMax, out pivot);
|
||||||
var labelObj = AddObject(name, parent, anchorMin, anchorMax, pivot, sizeDelta);
|
var labelObj = AddObject(name, parent, anchorMin, anchorMax, pivot, sizeDelta);
|
||||||
// TODO: 为了兼容旧版本,这里后面版本可以去掉
|
|
||||||
#region temp code
|
|
||||||
var oldText = labelObj.GetComponent<Text>();
|
|
||||||
if (oldText != null)
|
|
||||||
{
|
|
||||||
GameObject.DestroyImmediate(oldText);
|
|
||||||
}
|
|
||||||
var oldImage = labelObj.GetComponent<Image>();
|
|
||||||
if (oldImage != null)
|
|
||||||
{
|
|
||||||
GameObject.DestroyImmediate(oldImage);
|
|
||||||
}
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
var label = GetOrAddComponent<ChartLabel>(labelObj);
|
var label = GetOrAddComponent<ChartLabel>(labelObj);
|
||||||
label.text = AddTextObject("Text", label.gameObject.transform, anchorMin, anchorMax, pivot,
|
label.text = AddTextObject("Text", label.gameObject.transform, anchorMin, anchorMax, pivot,
|
||||||
sizeDelta, textStyle, theme, autoColor, autoAlignment, label.text);
|
sizeDelta, textStyle, theme, autoColor, autoAlignment, label.text);
|
||||||
@@ -624,7 +610,7 @@ namespace XCharts.Runtime
|
|||||||
return (Color32) color;
|
return (Color32) color;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static double GetMaxDivisibleValue(double max, int ceilRate)
|
public static double GetMaxDivisibleValue(double max, double ceilRate)
|
||||||
{
|
{
|
||||||
if (max == 0) return 0;
|
if (max == 0) return 0;
|
||||||
if (max > -1 && max < 1)
|
if (max > -1 && max < 1)
|
||||||
@@ -666,7 +652,7 @@ namespace XCharts.Runtime
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static double GetMinDivisibleValue(double min, int ceilRate)
|
public static double GetMinDivisibleValue(double min, double ceilRate)
|
||||||
{
|
{
|
||||||
if (min == 0) return 0;
|
if (min == 0) return 0;
|
||||||
if (min > -1 && min < 1)
|
if (min > -1 && min < 1)
|
||||||
|
|||||||
@@ -148,7 +148,7 @@ namespace XCharts.Runtime
|
|||||||
|
|
||||||
Axis axis;
|
Axis axis;
|
||||||
Axis relativedAxis;
|
Axis relativedAxis;
|
||||||
var isY = chart.GetSerieGridCoordAxis(serie, out axis, out relativedAxis);
|
chart.GetSerieGridCoordAxis(serie, out axis, out relativedAxis);
|
||||||
|
|
||||||
for (int i = 0; i < count; i++)
|
for (int i = 0; i < count; i++)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -852,8 +852,11 @@ namespace XCharts.Runtime
|
|||||||
public override void ClearVerticesDirty()
|
public override void ClearVerticesDirty()
|
||||||
{
|
{
|
||||||
base.ClearVerticesDirty();
|
base.ClearVerticesDirty();
|
||||||
foreach (var serieData in m_Data)
|
if (!IsPerformanceMode())
|
||||||
serieData.ClearVerticesDirty();
|
{
|
||||||
|
foreach (var serieData in m_Data)
|
||||||
|
serieData.ClearVerticesDirty();
|
||||||
|
}
|
||||||
symbol.ClearVerticesDirty();
|
symbol.ClearVerticesDirty();
|
||||||
lineStyle.ClearVerticesDirty();
|
lineStyle.ClearVerticesDirty();
|
||||||
itemStyle.ClearVerticesDirty();
|
itemStyle.ClearVerticesDirty();
|
||||||
@@ -872,8 +875,11 @@ namespace XCharts.Runtime
|
|||||||
public override void ClearComponentDirty()
|
public override void ClearComponentDirty()
|
||||||
{
|
{
|
||||||
base.ClearComponentDirty();
|
base.ClearComponentDirty();
|
||||||
foreach (var serieData in m_Data)
|
if (!IsPerformanceMode())
|
||||||
serieData.ClearComponentDirty();
|
{
|
||||||
|
foreach (var serieData in m_Data)
|
||||||
|
serieData.ClearComponentDirty();
|
||||||
|
}
|
||||||
symbol.ClearComponentDirty();
|
symbol.ClearComponentDirty();
|
||||||
lineStyle.ClearComponentDirty();
|
lineStyle.ClearComponentDirty();
|
||||||
itemStyle.ClearComponentDirty();
|
itemStyle.ClearComponentDirty();
|
||||||
@@ -900,6 +906,8 @@ namespace XCharts.Runtime
|
|||||||
|
|
||||||
private bool AnySerieDataVerticesDirty()
|
private bool AnySerieDataVerticesDirty()
|
||||||
{
|
{
|
||||||
|
if (IsPerformanceMode())
|
||||||
|
return false;
|
||||||
if (this is ISimplifiedSerie)
|
if (this is ISimplifiedSerie)
|
||||||
return false;
|
return false;
|
||||||
foreach (var serieData in m_Data)
|
foreach (var serieData in m_Data)
|
||||||
@@ -909,6 +917,8 @@ namespace XCharts.Runtime
|
|||||||
|
|
||||||
private bool AnySerieDataComponentDirty()
|
private bool AnySerieDataComponentDirty()
|
||||||
{
|
{
|
||||||
|
if (IsPerformanceMode())
|
||||||
|
return false;
|
||||||
if (this is ISimplifiedSerie)
|
if (this is ISimplifiedSerie)
|
||||||
return false;
|
return false;
|
||||||
foreach (var serieData in m_Data)
|
foreach (var serieData in m_Data)
|
||||||
@@ -1650,7 +1660,7 @@ namespace XCharts.Runtime
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public bool IsPerformanceMode()
|
public bool IsPerformanceMode()
|
||||||
{
|
{
|
||||||
return m_Large && m_Data.Count > m_LargeThreshold;
|
return m_Large && m_Data.Count >= m_LargeThreshold;
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool IsLegendName(string legendName)
|
public bool IsLegendName(string legendName)
|
||||||
|
|||||||
@@ -573,7 +573,7 @@ namespace XCharts.Runtime
|
|||||||
/// <param name="dimension"></param>
|
/// <param name="dimension"></param>
|
||||||
/// <param name="dataZoom"></param>
|
/// <param name="dataZoom"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public static void UpdateMinMaxData(Serie serie, int dimension, int ceilRate = 0, DataZoom dataZoom = null)
|
public static void UpdateMinMaxData(Serie serie, int dimension, double ceilRate = 0, DataZoom dataZoom = null)
|
||||||
{
|
{
|
||||||
double min = 0, max = 0;
|
double min = 0, max = 0;
|
||||||
GetMinMaxData(serie, dimension, out min, out max, dataZoom);
|
GetMinMaxData(serie, dimension, out min, out max, dataZoom);
|
||||||
@@ -589,7 +589,7 @@ namespace XCharts.Runtime
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void GetAllMinMaxData(Serie serie, int ceilRate = 0, DataZoom dataZoom = null)
|
public static void GetAllMinMaxData(Serie serie, double ceilRate = 0, DataZoom dataZoom = null)
|
||||||
{
|
{
|
||||||
double min = 0, max = 0;
|
double min = 0, max = 0;
|
||||||
GetMinMaxData(serie, out min, out max, dataZoom);
|
GetMinMaxData(serie, out min, out max, dataZoom);
|
||||||
|
|||||||
Reference in New Issue
Block a user