mirror of
https://github.com/XCharts-Team/XCharts.git
synced 2026-05-21 07:50:16 +00:00
增加Serie和AxisLabel的showAsPositiveNumber参数将负数数值显示为正数
This commit is contained in:
@@ -270,6 +270,7 @@ namespace XCharts
|
||||
[SerializeField] private bool m_Clip = false;
|
||||
[SerializeField] private bool m_Ignore = false;
|
||||
[SerializeField] private float m_IgnoreValue = 0;
|
||||
[SerializeField] private bool m_ShowAsPositiveNumber = false;
|
||||
[SerializeField] private RadarType m_RadarType = RadarType.Multiple;
|
||||
|
||||
[SerializeField] private List<SerieData> m_Data = new List<SerieData>();
|
||||
@@ -743,6 +744,15 @@ namespace XCharts
|
||||
set { if (PropertyUtility.SetStruct(ref m_Clip, value)) SetVerticesDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// Show negative number as positive number.
|
||||
/// 将负数数值显示为正数。一般和`AxisLabel`的`showAsPositiveNumber`配合使用。仅在折线图和柱状图中有效。
|
||||
/// </summary>
|
||||
public bool showAsPositiveNumber
|
||||
{
|
||||
get { return m_ShowAsPositiveNumber; }
|
||||
set { if (PropertyUtility.SetStruct(ref m_ShowAsPositiveNumber, value)) SetComponentDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// 系列中的数据内容数组。SerieData可以设置1到n维数据。
|
||||
/// </summary>
|
||||
public List<SerieData> data { get { return m_Data; } }
|
||||
@@ -1241,6 +1251,11 @@ namespace XCharts
|
||||
var serieData = showData[index];
|
||||
xValue = serieData.data[0];
|
||||
yVlaue = serieData.data[1];
|
||||
if (showAsPositiveNumber)
|
||||
{
|
||||
xValue = Mathf.Abs(xValue);
|
||||
yVlaue = Mathf.Abs(yVlaue);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -28,6 +28,7 @@ namespace XCharts
|
||||
[SerializeField] private int m_FontSize;
|
||||
[SerializeField] private FontStyle m_FontStyle;
|
||||
[SerializeField] private bool m_ForceENotation = false;
|
||||
[SerializeField] private bool m_ShowAsPositiveNumber = false;
|
||||
[SerializeField] private TextLimit m_TextLimit = new TextLimit();
|
||||
|
||||
/// <summary>
|
||||
@@ -119,6 +120,17 @@ namespace XCharts
|
||||
get { return m_ForceENotation; }
|
||||
set { if (PropertyUtility.SetStruct(ref m_ForceENotation, value)) SetComponentDirty(); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Show negative number as positive number.
|
||||
/// 将负数数值显示为正数。一般和`Serie`的`showAsPositiveNumber`配合使用。
|
||||
/// </summary>
|
||||
public bool showAsPositiveNumber
|
||||
{
|
||||
get { return m_ShowAsPositiveNumber; }
|
||||
set { if (PropertyUtility.SetStruct(ref m_ShowAsPositiveNumber, value)) SetComponentDirty(); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 文本限制。
|
||||
/// </summary>
|
||||
@@ -206,6 +218,10 @@ namespace XCharts
|
||||
|
||||
public string GetFormatterContent(float value, float minValue, float maxValue, bool isLog = false)
|
||||
{
|
||||
if (showAsPositiveNumber && value < 0)
|
||||
{
|
||||
value = Mathf.Abs(value);
|
||||
}
|
||||
if (string.IsNullOrEmpty(m_Formatter))
|
||||
{
|
||||
if (isLog)
|
||||
|
||||
Reference in New Issue
Block a user