mirror of
https://github.com/XCharts-Team/XCharts.git
synced 2026-05-21 16:00:24 +00:00
增加Pie的pieType支持实心饼图和线框柄图 (#349)
This commit is contained in:
@@ -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`在数据变更时不及时刷新的问题
|
||||
|
||||
@@ -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");
|
||||
|
||||
@@ -2,6 +2,21 @@ using UnityEngine;
|
||||
|
||||
namespace XCharts.Runtime
|
||||
{
|
||||
|
||||
public enum PieType
|
||||
{
|
||||
/// <summary>
|
||||
/// solid pie chart - default fill style.
|
||||
/// ||实心饼图 - 默认填充样式
|
||||
/// </summary>
|
||||
Solid,
|
||||
|
||||
/// <summary>
|
||||
/// wireframe pie chart - only show the outline wireframe.
|
||||
/// ||线框饼图 - 仅显示轮廓线框
|
||||
/// </summary>
|
||||
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; } }
|
||||
|
||||
/// <summary>
|
||||
/// Pie chart type.
|
||||
/// || 饼图类型。
|
||||
/// </summary>
|
||||
public PieType pieType
|
||||
{
|
||||
get { return m_PieType; }
|
||||
set { if (PropertyUtil.SetStruct(ref m_PieType, value)) { SetVerticesDirty(); } }
|
||||
}
|
||||
/// <summary>
|
||||
/// Whether to use gradient color in pie chart.
|
||||
/// || 是否开启半径方向的渐变效果。
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user