From 4ad450572063366067d112782f46b9c261e28aac Mon Sep 17 00:00:00 2001 From: monitor1394 Date: Tue, 18 Mar 2025 08:18:22 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0`Bar`=E5=8F=AF=E6=B7=BB?= =?UTF-8?q?=E5=8A=A0`TitleStyle`=E7=BB=84=E4=BB=B6=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/Serie/Bar/Bar.cs | 6 +++--- Runtime/Serie/Bar/BarHandler.cs | 9 +++++++++ 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/Documentation~/zh/changelog.md b/Documentation~/zh/changelog.md index 18d8d109..501eab79 100644 --- a/Documentation~/zh/changelog.md +++ b/Documentation~/zh/changelog.md @@ -80,6 +80,7 @@ slug: /changelog ## master +* (2025.03.18) 增加`Bar`可添加`TitleStyle`组件支持 * (2025.03.18) 增加`LabelStyle`的`fixedX`和`fixedY`可固定label的坐标 * (2025.03.17) 增加`ItemStyle`的`backgroundGap`可设置数据项背景间隙 diff --git a/Runtime/Serie/Bar/Bar.cs b/Runtime/Serie/Bar/Bar.cs index aad83f37..31e85d31 100644 --- a/Runtime/Serie/Bar/Bar.cs +++ b/Runtime/Serie/Bar/Bar.cs @@ -8,13 +8,13 @@ namespace XCharts.Runtime [CoordOptions(typeof(GridCoord), typeof(PolarCoord))] [DefaultAnimation(AnimationType.BottomToTop)] [DefaultTooltip(Tooltip.Type.Shadow, Tooltip.Trigger.Axis)] - [SerieComponent(typeof(LabelStyle), typeof(EmphasisStyle), typeof(BlurStyle), typeof(SelectStyle))] - [SerieDataComponent(typeof(ItemStyle), typeof(LabelStyle), typeof(EmphasisStyle), typeof(BlurStyle), typeof(SelectStyle))] + [SerieComponent(typeof(TitleStyle), typeof(LabelStyle), typeof(EmphasisStyle), typeof(BlurStyle), typeof(SelectStyle))] + [SerieDataComponent(typeof(ItemStyle), typeof(TitleStyle), typeof(LabelStyle), typeof(EmphasisStyle), typeof(BlurStyle), typeof(SelectStyle))] [SerieDataExtraField("m_Ignore")] public class Bar : Serie, INeedSerieContainer { public override bool useSortData { get { return realtimeSort; } } - + public int containerIndex { get; internal set; } public int containterInstanceId { get; internal set; } diff --git a/Runtime/Serie/Bar/BarHandler.cs b/Runtime/Serie/Bar/BarHandler.cs index 69197a70..beec6ea7 100644 --- a/Runtime/Serie/Bar/BarHandler.cs +++ b/Runtime/Serie/Bar/BarHandler.cs @@ -47,12 +47,14 @@ namespace XCharts.Runtime { switch (label.position) { + case LabelStyle.Position.Start: case LabelStyle.Position.Bottom: var center = serieData.context.areaCenter; var angle = serieData.context.halfAngle; var radius = serieData.context.insideRadius; return ChartHelper.GetPosition(center, angle, radius); case LabelStyle.Position.Top: + case LabelStyle.Position.End: center = serieData.context.areaCenter; angle = serieData.context.halfAngle; radius = serieData.context.outsideRadius; @@ -65,6 +67,7 @@ namespace XCharts.Runtime { switch (label.position) { + case LabelStyle.Position.Start: case LabelStyle.Position.Bottom: var center = serieData.context.rect.center; if (serie.context.isHorizontal) @@ -73,6 +76,7 @@ namespace XCharts.Runtime return new Vector3(center.x, center.y - serieData.context.rect.height / 2); case LabelStyle.Position.Center: case LabelStyle.Position.Inside: + case LabelStyle.Position.Middle: return serieData.context.rect.center; default: return serieData.context.position; @@ -80,6 +84,11 @@ namespace XCharts.Runtime } } + public override Vector3 GetSerieDataTitlePosition(SerieData serieData, TitleStyle titleStyle) + { + return GetSerieDataLabelPosition(serieData, titleStyle); + } + private void UpdateSerieGridContext() { if (m_SerieGrid == null)