优化PieChart支持设置ignoreValue不显示指定数据

This commit is contained in:
monitor1394
2020-05-30 10:27:54 +08:00
parent 36200c7386
commit c08367fdac
6 changed files with 18 additions and 4 deletions

View File

@@ -1,6 +1,8 @@
# 更新日志
* (2020.05.30) 优化`PieChart`支持设置`ignoreValue`不显示指定数据
* (2020.05.30) 修复`RadarChart``Circle`时不绘制`SplitArea`的问题
* (2020.05.30) 优化`RadarChart`在设置`max``0`时可自动刷新最大值
* (2020.05.29) 修复`PieChart`设置`space`时只有一个数据时绘制异常的问题
* (2020.05.27) 修复调用`UpdateDataName()`接口时不会自动刷新的问题

View File

@@ -560,6 +560,8 @@
* `center`中心点坐标。当值为0-1的浮点数时表示百分比。
* `radius`:半径。`radius[0]`为内径,`radius[1]`为外径。当内径大于0时即为圆环图。
* `roundCap`:是否启用圆弧效果。
* `ignore`:是否开启忽略数据。当为 `true` 时,数据值为 `ignoreValue` 时不进行绘制,对应的`Label``Legend`也不会显示。
* `ignoreValue`忽略数据的默认值。默认值默认为0`ignore``true` 才有效。
* `label`:图形上的文本标签 [SerieLabel](#SerieLabel),可用于说明图形的一些数据信息,比如值,名称等。
* `emphasis`:高亮样式 [Emphasis](#Emphasis)。
* `animation`:起始动画 [SerieAnimation](#SerieAnimation)。

View File

@@ -209,6 +209,10 @@ namespace XCharts
ChartEditorHelper.MakeTwoField(ref drawRect, pos.width, m_Radius, "Radius");
EditorGUI.PropertyField(drawRect, m_RoundCap);
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
EditorGUI.PropertyField(drawRect, m_Ignore);
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
EditorGUI.PropertyField(drawRect, m_IgnoreValue);
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
EditorGUI.PropertyField(drawRect, m_ItemStyle);
drawRect.y += EditorGUI.GetPropertyHeight(m_ItemStyle);
EditorGUI.PropertyField(drawRect, m_Label);
@@ -523,7 +527,7 @@ namespace XCharts
height += EditorGUI.GetPropertyHeight(prop.FindPropertyRelative("m_Animation"));
break;
case SerieType.Pie:
height += 9 * EditorGUIUtility.singleLineHeight + 8 * EditorGUIUtility.standardVerticalSpacing;
height += 11 * EditorGUIUtility.singleLineHeight + 10 * EditorGUIUtility.standardVerticalSpacing;
height += EditorGUI.GetPropertyHeight(prop.FindPropertyRelative("m_ItemStyle"));
height += EditorGUI.GetPropertyHeight(prop.FindPropertyRelative("m_Label"));
height += EditorGUI.GetPropertyHeight(prop.FindPropertyRelative("m_Emphasis"));

View File

@@ -80,6 +80,11 @@ namespace XCharts
serieData.labelObject.label.fontStyle = label.fontStyle;
}
public static bool CanShowLabel(Serie serie, SerieData serieData, SerieLabel label, int dimesion)
{
return serie.show && serieData.canShowLabel && !serie.IsIgnoreValue(serieData.GetData(dimesion));
}
public static string GetFormatterContent(Serie serie, SerieData serieData,
float dataValue, float dataTotal, SerieLabel serieLabel = null)
{

View File

@@ -102,6 +102,7 @@ namespace XCharts
case SerieType.Ring:
for (int i = 0; i < serie.data.Count; i++)
{
if (serie.type == SerieType.Pie && serie.IsIgnoreValue(serie.data[i].GetData(1))) continue;
if (string.IsNullOrEmpty(serie.data[i].name))
serieNameList.Add(ChartCached.IntToStr(i));
else if (!serieNameList.Contains(serie.data[i].name))

View File

@@ -201,7 +201,7 @@ namespace XCharts
foreach (var serieData in serie.data)
{
var serieLabel = SerieHelper.GetSerieLabel(serie, serieData);
if (serieLabel.show && serieData.canShowLabel)
if (SerieLabelHelper.CanShowLabel(serie, serieData, serieLabel, 1))
{
int colorIndex = m_LegendRealShowName.IndexOf(serieData.name);
Color color = m_ThemeInfo.GetColor(colorIndex);
@@ -221,7 +221,7 @@ namespace XCharts
foreach (var serieData in serie.data)
{
var serieLabel = SerieHelper.GetSerieLabel(serie, serieData);
if (serieLabel.show && serieData.canShowLabel)
if (SerieLabelHelper.CanShowLabel(serie, serieData, serieLabel, 1))
{
UpdateLabelPostion(serie, serieData);
DrawLabelBackground(vh, serie, serieData);
@@ -342,7 +342,7 @@ namespace XCharts
for (int n = 0; n < data.Count; n++)
{
var serieData = data[n];
if (!serieData.canShowLabel)
if (!serieData.canShowLabel || serie.IsIgnoreValue(serieData.GetData(1)))
{
serieData.SetLabelActive(false);
continue;