From 01a49de37301fc21afd9ec501d9cae69373bc07c Mon Sep 17 00:00:00 2001 From: monitor1394 Date: Wed, 9 Aug 2023 13:27:03 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0`Axis`=E5=8F=AF=E9=80=9A?= =?UTF-8?q?=E8=BF=87=E8=AE=BE=E7=BD=AE`IconStyle`=E7=9A=84`color`=E4=B8=BA?= =?UTF-8?q?`clear`=E6=9D=A5=E5=AE=9E=E7=8E=B0=E5=8A=A8=E6=80=81=E5=9B=BE?= =?UTF-8?q?=E6=A0=87=E9=A2=9C=E8=89=B2=E7=9A=84=E6=94=AF=E6=8C=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Documentation~/zh/changelog.md | 1 + Runtime/Component/Axis/AxisHandler.cs | 3 ++- Runtime/Internal/Object/ChartLabel.cs | 4 ++-- Runtime/Internal/Utilities/ChartHelper.cs | 4 ++-- 4 files changed, 7 insertions(+), 5 deletions(-) diff --git a/Documentation~/zh/changelog.md b/Documentation~/zh/changelog.md index 11354b4a..bd03c2f9 100644 --- a/Documentation~/zh/changelog.md +++ b/Documentation~/zh/changelog.md @@ -76,6 +76,7 @@ slug: /changelog 日志详情: +* (2023.08.09) 增加`Axis`可通过设置`IconStyle`的`color`为`clear`来实现动态图标颜色的支持 * (2023.08.08) 增加`Pie`对`LabelLine`的`lineEndX`的支持 * (2023.08.05) 整理`Examples`的代码,删除不必要的用例 * (2023.08.04) 增加`LabelLine`的`lineEndX`可设置引导线固定X位置的支持 diff --git a/Runtime/Component/Axis/AxisHandler.cs b/Runtime/Component/Axis/AxisHandler.cs index 0fbded80..4651da8a 100644 --- a/Runtime/Component/Axis/AxisHandler.cs +++ b/Runtime/Component/Axis/AxisHandler.cs @@ -387,7 +387,8 @@ namespace XCharts new Vector2(textWidth, textHeight), axis, chart.theme.axis, labelName, Color.clear, - defaultAlignment); + defaultAlignment, + chart.theme.GetColor(i)); if (i == 0) axis.axisLabel.SetRelatedText(label.text, labelWidth); diff --git a/Runtime/Internal/Object/ChartLabel.cs b/Runtime/Internal/Object/ChartLabel.cs index b6dbe2e6..33d6e3bd 100644 --- a/Runtime/Internal/Object/ChartLabel.cs +++ b/Runtime/Internal/Object/ChartLabel.cs @@ -130,7 +130,7 @@ namespace XCharts.Runtime if (m_IconRect != null) m_IconRect.sizeDelta = new Vector3(width, height); } - public void UpdateIcon(IconStyle iconStyle, Sprite sprite = null) + public void UpdateIcon(IconStyle iconStyle, Sprite sprite = null, Color color = default(Color)) { if (m_IconImage == null || iconStyle == null) return; @@ -139,7 +139,7 @@ namespace XCharts.Runtime if (iconStyle.show) { m_IconImage.sprite = sprite == null ? iconStyle.sprite : sprite; - m_IconImage.color = iconStyle.color; + m_IconImage.color = ChartHelper.IsClearColor(iconStyle.color) ? color : iconStyle.color; m_IconImage.type = iconStyle.type; m_IconRect.sizeDelta = new Vector2(iconStyle.width, iconStyle.height); m_IconOffest = iconStyle.offset; diff --git a/Runtime/Internal/Utilities/ChartHelper.cs b/Runtime/Internal/Utilities/ChartHelper.cs index da84ae41..789117d1 100644 --- a/Runtime/Internal/Utilities/ChartHelper.cs +++ b/Runtime/Internal/Utilities/ChartHelper.cs @@ -370,12 +370,12 @@ namespace XCharts.Runtime public static ChartLabel AddAxisLabelObject(int total, int index, string name, Transform parent, Vector2 sizeDelta, Axis axis, ComponentTheme theme, - string content, Color autoColor, TextAnchor autoAlignment = TextAnchor.MiddleCenter) + string content, Color autoColor, TextAnchor autoAlignment = TextAnchor.MiddleCenter, Color32 iconDefaultColor = default(Color32)) { var textStyle = axis.axisLabel.textStyle; var label = AddChartLabel(name, parent, axis.axisLabel, theme, content, autoColor, autoAlignment); var labelShow = axis.IsNeedShowLabel(index, total); - label.UpdateIcon(axis.axisLabel.icon, axis.GetIcon(index)); + label.UpdateIcon(axis.axisLabel.icon, axis.GetIcon(index), iconDefaultColor); label.text.SetActive(labelShow); return label; }