From c08367fdac4fad5b103fb480c8b714822845d686 Mon Sep 17 00:00:00 2001 From: monitor1394 Date: Sat, 30 May 2020 10:27:54 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96`PieChart`=E6=94=AF=E6=8C=81?= =?UTF-8?q?=E8=AE=BE=E7=BD=AE`ignoreValue`=E4=B8=8D=E6=98=BE=E7=A4=BA?= =?UTF-8?q?=E6=8C=87=E5=AE=9A=E6=95=B0=E6=8D=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Assets/XCharts/CHANGELOG.md | 2 ++ Assets/XCharts/Documentation/XCharts配置项手册.md | 2 ++ Assets/XCharts/Editor/PropertyDrawers/SerieDrawer.cs | 6 +++++- Assets/XCharts/Runtime/Internal/Helper/SerieLabelHelper.cs | 5 +++++ Assets/XCharts/Runtime/Internal/Helper/SeriesHelper.cs | 1 + Assets/XCharts/Runtime/PieChart.cs | 6 +++--- 6 files changed, 18 insertions(+), 4 deletions(-) diff --git a/Assets/XCharts/CHANGELOG.md b/Assets/XCharts/CHANGELOG.md index d7eca9e4..30ddd524 100644 --- a/Assets/XCharts/CHANGELOG.md +++ b/Assets/XCharts/CHANGELOG.md @@ -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()`接口时不会自动刷新的问题 diff --git a/Assets/XCharts/Documentation/XCharts配置项手册.md b/Assets/XCharts/Documentation/XCharts配置项手册.md index c79ada69..02bea3b4 100644 --- a/Assets/XCharts/Documentation/XCharts配置项手册.md +++ b/Assets/XCharts/Documentation/XCharts配置项手册.md @@ -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)。 diff --git a/Assets/XCharts/Editor/PropertyDrawers/SerieDrawer.cs b/Assets/XCharts/Editor/PropertyDrawers/SerieDrawer.cs index 34526d50..fbaeccc3 100644 --- a/Assets/XCharts/Editor/PropertyDrawers/SerieDrawer.cs +++ b/Assets/XCharts/Editor/PropertyDrawers/SerieDrawer.cs @@ -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")); diff --git a/Assets/XCharts/Runtime/Internal/Helper/SerieLabelHelper.cs b/Assets/XCharts/Runtime/Internal/Helper/SerieLabelHelper.cs index 75da71e6..908c869d 100644 --- a/Assets/XCharts/Runtime/Internal/Helper/SerieLabelHelper.cs +++ b/Assets/XCharts/Runtime/Internal/Helper/SerieLabelHelper.cs @@ -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) { diff --git a/Assets/XCharts/Runtime/Internal/Helper/SeriesHelper.cs b/Assets/XCharts/Runtime/Internal/Helper/SeriesHelper.cs index 155eeaca..db5c5227 100644 --- a/Assets/XCharts/Runtime/Internal/Helper/SeriesHelper.cs +++ b/Assets/XCharts/Runtime/Internal/Helper/SeriesHelper.cs @@ -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)) diff --git a/Assets/XCharts/Runtime/PieChart.cs b/Assets/XCharts/Runtime/PieChart.cs index 37622450..4a6d9714 100644 --- a/Assets/XCharts/Runtime/PieChart.cs +++ b/Assets/XCharts/Runtime/PieChart.cs @@ -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;