From f0e94d35b6818aa675aa3e0489780ff5fd3477ac Mon Sep 17 00:00:00 2001 From: monitor1394 Date: Tue, 21 Dec 2021 07:01:54 +0800 Subject: [PATCH] fixed emphasis label --- Assets/XCharts/CHANGELOG-EN.md | 1 + Assets/XCharts/CHANGELOG.md | 1 + Assets/XCharts/Runtime/Component/Sub/MarkLine.cs | 2 -- Assets/XCharts/Runtime/Helper/SerieHelper.cs | 8 ++++++++ Assets/XCharts/Runtime/Internal/BaseChart.cs | 3 ++- 5 files changed, 12 insertions(+), 3 deletions(-) diff --git a/Assets/XCharts/CHANGELOG-EN.md b/Assets/XCharts/CHANGELOG-EN.md index 48204e00..2d8aac9e 100644 --- a/Assets/XCharts/CHANGELOG-EN.md +++ b/Assets/XCharts/CHANGELOG-EN.md @@ -41,6 +41,7 @@ ## branch-2.0 +* (2021.12.21) Fixed `Emphasis` dont work * (2021.12.17) Fixed `MarkLine` does not auto refresh label active when serie hide #178 * (2021.12.10) Improved `Radar`'s `AxisLine` and `SplitLine` to be controlled separately * (2021.12.08) Fixed y axis does not refresh when serie hidden diff --git a/Assets/XCharts/CHANGELOG.md b/Assets/XCharts/CHANGELOG.md index ca4743d1..0530e204 100644 --- a/Assets/XCharts/CHANGELOG.md +++ b/Assets/XCharts/CHANGELOG.md @@ -41,6 +41,7 @@ ## branch-2.0 +* (2021.12.21) 修复`Emphasis`不生效的问题 * (2021.12.17) 修复`MarkLine`在运行时`Label`不自动刷新显示隐藏的问题 #178 * (2021.12.10) 完善`Radar`的`AxisLine`和`SplitLine`可单独控制 * (2021.12.08) 修复`Serie`隐藏后`Y`轴最大值不刷新的问题 diff --git a/Assets/XCharts/Runtime/Component/Sub/MarkLine.cs b/Assets/XCharts/Runtime/Component/Sub/MarkLine.cs index 5d433050..915104aa 100644 --- a/Assets/XCharts/Runtime/Component/Sub/MarkLine.cs +++ b/Assets/XCharts/Runtime/Component/Sub/MarkLine.cs @@ -262,7 +262,6 @@ internal class MarkLineHandler : IComponentHandler { public CoordinateChart chart; private GameObject m_MarkLineLabelRoot; - private bool m_RefreshLabel = false; public MarkLineHandler(CoordinateChart chart) { @@ -515,7 +514,6 @@ private void DrawMakLineData(VertexHelper vh, MarkLineData data, SerieAnimation data.runtimeCurrentEndPosition = ep; if (sp != Vector3.zero || ep != Vector3.zero) { - m_RefreshLabel = true; chart.ClampInChart(ref sp); chart.ClampInChart(ref ep); var theme = chart.theme.axis; diff --git a/Assets/XCharts/Runtime/Helper/SerieHelper.cs b/Assets/XCharts/Runtime/Helper/SerieHelper.cs index 68b55962..a4e8184a 100644 --- a/Assets/XCharts/Runtime/Helper/SerieHelper.cs +++ b/Assets/XCharts/Runtime/Helper/SerieHelper.cs @@ -431,6 +431,14 @@ public static SerieLabel GetSerieLabel(Serie serie, SerieData serieData, bool hi } } + public static SerieLabel GetSerieEmphasisLabel(Serie serie, SerieData serieData) + { + if (!serie.IsPerformanceMode() && serieData.enableEmphasis && serieData.emphasis.show) + return serieData.emphasis.label; + else if (serie.emphasis.show) return serie.emphasis.label; + else return null; + } + public static IconStyle GetIconStyle(Serie serie, SerieData serieData) { if (serieData.enableIconStyle) return serieData.iconStyle; diff --git a/Assets/XCharts/Runtime/Internal/BaseChart.cs b/Assets/XCharts/Runtime/Internal/BaseChart.cs index 6f9b2cf0..7e6f6eb8 100644 --- a/Assets/XCharts/Runtime/Internal/BaseChart.cs +++ b/Assets/XCharts/Runtime/Internal/BaseChart.cs @@ -544,9 +544,10 @@ protected void AddSerieLabel(Serie serie, SerieData serieData, ref int count) if (m_SerieLabelRoot == null) return; if (count == -1) count = serie.dataCount; var serieLabel = SerieHelper.GetSerieLabel(serie, serieData); + var serieEmphasisLable = SerieHelper.GetSerieEmphasisLabel(serie, serieData); var iconStyle = SerieHelper.GetIconStyle(serie, serieData); if (serie.IsPerformanceMode()) return; - if (!serieLabel.show && !iconStyle.show) return; + if (!serieLabel.show && (serieEmphasisLable == null || !serieEmphasisLable.show) && !iconStyle.show) return; if (serie.animation.enable && serie.animation.HasFadeOut()) return; var textName = ChartCached.GetSerieLabelName(s_SerieLabelObjectName, serie.index, serieData.index); var color = Color.grey;