From c2bafb8aa88fce703c0003742a75174d68a1682a Mon Sep 17 00:00:00 2001 From: monitor1394 Date: Wed, 22 Oct 2025 09:06:28 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0`Pie`=E7=9A=84`pieType`?= =?UTF-8?q?=E6=94=AF=E6=8C=81=E5=AE=9E=E5=BF=83=E9=A5=BC=E5=9B=BE=E5=92=8C?= =?UTF-8?q?=E7=BA=BF=E6=A1=86=E6=9F=84=E5=9B=BE=20(#349)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Documentation~/zh/changelog.md | 1 + Editor/Series/PieEditor.cs | 1 + Runtime/Serie/Pie/Pie.cs | 25 +++++++++++++++++++++++++ Runtime/Serie/Pie/PieHandler.cs | 13 +++++++++++-- Runtime/XUGL/UGL.cs | 2 +- 5 files changed, 39 insertions(+), 3 deletions(-) diff --git a/Documentation~/zh/changelog.md b/Documentation~/zh/changelog.md index 5b5b023f..86bf16c8 100644 --- a/Documentation~/zh/changelog.md +++ b/Documentation~/zh/changelog.md @@ -80,6 +80,7 @@ slug: /changelog ## master +* (2025.10.22) 增加`Pie`的`pieType`支持实心饼图和线框柄图 (#349) * (2025.09.05) 优化`MarkLine`的表现 * (2025.09.01) 增加`AxisLine`的`startExtendLength`和`endExtendLength`设置轴线的延长线 * (2025.08.27) 修复`Serie`的`TitleStyle`在数据变更时不及时刷新的问题 diff --git a/Editor/Series/PieEditor.cs b/Editor/Series/PieEditor.cs index 54fe463b..a6253ec2 100644 --- a/Editor/Series/PieEditor.cs +++ b/Editor/Series/PieEditor.cs @@ -8,6 +8,7 @@ namespace XCharts.Editor public override void OnCustomInspectorGUI() { PropertyField("m_GridIndex"); + PropertyField("m_PieType"); PropertyField("m_RoseType"); PropertyField("m_Gap"); PropertyTwoFiled("m_Center"); diff --git a/Runtime/Serie/Pie/Pie.cs b/Runtime/Serie/Pie/Pie.cs index 14086a10..572ae7d5 100644 --- a/Runtime/Serie/Pie/Pie.cs +++ b/Runtime/Serie/Pie/Pie.cs @@ -2,6 +2,21 @@ using UnityEngine; namespace XCharts.Runtime { + + public enum PieType + { + /// + /// solid pie chart - default fill style. + /// ||实心饼图 - 默认填充样式 + /// + Solid, + + /// + /// wireframe pie chart - only show the outline wireframe. + /// ||线框饼图 - 仅显示轮廓线框 + /// + Wireframe + } [System.Serializable] [SerieConvert(typeof(Line), typeof(Bar))] [SerieHandler(typeof(PieHandler), true)] @@ -12,10 +27,20 @@ namespace XCharts.Runtime public class Pie : Serie { [SerializeField][Since("v3.8.1")] private bool m_RadiusGradient = false; + [SerializeField][Since("v3.15.0")] private PieType m_PieType = PieType.Solid; public override SerieColorBy defaultColorBy { get { return SerieColorBy.Data; } } public override bool titleJustForSerie { get { return true; } } + /// + /// Pie chart type. + /// || 饼图类型。 + /// + public PieType pieType + { + get { return m_PieType; } + set { if (PropertyUtil.SetStruct(ref m_PieType, value)) { SetVerticesDirty(); } } + } /// /// Whether to use gradient color in pie chart. /// || 是否开启半径方向的渐变效果。 diff --git a/Runtime/Serie/Pie/PieHandler.cs b/Runtime/Serie/Pie/PieHandler.cs index ba3a6400..f9fba3fc 100644 --- a/Runtime/Serie/Pie/PieHandler.cs +++ b/Runtime/Serie/Pie/PieHandler.cs @@ -381,8 +381,6 @@ namespace XCharts.Runtime var needOffset = (serie.pieClickOffset && (serieData.selected || serieData.context.selected)); var offsetCenter = needOffset ? serieData.context.offsetCenter : serie.context.center; - var borderWidth = itemStyle.borderWidth; - var borderColor = itemStyle.borderColor; var progress = AnimationStyleHelper.CheckDataAnimation(chart, serie, n, 1); var insideRadius = serieData.context.insideRadius * progress; @@ -398,6 +396,17 @@ namespace XCharts.Runtime serieData.interact.SetPosition(ref interacting, offsetCenter); } } + var borderWidth = itemStyle.borderWidth; + var borderColor = itemStyle.GetBorderColor(color); + if (serie.pieType == PieType.Wireframe) + { + color = ColorUtil.clearColor32; + toColor = ColorUtil.clearColor32; + if (borderWidth <= 0) + { + borderWidth = 4; + } + } var drawEndDegree = serieData.context.currentAngle; var needRoundCap = serie.roundCap && insideRadius > 0; UGL.DrawDoughnut(vh, offsetCenter, insideRadius, diff --git a/Runtime/XUGL/UGL.cs b/Runtime/XUGL/UGL.cs index a6e01052..2ff10bb2 100644 --- a/Runtime/XUGL/UGL.cs +++ b/Runtime/XUGL/UGL.cs @@ -1446,7 +1446,7 @@ namespace XUGL var lastP4 = center; var lastColor = color; var needBorder = borderWidth != 0; - var needSpace = gap != 0; + var needSpace = gap != 0 || borderWidth != 0; var borderLineWidth = needSpace ? borderWidth : borderWidth / 2; var lastPos = Vector3.zero; var middleDire = UGLHelper.GetDire(startAngle + halfAngle);