[improve][Parallel] improve ParallelChart

This commit is contained in:
monitor1394
2022-09-23 08:38:56 +08:00
parent bd9a0df52b
commit 4c89bda4b9
7 changed files with 21 additions and 17 deletions

View File

@@ -58,6 +58,7 @@
## master ## master
* (2022.09.23) 优化`ParallelChart`
* (2022.09.22) 增加`SaveAsImage()`接口保存图表到图片 * (2022.09.22) 增加`SaveAsImage()`接口保存图表到图片
* (2022.09.21) 修复`InsertSerie()`接口不刷新图表的问题 * (2022.09.21) 修复`InsertSerie()`接口不刷新图表的问题
* (2022.09.21) 优化`PolarChart``Line`热力图的支持 * (2022.09.21) 优化`PolarChart``Line`热力图的支持

View File

@@ -7,6 +7,7 @@ namespace XCharts.Editor
{ {
public override void OnCustomInspectorGUI() public override void OnCustomInspectorGUI()
{ {
PropertyField("m_ColorBy");
PropertyField("m_ParallelIndex"); PropertyField("m_ParallelIndex");
PropertyField("m_LineType"); PropertyField("m_LineType");
PropertyField("m_LineStyle"); PropertyField("m_LineStyle");

View File

@@ -23,6 +23,7 @@ namespace XCharts.Runtime
splitLine.show = false; splitLine.show = false;
splitLine.lineStyle.type = LineStyle.Type.None; splitLine.lineStyle.type = LineStyle.Type.None;
axisLabel.textLimit.enable = true; axisLabel.textLimit.enable = true;
axisName.labelStyle.offset = new Vector3(0, 25, 0);
} }
} }

View File

@@ -160,7 +160,7 @@ namespace XCharts.Runtime
internal override float GetAxisLineXOrY() internal override float GetAxisLineXOrY()
{ {
return component.context.y; return component.context.x;
} }
} }
} }

View File

@@ -6,7 +6,8 @@ namespace XCharts.Runtime
[System.Serializable] [System.Serializable]
[SerieHandler(typeof(ParallelHandler), true)] [SerieHandler(typeof(ParallelHandler), true)]
[RequireChartComponent(typeof(ParallelCoord))] [RequireChartComponent(typeof(ParallelCoord))]
[SerieDataExtraComponent(typeof(ItemStyle), typeof(LabelStyle), typeof(EmphasisStyle), typeof(BlurStyle), typeof(SelectStyle))] [SerieExtraComponent(typeof(EmphasisStyle), typeof(BlurStyle), typeof(SelectStyle))]
[SerieDataExtraComponent(typeof(EmphasisStyle), typeof(BlurStyle), typeof(SelectStyle))]
[SerieDataExtraField()] [SerieDataExtraField()]
public class Parallel : Serie, INeedSerieContainer public class Parallel : Serie, INeedSerieContainer
{ {

View File

@@ -8,8 +8,6 @@ namespace XCharts.Runtime
[UnityEngine.Scripting.Preserve] [UnityEngine.Scripting.Preserve]
internal sealed class ParallelHandler : SerieHandler<Parallel> internal sealed class ParallelHandler : SerieHandler<Parallel>
{ {
private List<Vector3> m_Points = new List<Vector3>();
public override void Update() public override void Update()
{ {
base.Update(); base.Update();
@@ -38,7 +36,7 @@ namespace XCharts.Runtime
var animationIndex = serie.animation.GetCurrIndex(); var animationIndex = serie.animation.GetCurrIndex();
var isHorizonal = parallel.orient == Orient.Horizonal; var isHorizonal = parallel.orient == Orient.Horizonal;
var lineColor = SerieHelper.GetLineColor(serie, null, chart.theme, serie.context.colorIndex);
var lineWidth = serie.lineStyle.GetWidth(chart.theme.serie.lineWidth); var lineWidth = serie.lineStyle.GetWidth(chart.theme.serie.lineWidth);
float currDetailProgress = !isHorizonal ? float currDetailProgress = !isHorizonal ?
@@ -58,9 +56,11 @@ namespace XCharts.Runtime
var isSmooth = serie.lineType == LineType.Smooth; var isSmooth = serie.lineType == LineType.Smooth;
foreach (var serieData in serie.data) foreach (var serieData in serie.data)
{ {
m_Points.Clear();
var count = Mathf.Min(axisCount, serieData.data.Count); var count = Mathf.Min(axisCount, serieData.data.Count);
var lp = Vector3.zero; var lp = Vector3.zero;
var colorIndex = serie.colorByData?serieData.index : serie.context.colorIndex;
var lineColor = SerieHelper.GetLineColor(serie, serieData, chart.theme, colorIndex);
serieData.context.dataPoints.Clear();
for (int i = 0; i < count; i++) for (int i = 0; i < count; i++)
{ {
if (animationIndex >= 0 && i > animationIndex) continue; if (animationIndex >= 0 && i > animationIndex) continue;
@@ -69,11 +69,11 @@ namespace XCharts.Runtime
{ {
if (isSmooth) if (isSmooth)
{ {
m_Points.Add(pos); serieData.context.dataPoints.Add(pos);
} }
else if (pos.x <= currProgress) else if (pos.x <= currProgress)
{ {
m_Points.Add(pos); serieData.context.dataPoints.Add(pos);
} }
else else
{ {
@@ -82,9 +82,9 @@ namespace XCharts.Runtime
var intersectionPos = Vector3.zero; var intersectionPos = Vector3.zero;
if (UGLHelper.GetIntersection(lp, pos, currProgressStart, currProgressEnd, ref intersectionPos)) if (UGLHelper.GetIntersection(lp, pos, currProgressStart, currProgressEnd, ref intersectionPos))
m_Points.Add(intersectionPos); serieData.context.dataPoints.Add(intersectionPos);
else else
m_Points.Add(pos); serieData.context.dataPoints.Add(pos);
break; break;
} }
} }
@@ -92,11 +92,11 @@ namespace XCharts.Runtime
{ {
if (isSmooth) if (isSmooth)
{ {
m_Points.Add(pos); serieData.context.dataPoints.Add(pos);
} }
else if (pos.y <= currProgress) else if (pos.y <= currProgress)
{ {
m_Points.Add(pos); serieData.context.dataPoints.Add(pos);
} }
else else
{ {
@@ -105,21 +105,21 @@ namespace XCharts.Runtime
var intersectionPos = Vector3.zero; var intersectionPos = Vector3.zero;
if (UGLHelper.GetIntersection(lp, pos, currProgressStart, currProgressEnd, ref intersectionPos)) if (UGLHelper.GetIntersection(lp, pos, currProgressStart, currProgressEnd, ref intersectionPos))
m_Points.Add(intersectionPos); serieData.context.dataPoints.Add(intersectionPos);
else else
m_Points.Add(pos); serieData.context.dataPoints.Add(pos);
break; break;
} }
} }
lp = pos; lp = pos;
} }
if (isSmooth) if (isSmooth)
UGL.DrawCurves(vh, m_Points, lineWidth, lineColor, UGL.DrawCurves(vh, serieData.context.dataPoints, lineWidth, lineColor,
chart.settings.lineSmoothStyle, chart.settings.lineSmoothStyle,
chart.settings.lineSmoothness, chart.settings.lineSmoothness,
UGL.Direction.XAxis, currProgress, isHorizonal); UGL.Direction.XAxis, currProgress, isHorizonal);
else else
UGL.DrawLine(vh, m_Points, lineWidth, lineColor, isSmooth); UGL.DrawLine(vh, serieData.context.dataPoints, lineWidth, lineColor, isSmooth);
} }
if (!serie.animation.IsFinish()) if (!serie.animation.IsFinish())
{ {

View File

@@ -448,7 +448,7 @@ namespace XCharts.Runtime
var endLabelStyle = serie.endLabel; var endLabelStyle = serie.endLabel;
if (endLabelStyle == null) if (endLabelStyle == null)
return; return;
var dataCount = serie.context.drawPoints.Count; var dataCount = serie.context.dataPoints.Count;
var active = endLabelStyle.show && dataCount > 0; var active = endLabelStyle.show && dataCount > 0;
m_EndLabel.SetActive(active); m_EndLabel.SetActive(active);
if (active) if (active)