mirror of
https://github.com/XCharts-Team/XCharts.git
synced 2026-05-30 05:08:48 +00:00
[feature][radar] support smooth line
This commit is contained in:
@@ -11,9 +11,21 @@ namespace XCharts.Runtime
|
||||
[SerieDataExtraField()]
|
||||
public class Radar : Serie, INeedSerieContainer
|
||||
{
|
||||
[SerializeField][Since("3.2.0")] private bool m_Smooth = false;
|
||||
|
||||
/// <summary>
|
||||
/// Whether use smooth curve.
|
||||
/// |是否平滑曲线。平滑曲线时不支持区域填充颜色。
|
||||
/// </summary>
|
||||
public bool smooth
|
||||
{
|
||||
get { return m_Smooth; }
|
||||
set { if (PropertyUtil.SetStruct(ref m_Smooth, value)) { SetVerticesDirty(); } }
|
||||
}
|
||||
|
||||
public int containerIndex { get; internal set; }
|
||||
public int containterInstanceId { get; internal set; }
|
||||
public override bool useDataNameForColor { get { return true; } }
|
||||
public override bool useDataNameForColor { get { return radarType == RadarType.Multiple; } }
|
||||
public override bool multiDimensionLabel { get { return radarType == RadarType.Multiple; } }
|
||||
|
||||
public static Serie AddDefaultSerie(BaseChart chart, string serieName)
|
||||
|
||||
@@ -262,11 +262,11 @@ namespace XCharts.Runtime
|
||||
{
|
||||
toPoint = new Vector3(centerPos.x + radius * Mathf.Sin(currAngle),
|
||||
centerPos.y + radius * Mathf.Cos(currAngle));
|
||||
if (areaStyle != null && areaStyle.show)
|
||||
if (areaStyle != null && areaStyle.show && !serie.smooth)
|
||||
{
|
||||
UGL.DrawTriangle(vh, startPoint, toPoint, centerPos, areaColor, areaColor, areaToColor);
|
||||
}
|
||||
if (lineStyle.show)
|
||||
if (lineStyle.show && !serie.smooth)
|
||||
{
|
||||
ChartDrawer.DrawLineStyle(vh, lineStyle.type, lineWidth, startPoint, toPoint, lineColor);
|
||||
}
|
||||
@@ -274,14 +274,24 @@ namespace XCharts.Runtime
|
||||
}
|
||||
serieData.context.dataPoints.Add(startPoint);
|
||||
}
|
||||
if (areaStyle != null && areaStyle.show)
|
||||
if (areaStyle != null && areaStyle.show && !serie.smooth)
|
||||
{
|
||||
UGL.DrawTriangle(vh, startPoint, firstPoint, centerPos, areaColor, areaColor, areaToColor);
|
||||
}
|
||||
if (lineStyle.show)
|
||||
if (lineStyle.show && !serie.smooth)
|
||||
{
|
||||
ChartDrawer.DrawLineStyle(vh, lineStyle.type, lineWidth, startPoint, firstPoint, lineColor);
|
||||
}
|
||||
|
||||
if (serie.smooth)
|
||||
{
|
||||
UGL.DrawCurves(vh, serieData.context.dataPoints, lineWidth, lineColor,
|
||||
chart.settings.lineSmoothStyle,
|
||||
chart.settings.lineSmoothness,
|
||||
UGL.Direction.Random,
|
||||
float.NaN, true);
|
||||
}
|
||||
|
||||
if (symbol.show && symbol.type != SymbolType.None)
|
||||
{
|
||||
for (int m = 0; m < serieData.context.dataPoints.Count; m++)
|
||||
@@ -394,11 +404,11 @@ namespace XCharts.Runtime
|
||||
{
|
||||
toPoint = new Vector3(p.x + radius * Mathf.Sin(currAngle),
|
||||
p.y + radius * Mathf.Cos(currAngle));
|
||||
if (areaStyle != null && areaStyle.show)
|
||||
if (areaStyle != null && areaStyle.show && !serie.smooth)
|
||||
{
|
||||
UGL.DrawTriangle(vh, startPoint, toPoint, p, areaColor, areaColor, areaToColor);
|
||||
}
|
||||
if (lineStyle.show)
|
||||
if (lineStyle.show && !serie.smooth)
|
||||
{
|
||||
if (radar.connectCenter)
|
||||
ChartDrawer.DrawLineStyle(vh, lineStyle, startPoint, centerPos,
|
||||
@@ -409,14 +419,15 @@ namespace XCharts.Runtime
|
||||
startPoint = toPoint;
|
||||
lastColor = lineColor;
|
||||
}
|
||||
serie.context.dataPoints.Add(startPoint);
|
||||
serieData.context.position = startPoint;
|
||||
serieData.context.labelPosition = startPoint;
|
||||
|
||||
if (areaStyle != null && areaStyle.show && j == endIndex)
|
||||
if (areaStyle != null && areaStyle.show && j == endIndex && !serie.smooth)
|
||||
{
|
||||
UGL.DrawTriangle(vh, startPoint, firstPoint, centerPos, areaColor, areaColor, areaToColor);
|
||||
}
|
||||
if (lineStyle.show && j == endIndex)
|
||||
if (lineStyle.show && j == endIndex && !serie.smooth)
|
||||
{
|
||||
if (radar.connectCenter)
|
||||
ChartDrawer.DrawLineStyle(vh, lineStyle, startPoint, centerPos,
|
||||
@@ -425,6 +436,16 @@ namespace XCharts.Runtime
|
||||
LineStyle.Type.Solid, lineColor, radar.lineGradient ? firstColor : lineColor);
|
||||
}
|
||||
}
|
||||
if (serie.smooth)
|
||||
{
|
||||
var lineWidth = serie.lineStyle.GetWidth(chart.theme.serie.lineWidth);
|
||||
var lineColor = SerieHelper.GetLineColor(serie, null, chart.theme, serie.context.colorIndex, false);
|
||||
UGL.DrawCurves(vh, serie.context.dataPoints, lineWidth, lineColor,
|
||||
chart.settings.lineSmoothStyle,
|
||||
chart.settings.lineSmoothness,
|
||||
UGL.Direction.Random,
|
||||
float.NaN, true);
|
||||
}
|
||||
if (serie.symbol.show && serie.symbol.type != SymbolType.None)
|
||||
{
|
||||
for (int j = 0; j < serie.data.Count; j++)
|
||||
|
||||
Reference in New Issue
Block a user