mirror of
https://github.com/XCharts-Team/XCharts.git
synced 2026-05-24 09:50:15 +00:00
增加Serie和AxisLabel的showAsPositiveNumber参数将负数数值显示为正数
This commit is contained in:
@@ -1,6 +1,7 @@
|
|||||||
|
|
||||||
# 更新日志
|
# 更新日志
|
||||||
|
|
||||||
|
* (2020.04.19) 增加`Serie`和`AxisLabel`的`showAsPositiveNumber`参数将负数数值显示为正数
|
||||||
* (2020.04.18) 增加`Covert XY Axis`互换XY轴配置
|
* (2020.04.18) 增加`Covert XY Axis`互换XY轴配置
|
||||||
* (2020.04.17) 增加`Axis`可通过`inverse`参数设置坐标轴反转
|
* (2020.04.17) 增加`Axis`可通过`inverse`参数设置坐标轴反转
|
||||||
* (2020.04.16) 修复`Check warning`在`Unity2019.3`上的显示问题
|
* (2020.04.16) 修复`Check warning`在`Unity2019.3`上的显示问题
|
||||||
|
|||||||
@@ -470,6 +470,7 @@
|
|||||||
* `clip`:是否裁剪超出坐标系部分的图形。
|
* `clip`:是否裁剪超出坐标系部分的图形。
|
||||||
* `ignore`:是否开启忽略数据。当为 `true` 时,数据值为 `ignoreValue` 时不进行绘制。
|
* `ignore`:是否开启忽略数据。当为 `true` 时,数据值为 `ignoreValue` 时不进行绘制。
|
||||||
* `ignoreValue`:忽略数据的默认值。默认值默认为0,当 `ignore` 为 `true` 才有效。
|
* `ignoreValue`:忽略数据的默认值。默认值默认为0,当 `ignore` 为 `true` 才有效。
|
||||||
|
* `showAsPositiveNumber`:将负数数值显示为正数。一般和`AxisLabel`的`showAsPositiveNumber`配合使用。仅在折线图和柱状图中有效。
|
||||||
* `areaStyle`:区域填充样式 [AreaStyle](#AreaStyle)。
|
* `areaStyle`:区域填充样式 [AreaStyle](#AreaStyle)。
|
||||||
* `symbol`:标记的图形 [SerieSymbol](#SerieSymbol)。
|
* `symbol`:标记的图形 [SerieSymbol](#SerieSymbol)。
|
||||||
* `lineType`:折线图样式类型。支持以下十种类型:
|
* `lineType`:折线图样式类型。支持以下十种类型:
|
||||||
@@ -515,6 +516,7 @@
|
|||||||
* `clip`:是否裁剪超出坐标系部分的图形。
|
* `clip`:是否裁剪超出坐标系部分的图形。
|
||||||
* `ignore`:是否开启忽略数据。当为 `true` 时,数据值为 `ignoreValue` 时不进行绘制。
|
* `ignore`:是否开启忽略数据。当为 `true` 时,数据值为 `ignoreValue` 时不进行绘制。
|
||||||
* `ignoreValue`:忽略数据的默认值。默认值默认为0,当 `ignore` 为 `true` 才有效。
|
* `ignoreValue`:忽略数据的默认值。默认值默认为0,当 `ignore` 为 `true` 才有效。
|
||||||
|
* `showAsPositiveNumber`:将负数数值显示为正数。一般和`AxisLabel`的`showAsPositiveNumber`配合使用。仅在折线图和柱状图中有效。
|
||||||
* `symbol`:标记的图形 [SerieSymbol](#SerieSymbol)。
|
* `symbol`:标记的图形 [SerieSymbol](#SerieSymbol)。
|
||||||
* `itemStyle`:柱条样式 [ItemStyle](#ItemStyle)。
|
* `itemStyle`:柱条样式 [ItemStyle](#ItemStyle)。
|
||||||
* `areaStyle`:区域填充样式 [AreaStyle](#AreaStyle)。
|
* `areaStyle`:区域填充样式 [AreaStyle](#AreaStyle)。
|
||||||
@@ -682,6 +684,7 @@
|
|||||||
* `fontStyle`:文字字体的风格。
|
* `fontStyle`:文字字体的风格。
|
||||||
* `formatter`:图例内容字符串模版格式器。支持用 \n 换行。模板变量为图例名称 {value},支持{value:f0},{value:f1},{value:f2}。
|
* `formatter`:图例内容字符串模版格式器。支持用 \n 换行。模板变量为图例名称 {value},支持{value:f0},{value:f1},{value:f2}。
|
||||||
* `forceENotation`:是否强制使用科学计数法格式化显示数值。默认为false,当小数精度大于3时才采用科学计数法。
|
* `forceENotation`:是否强制使用科学计数法格式化显示数值。默认为false,当小数精度大于3时才采用科学计数法。
|
||||||
|
* `showAsPositiveNumber`:将负数数值显示为正数。一般和`Serie`的`showAsPositiveNumber`配合使用。
|
||||||
* `textLimit`:文本自适应 [TextLimit](#TextLimit)。只在类目轴中有效。
|
* `textLimit`:文本自适应 [TextLimit](#TextLimit)。只在类目轴中有效。
|
||||||
|
|
||||||
## `AxisLine`
|
## `AxisLine`
|
||||||
|
|||||||
@@ -30,6 +30,7 @@ namespace XCharts
|
|||||||
SerializedProperty m_FontSize = prop.FindPropertyRelative("m_FontSize");
|
SerializedProperty m_FontSize = prop.FindPropertyRelative("m_FontSize");
|
||||||
SerializedProperty m_FontStyle = prop.FindPropertyRelative("m_FontStyle");
|
SerializedProperty m_FontStyle = prop.FindPropertyRelative("m_FontStyle");
|
||||||
SerializedProperty m_ForceENotation = prop.FindPropertyRelative("m_ForceENotation");
|
SerializedProperty m_ForceENotation = prop.FindPropertyRelative("m_ForceENotation");
|
||||||
|
SerializedProperty m_ShowAsPositiveNumber = prop.FindPropertyRelative("m_ShowAsPositiveNumber");
|
||||||
SerializedProperty m_TextLimit = prop.FindPropertyRelative("m_TextLimit");
|
SerializedProperty m_TextLimit = prop.FindPropertyRelative("m_TextLimit");
|
||||||
|
|
||||||
ChartEditorHelper.MakeFoldout(ref drawRect, ref m_AxisLabelToggle, prop, "Axis Label", show, false);
|
ChartEditorHelper.MakeFoldout(ref drawRect, ref m_AxisLabelToggle, prop, "Axis Label", show, false);
|
||||||
@@ -55,6 +56,8 @@ namespace XCharts
|
|||||||
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||||
EditorGUI.PropertyField(drawRect, m_ForceENotation);
|
EditorGUI.PropertyField(drawRect, m_ForceENotation);
|
||||||
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||||
|
EditorGUI.PropertyField(drawRect, m_ShowAsPositiveNumber);
|
||||||
|
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||||
EditorGUI.PropertyField(drawRect, m_TextLimit);
|
EditorGUI.PropertyField(drawRect, m_TextLimit);
|
||||||
drawRect.y += EditorGUI.GetPropertyHeight(m_TextLimit);
|
drawRect.y += EditorGUI.GetPropertyHeight(m_TextLimit);
|
||||||
--EditorGUI.indentLevel;
|
--EditorGUI.indentLevel;
|
||||||
@@ -66,7 +69,7 @@ namespace XCharts
|
|||||||
float height = 0;
|
float height = 0;
|
||||||
if (ChartEditorHelper.IsToggle(m_AxisLabelToggle, prop))
|
if (ChartEditorHelper.IsToggle(m_AxisLabelToggle, prop))
|
||||||
{
|
{
|
||||||
height += 10 * EditorGUIUtility.singleLineHeight + 9 * EditorGUIUtility.standardVerticalSpacing;
|
height += 11 * EditorGUIUtility.singleLineHeight + 10 * EditorGUIUtility.standardVerticalSpacing;
|
||||||
height += EditorGUI.GetPropertyHeight(prop.FindPropertyRelative("m_TextLimit"));
|
height += EditorGUI.GetPropertyHeight(prop.FindPropertyRelative("m_TextLimit"));
|
||||||
}
|
}
|
||||||
return height;
|
return height;
|
||||||
|
|||||||
@@ -74,6 +74,7 @@ namespace XCharts
|
|||||||
SerializedProperty m_Clip = prop.FindPropertyRelative("m_Clip");
|
SerializedProperty m_Clip = prop.FindPropertyRelative("m_Clip");
|
||||||
SerializedProperty m_Ignore = prop.FindPropertyRelative("m_Ignore");
|
SerializedProperty m_Ignore = prop.FindPropertyRelative("m_Ignore");
|
||||||
SerializedProperty m_IgnoreValue = prop.FindPropertyRelative("m_IgnoreValue");
|
SerializedProperty m_IgnoreValue = prop.FindPropertyRelative("m_IgnoreValue");
|
||||||
|
SerializedProperty m_ShowAsPositiveNumber = prop.FindPropertyRelative("m_ShowAsPositiveNumber");
|
||||||
SerializedProperty m_Datas = prop.FindPropertyRelative("m_Data");
|
SerializedProperty m_Datas = prop.FindPropertyRelative("m_Data");
|
||||||
|
|
||||||
int index = InitToggle(prop);
|
int index = InitToggle(prop);
|
||||||
@@ -131,6 +132,8 @@ namespace XCharts
|
|||||||
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||||
EditorGUI.PropertyField(drawRect, m_IgnoreValue);
|
EditorGUI.PropertyField(drawRect, m_IgnoreValue);
|
||||||
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||||
|
EditorGUI.PropertyField(drawRect, m_ShowAsPositiveNumber);
|
||||||
|
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||||
EditorGUI.PropertyField(drawRect, m_Symbol);
|
EditorGUI.PropertyField(drawRect, m_Symbol);
|
||||||
drawRect.y += EditorGUI.GetPropertyHeight(m_Symbol);
|
drawRect.y += EditorGUI.GetPropertyHeight(m_Symbol);
|
||||||
EditorGUI.PropertyField(drawRect, m_LineStyle);
|
EditorGUI.PropertyField(drawRect, m_LineStyle);
|
||||||
@@ -178,6 +181,8 @@ namespace XCharts
|
|||||||
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||||
EditorGUI.PropertyField(drawRect, m_IgnoreValue);
|
EditorGUI.PropertyField(drawRect, m_IgnoreValue);
|
||||||
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||||
|
EditorGUI.PropertyField(drawRect, m_ShowAsPositiveNumber);
|
||||||
|
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||||
EditorGUI.PropertyField(drawRect, m_ItemStyle);
|
EditorGUI.PropertyField(drawRect, m_ItemStyle);
|
||||||
drawRect.y += EditorGUI.GetPropertyHeight(m_ItemStyle);
|
drawRect.y += EditorGUI.GetPropertyHeight(m_ItemStyle);
|
||||||
EditorGUI.PropertyField(drawRect, m_Label);
|
EditorGUI.PropertyField(drawRect, m_Label);
|
||||||
@@ -316,8 +321,8 @@ namespace XCharts
|
|||||||
var gap = 2;
|
var gap = 2;
|
||||||
var namegap = 3;
|
var namegap = 3;
|
||||||
#else
|
#else
|
||||||
var gap = 0;
|
var gap = 0;
|
||||||
var namegap = 0;
|
var namegap = 0;
|
||||||
#endif
|
#endif
|
||||||
EditorGUI.PropertyField(new Rect(drawRect.x, drawRect.y, pos.width - 2 * nameWid - 2, pos.height), m_DataDimension);
|
EditorGUI.PropertyField(new Rect(drawRect.x, drawRect.y, pos.width - 2 * nameWid - 2, pos.height), m_DataDimension);
|
||||||
var nameRect = new Rect(pos.width - 2 * nameWid + 14 + gap, drawRect.y, nameWid - gap, pos.height);
|
var nameRect = new Rect(pos.width - 2 * nameWid + 14 + gap, drawRect.y, nameWid - gap, pos.height);
|
||||||
@@ -490,7 +495,7 @@ namespace XCharts
|
|||||||
switch (serieType)
|
switch (serieType)
|
||||||
{
|
{
|
||||||
case SerieType.Line:
|
case SerieType.Line:
|
||||||
height += 16 * EditorGUIUtility.singleLineHeight + 15 * EditorGUIUtility.standardVerticalSpacing;
|
height += 17 * EditorGUIUtility.singleLineHeight + 16 * EditorGUIUtility.standardVerticalSpacing;
|
||||||
height += EditorGUI.GetPropertyHeight(prop.FindPropertyRelative("m_Symbol"));
|
height += EditorGUI.GetPropertyHeight(prop.FindPropertyRelative("m_Symbol"));
|
||||||
height += EditorGUI.GetPropertyHeight(prop.FindPropertyRelative("m_LineStyle"));
|
height += EditorGUI.GetPropertyHeight(prop.FindPropertyRelative("m_LineStyle"));
|
||||||
height += EditorGUI.GetPropertyHeight(prop.FindPropertyRelative("m_LineArrow"));
|
height += EditorGUI.GetPropertyHeight(prop.FindPropertyRelative("m_LineArrow"));
|
||||||
@@ -501,7 +506,7 @@ namespace XCharts
|
|||||||
height += EditorGUI.GetPropertyHeight(prop.FindPropertyRelative("m_Animation"));
|
height += EditorGUI.GetPropertyHeight(prop.FindPropertyRelative("m_Animation"));
|
||||||
break;
|
break;
|
||||||
case SerieType.Bar:
|
case SerieType.Bar:
|
||||||
height += 18 * EditorGUIUtility.singleLineHeight + 17 * EditorGUIUtility.standardVerticalSpacing;
|
height += 19 * EditorGUIUtility.singleLineHeight + 18 * EditorGUIUtility.standardVerticalSpacing;
|
||||||
height += EditorGUI.GetPropertyHeight(prop.FindPropertyRelative("m_ItemStyle"));
|
height += EditorGUI.GetPropertyHeight(prop.FindPropertyRelative("m_ItemStyle"));
|
||||||
height += EditorGUI.GetPropertyHeight(prop.FindPropertyRelative("m_Label"));
|
height += EditorGUI.GetPropertyHeight(prop.FindPropertyRelative("m_Label"));
|
||||||
height += EditorGUI.GetPropertyHeight(prop.FindPropertyRelative("m_Emphasis"));
|
height += EditorGUI.GetPropertyHeight(prop.FindPropertyRelative("m_Emphasis"));
|
||||||
|
|||||||
@@ -270,6 +270,7 @@ namespace XCharts
|
|||||||
[SerializeField] private bool m_Clip = false;
|
[SerializeField] private bool m_Clip = false;
|
||||||
[SerializeField] private bool m_Ignore = false;
|
[SerializeField] private bool m_Ignore = false;
|
||||||
[SerializeField] private float m_IgnoreValue = 0;
|
[SerializeField] private float m_IgnoreValue = 0;
|
||||||
|
[SerializeField] private bool m_ShowAsPositiveNumber = false;
|
||||||
[SerializeField] private RadarType m_RadarType = RadarType.Multiple;
|
[SerializeField] private RadarType m_RadarType = RadarType.Multiple;
|
||||||
|
|
||||||
[SerializeField] private List<SerieData> m_Data = new List<SerieData>();
|
[SerializeField] private List<SerieData> m_Data = new List<SerieData>();
|
||||||
@@ -743,6 +744,15 @@ namespace XCharts
|
|||||||
set { if (PropertyUtility.SetStruct(ref m_Clip, value)) SetVerticesDirty(); }
|
set { if (PropertyUtility.SetStruct(ref m_Clip, value)) SetVerticesDirty(); }
|
||||||
}
|
}
|
||||||
/// <summary>
|
/// <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维数据。
|
/// 系列中的数据内容数组。SerieData可以设置1到n维数据。
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public List<SerieData> data { get { return m_Data; } }
|
public List<SerieData> data { get { return m_Data; } }
|
||||||
@@ -1241,6 +1251,11 @@ namespace XCharts
|
|||||||
var serieData = showData[index];
|
var serieData = showData[index];
|
||||||
xValue = serieData.data[0];
|
xValue = serieData.data[0];
|
||||||
yVlaue = serieData.data[1];
|
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 int m_FontSize;
|
||||||
[SerializeField] private FontStyle m_FontStyle;
|
[SerializeField] private FontStyle m_FontStyle;
|
||||||
[SerializeField] private bool m_ForceENotation = false;
|
[SerializeField] private bool m_ForceENotation = false;
|
||||||
|
[SerializeField] private bool m_ShowAsPositiveNumber = false;
|
||||||
[SerializeField] private TextLimit m_TextLimit = new TextLimit();
|
[SerializeField] private TextLimit m_TextLimit = new TextLimit();
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -119,6 +120,17 @@ namespace XCharts
|
|||||||
get { return m_ForceENotation; }
|
get { return m_ForceENotation; }
|
||||||
set { if (PropertyUtility.SetStruct(ref m_ForceENotation, value)) SetComponentDirty(); }
|
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>
|
||||||
/// 文本限制。
|
/// 文本限制。
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -206,6 +218,10 @@ namespace XCharts
|
|||||||
|
|
||||||
public string GetFormatterContent(float value, float minValue, float maxValue, bool isLog = false)
|
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 (string.IsNullOrEmpty(m_Formatter))
|
||||||
{
|
{
|
||||||
if (isLog)
|
if (isLog)
|
||||||
|
|||||||
Reference in New Issue
Block a user