From d0448a5b1142287cd5499544d49db01e256dac69 Mon Sep 17 00:00:00 2001 From: monitor1394 Date: Thu, 18 Jan 2024 22:41:32 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D`Animation`=E7=9A=84`type`?= =?UTF-8?q?=E4=BB=A3=E7=A0=81=E5=8A=A8=E6=80=81=E4=BF=AE=E6=94=B9=E6=97=A0?= =?UTF-8?q?=E6=95=88=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Documentation~/zh/changelog.md | 1 + Runtime/Component/Animation/AnimationStyle.cs | 13 ++++++++++++- Runtime/Serie/Serie.cs | 4 ++-- 3 files changed, 15 insertions(+), 3 deletions(-) diff --git a/Documentation~/zh/changelog.md b/Documentation~/zh/changelog.md index 4afbc4ae..b0501c50 100644 --- a/Documentation~/zh/changelog.md +++ b/Documentation~/zh/changelog.md @@ -70,6 +70,7 @@ slug: /changelog ## master +* (2024.01.18) 修复`Animation`的`type`代码动态修改无效的问题 * (2024.01.13) 增加`Chart`的更多快捷创建图表菜单 * (2024.01.12) 屏蔽`Chart`的`Init()`接口,动态创建图表不再需要调用 * (2024.01.09) 增加`Background`的`borderStyle`,给图表默认设置圆角 diff --git a/Runtime/Component/Animation/AnimationStyle.cs b/Runtime/Component/Animation/AnimationStyle.cs index 4ae085a4..eb52aaa2 100644 --- a/Runtime/Component/Animation/AnimationStyle.cs +++ b/Runtime/Component/Animation/AnimationStyle.cs @@ -86,7 +86,18 @@ namespace XCharts.Runtime /// The type of animation. /// ||动画类型。 /// - public AnimationType type { get { return m_Type; } set { m_Type = value; } } + public AnimationType type + { + get { return m_Type; } + set + { + m_Type = value; + if (m_Type != AnimationType.Default) + { + context.type = m_Type; + } + } + } /// /// Whether to set graphic number threshold to animation. Animation will be disabled when graphic number is larger than threshold. /// ||是否开启动画的阈值,当单个系列显示的图形数量大于这个阈值时会关闭动画。 diff --git a/Runtime/Serie/Serie.cs b/Runtime/Serie/Serie.cs index 7b45d87c..cbfe1f88 100644 --- a/Runtime/Serie/Serie.cs +++ b/Runtime/Serie/Serie.cs @@ -1862,7 +1862,7 @@ namespace XCharts.Runtime serieData.context.highlight = flag; } - public float GetBarWidth(float categoryWidth, int barCount = 0) + public float GetBarWidth(float categoryWidth, int barCount = 0, float defaultRate = 0.6f) { var realWidth = 0f; if (categoryWidth < 2) @@ -1871,7 +1871,7 @@ namespace XCharts.Runtime } else if (m_BarWidth == 0) { - var width = ChartHelper.GetActualValue(0.6f, categoryWidth); + var width = ChartHelper.GetActualValue(defaultRate, categoryWidth); if (barCount == 0) realWidth = width < 1 ? categoryWidth : width; else