mirror of
https://github.com/XCharts-Team/XCharts.git
synced 2026-05-14 20:00:09 +00:00
增加Pie的radiusGradient可设置半径方向的渐变效果
This commit is contained in:
@@ -1628,6 +1628,19 @@ Grid component.
|
||||
|
||||
> XCharts.Runtime.Pie : [Serie](#serie)
|
||||
|
||||
```mdx-code-block
|
||||
<APITable name="Pie">
|
||||
```
|
||||
|
||||
|
||||
|field|default|since|comment|
|
||||
|--|--|--|--|
|
||||
|radiusGradient|false|v3.8.1|Whether to use gradient color in pie chart.
|
||||
|
||||
```mdx-code-block
|
||||
</APITable>
|
||||
```
|
||||
|
||||
## PolarAxisTheme
|
||||
|
||||
> XCharts.Runtime.PolarAxisTheme : [BaseAxisTheme](#baseaxistheme)
|
||||
|
||||
@@ -68,6 +68,7 @@ slug: /changelog
|
||||
|
||||
## master
|
||||
|
||||
* (2023.09.12) 增加`Pie`的`radiusGradient`可设置半径方向的渐变效果
|
||||
* (2023.09.05) 优化`LabelLine`的`lineEndX`在`Pie`中的表现
|
||||
* (2023.09.05) 修复`TriggerTooltip()`接口对`Ring`无效的问题
|
||||
* (2023.09.05) 修复`Radar`数据全为0时绘制报错的问题
|
||||
|
||||
@@ -1628,6 +1628,19 @@ Drawing grid in rectangular coordinate. Line chart, bar chart, and scatter chart
|
||||
|
||||
> XCharts.Runtime.Pie : [Serie](#serie)
|
||||
|
||||
```mdx-code-block
|
||||
<APITable name="Pie">
|
||||
```
|
||||
|
||||
|
||||
|field|default|since|comment|
|
||||
|--|--|--|--|
|
||||
|radiusGradient|false|v3.8.1|是否开启半径方向的渐变效果。
|
||||
|
||||
```mdx-code-block
|
||||
</APITable>
|
||||
```
|
||||
|
||||
## PolarAxisTheme
|
||||
|
||||
> XCharts.Runtime.PolarAxisTheme : [BaseAxisTheme](#baseaxistheme)
|
||||
|
||||
@@ -22,6 +22,7 @@ namespace XCharts.Editor
|
||||
PropertyField("m_Ignore");
|
||||
PropertyField("m_IgnoreValue");
|
||||
PropertyField("m_ClickOffset");
|
||||
PropertyField("m_RadiusGradient");
|
||||
});
|
||||
PropertyField("m_ItemStyle");
|
||||
PropertyField("m_Animation");
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
using UnityEngine;
|
||||
|
||||
namespace XCharts.Runtime
|
||||
{
|
||||
[System.Serializable]
|
||||
@@ -9,9 +11,21 @@ namespace XCharts.Runtime
|
||||
[SerieDataExtraField("m_Ignore", "m_Selected", "m_Radius")]
|
||||
public class Pie : Serie
|
||||
{
|
||||
[SerializeField][Since("v3.8.1")] private bool m_RadiusGradient = false;
|
||||
|
||||
public override SerieColorBy defaultColorBy { get { return SerieColorBy.Data; } }
|
||||
public override bool titleJustForSerie { get { return true; } }
|
||||
|
||||
/// <summary>
|
||||
/// Whether to use gradient color in pie chart.
|
||||
/// | 是否开启半径方向的渐变效果。
|
||||
/// </summary>
|
||||
public bool radiusGradient
|
||||
{
|
||||
get { return m_RadiusGradient; }
|
||||
set { if (PropertyUtil.SetStruct(ref m_RadiusGradient, value)) { SetVerticesDirty(); } }
|
||||
}
|
||||
|
||||
public static Serie AddDefaultSerie(BaseChart chart, string serieName)
|
||||
{
|
||||
var serie = chart.AddSerie<Pie>(serieName);
|
||||
|
||||
@@ -333,7 +333,7 @@ namespace XCharts.Runtime
|
||||
}
|
||||
}
|
||||
|
||||
private void DrawPie(VertexHelper vh, Serie serie)
|
||||
private void DrawPie(VertexHelper vh, Pie serie)
|
||||
{
|
||||
if (!serie.show || serie.animation.HasFadeOut())
|
||||
{
|
||||
@@ -387,7 +387,7 @@ namespace XCharts.Runtime
|
||||
UGL.DrawDoughnut(vh, offsetCenter, insideRadius,
|
||||
outsideRadius, color, toColor, Color.clear, serieData.context.startAngle,
|
||||
drawEndDegree, borderWidth, borderColor, serie.gap / 2, chart.settings.cicleSmoothness,
|
||||
needRoundCap, true);
|
||||
needRoundCap, true, serie.radiusGradient);
|
||||
DrawPieCenter(vh, serie, itemStyle, insideRadius);
|
||||
|
||||
if (serie.animation.CheckDetailBreak(serieData.context.toAngle))
|
||||
|
||||
@@ -1590,7 +1590,7 @@ namespace XUGL
|
||||
|
||||
public static void DrawDoughnut(VertexHelper vh, Vector3 center, float insideRadius, float outsideRadius,
|
||||
Color32 color, Color32 toColor, Color32 emptyColor, float startDegree, float toDegree, float borderWidth,
|
||||
Color32 borderColor, float gap, float smoothness, bool roundCap = false, bool clockwise = true)
|
||||
Color32 borderColor, float gap, float smoothness, bool roundCap = false, bool clockwise = true, bool radiusGradient = true)
|
||||
{
|
||||
if (toDegree - startDegree == 0) return;
|
||||
if (gap > 0 && Mathf.Abs(toDegree - startDegree) >= 360) gap = 0;
|
||||
@@ -1785,10 +1785,19 @@ namespace XUGL
|
||||
center.y + insideRadius * Mathf.Cos(currAngle));
|
||||
if (isGradient)
|
||||
{
|
||||
var tcolor = Color32.Lerp(color, toColor, i * 1.0f / segments);
|
||||
if (i == 0 && (needSpace || needBorder))
|
||||
UGL.DrawTriangle(vh, p1, p2, p3, color, tcolor, tcolor);
|
||||
AddVertToVertexHelper(vh, p3, p4, tcolor, tcolor, i > 0);
|
||||
if (radiusGradient)
|
||||
{
|
||||
if (i == 0 && (needSpace || needBorder))
|
||||
UGL.DrawTriangle(vh, p1, p2, p3, color, toColor, toColor);
|
||||
AddVertToVertexHelper(vh, p3, p4, color, toColor, i > 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
var tcolor = Color32.Lerp(color, toColor, i * 1.0f / segments);
|
||||
if (i == 0 && (needSpace || needBorder))
|
||||
UGL.DrawTriangle(vh, p1, p2, p3, color, tcolor, tcolor);
|
||||
AddVertToVertexHelper(vh, p3, p4, tcolor, tcolor, i > 0);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user