mirror of
https://github.com/XCharts-Team/XCharts.git
synced 2026-05-24 09:50:15 +00:00
[improve][line] improve line in polar
This commit is contained in:
@@ -58,6 +58,7 @@
|
|||||||
|
|
||||||
## master
|
## master
|
||||||
|
|
||||||
|
* (2022.09.21) 优化`PolarChart`对`Line`热力图的支持
|
||||||
* (2022.09.20) 增加`PolarChart`对`Heatmap`热力图的支持
|
* (2022.09.20) 增加`PolarChart`对`Heatmap`热力图的支持
|
||||||
* (2022.09.19) 增加`PolarChart`对多柱图和堆叠柱图的支持
|
* (2022.09.19) 增加`PolarChart`对多柱图和堆叠柱图的支持
|
||||||
* (2022.09.16) 增加`PolarChart`对`Bar`柱图的支持
|
* (2022.09.16) 增加`PolarChart`对`Bar`柱图的支持
|
||||||
|
|||||||
@@ -185,7 +185,7 @@ namespace XCharts.Runtime
|
|||||||
float symbolBorder = 0f;
|
float symbolBorder = 0f;
|
||||||
float[] cornerRadius = null;
|
float[] cornerRadius = null;
|
||||||
Color32 symbolColor, symbolToColor, symbolEmptyColor, borderColor;
|
Color32 symbolColor, symbolToColor, symbolEmptyColor, borderColor;
|
||||||
SerieHelper.GetItemColor(out symbolColor, out symbolToColor, out symbolEmptyColor, serie, serieData, theme, serie.index);
|
SerieHelper.GetItemColor(out symbolColor, out symbolToColor, out symbolEmptyColor, serie, serieData, theme, serie.context.colorIndex);
|
||||||
SerieHelper.GetSymbolInfo(out borderColor, out symbolBorder, out cornerRadius, serie, null, chart.theme, state);
|
SerieHelper.GetSymbolInfo(out borderColor, out symbolBorder, out cornerRadius, serie, null, chart.theme, state);
|
||||||
if (isVisualMapGradient)
|
if (isVisualMapGradient)
|
||||||
{
|
{
|
||||||
@@ -213,7 +213,7 @@ namespace XCharts.Runtime
|
|||||||
if (serie.context.dataPoints.Count < 2)
|
if (serie.context.dataPoints.Count < 2)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
var lineColor = SerieHelper.GetLineColor(serie, null, chart.theme, serie.index);
|
var lineColor = SerieHelper.GetLineColor(serie, null, chart.theme, serie.context.colorIndex);
|
||||||
var startPos = Vector3.zero;
|
var startPos = Vector3.zero;
|
||||||
var arrowPos = Vector3.zero;
|
var arrowPos = Vector3.zero;
|
||||||
var lineArrow = serie.lineArrow.arrow;
|
var lineArrow = serie.lineArrow.arrow;
|
||||||
|
|||||||
@@ -114,7 +114,7 @@ namespace XCharts.Runtime
|
|||||||
var firstSerieData = datas[0];
|
var firstSerieData = datas[0];
|
||||||
var lp = PolarHelper.UpdatePolarAngleAndPos(m_SeriePolar, m_AngleAxis, m_RadiusAxis, firstSerieData);
|
var lp = PolarHelper.UpdatePolarAngleAndPos(m_SeriePolar, m_AngleAxis, m_RadiusAxis, firstSerieData);
|
||||||
var cp = Vector3.zero;
|
var cp = Vector3.zero;
|
||||||
var lineColor = SerieHelper.GetLineColor(serie, null, chart.theme, serie.index);
|
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);
|
||||||
var currDetailProgress = 0f;
|
var currDetailProgress = 0f;
|
||||||
var totalDetailProgress = datas.Count;
|
var totalDetailProgress = datas.Count;
|
||||||
@@ -130,53 +130,69 @@ namespace XCharts.Runtime
|
|||||||
var clp = Vector3.zero;
|
var clp = Vector3.zero;
|
||||||
var crp = Vector3.zero;
|
var crp = Vector3.zero;
|
||||||
bool bitp = true, bibp = true;
|
bool bitp = true, bibp = true;
|
||||||
for (int i = 1; i < datas.Count; i++)
|
if (datas.Count <= 2)
|
||||||
{
|
{
|
||||||
if (serie.animation.CheckDetailBreak(i))
|
for (int i = 0; i < datas.Count; i++)
|
||||||
break;
|
|
||||||
|
|
||||||
var serieData = datas[i];
|
|
||||||
|
|
||||||
cp = PolarHelper.UpdatePolarAngleAndPos(m_SeriePolar, m_AngleAxis, m_RadiusAxis, datas[i]);
|
|
||||||
var np = i == datas.Count - 1 ? cp :
|
|
||||||
PolarHelper.UpdatePolarAngleAndPos(m_SeriePolar, m_AngleAxis, m_RadiusAxis, datas[i + 1]);
|
|
||||||
|
|
||||||
UGLHelper.GetLinePoints(lp, cp, np, lineWidth,
|
|
||||||
ref ltp, ref lbp,
|
|
||||||
ref ntp, ref nbp,
|
|
||||||
ref itp, ref ibp,
|
|
||||||
ref clp, ref crp,
|
|
||||||
ref bitp, ref bibp, i);
|
|
||||||
|
|
||||||
if (i == 1)
|
|
||||||
{
|
{
|
||||||
UGL.AddVertToVertexHelper(vh, ltp, lbp, lineColor, false);
|
var serieData = datas[i];
|
||||||
|
cp = PolarHelper.UpdatePolarAngleAndPos(m_SeriePolar, m_AngleAxis, m_RadiusAxis, datas[i]);
|
||||||
|
serieData.context.position = cp;
|
||||||
|
serie.context.dataPoints.Add(cp);
|
||||||
}
|
}
|
||||||
|
UGL.DrawLine(vh, serie.context.dataPoints, lineWidth, lineColor, false, false);
|
||||||
if (bitp == bibp)
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
for (int i = 1; i < datas.Count; i++)
|
||||||
{
|
{
|
||||||
if (bitp)
|
if (serie.animation.CheckDetailBreak(i))
|
||||||
UGL.AddVertToVertexHelper(vh, itp, ibp, lineColor, true);
|
break;
|
||||||
|
|
||||||
|
var serieData = datas[i];
|
||||||
|
cp = PolarHelper.UpdatePolarAngleAndPos(m_SeriePolar, m_AngleAxis, m_RadiusAxis, datas[i]);
|
||||||
|
serieData.context.position = cp;
|
||||||
|
serie.context.dataPoints.Add(cp);
|
||||||
|
|
||||||
|
var np = i == datas.Count - 1 ? cp :
|
||||||
|
PolarHelper.UpdatePolarAngleAndPos(m_SeriePolar, m_AngleAxis, m_RadiusAxis, datas[i + 1]);
|
||||||
|
|
||||||
|
UGLHelper.GetLinePoints(lp, cp, np, lineWidth,
|
||||||
|
ref ltp, ref lbp,
|
||||||
|
ref ntp, ref nbp,
|
||||||
|
ref itp, ref ibp,
|
||||||
|
ref clp, ref crp,
|
||||||
|
ref bitp, ref bibp, i);
|
||||||
|
|
||||||
|
if (i == 1)
|
||||||
|
{
|
||||||
|
UGL.AddVertToVertexHelper(vh, ltp, lbp, lineColor, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (bitp == bibp)
|
||||||
|
{
|
||||||
|
if (bitp)
|
||||||
|
UGL.AddVertToVertexHelper(vh, itp, ibp, lineColor, true);
|
||||||
|
else
|
||||||
|
{
|
||||||
|
UGL.AddVertToVertexHelper(vh, ltp, clp, lineColor, true);
|
||||||
|
UGL.AddVertToVertexHelper(vh, ltp, crp, lineColor, true);
|
||||||
|
}
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
UGL.AddVertToVertexHelper(vh, ltp, clp, lineColor, true);
|
if (bitp)
|
||||||
UGL.AddVertToVertexHelper(vh, ltp, crp, lineColor, true);
|
{
|
||||||
|
UGL.AddVertToVertexHelper(vh, itp, clp, lineColor, true);
|
||||||
|
UGL.AddVertToVertexHelper(vh, itp, crp, lineColor, true);
|
||||||
|
}
|
||||||
|
else if (bibp)
|
||||||
|
{
|
||||||
|
UGL.AddVertToVertexHelper(vh, clp, ibp, lineColor, true);
|
||||||
|
UGL.AddVertToVertexHelper(vh, crp, ibp, lineColor, true);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
lp = cp;
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
if (bitp)
|
|
||||||
{
|
|
||||||
UGL.AddVertToVertexHelper(vh, itp, clp, lineColor, true);
|
|
||||||
UGL.AddVertToVertexHelper(vh, itp, crp, lineColor, true);
|
|
||||||
}
|
|
||||||
else if (bibp)
|
|
||||||
{
|
|
||||||
UGL.AddVertToVertexHelper(vh, clp, ibp, lineColor, true);
|
|
||||||
UGL.AddVertToVertexHelper(vh, crp, ibp, lineColor, true);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
lp = cp;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!serie.animation.IsFinish())
|
if (!serie.animation.IsFinish())
|
||||||
@@ -187,6 +203,46 @@ namespace XCharts.Runtime
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void DrawPolarLineArrow(VertexHelper vh, Serie serie)
|
||||||
|
{
|
||||||
|
if (!serie.show || serie.lineArrow == null || !serie.lineArrow.show)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (serie.context.dataPoints.Count < 2)
|
||||||
|
return;
|
||||||
|
|
||||||
|
var lineColor = SerieHelper.GetLineColor(serie, null, chart.theme, serie.context.colorIndex);
|
||||||
|
var startPos = Vector3.zero;
|
||||||
|
var arrowPos = Vector3.zero;
|
||||||
|
var lineArrow = serie.lineArrow.arrow;
|
||||||
|
var dataPoints = serie.context.dataPoints;
|
||||||
|
switch (serie.lineArrow.position)
|
||||||
|
{
|
||||||
|
case LineArrow.Position.End:
|
||||||
|
if (dataPoints.Count < 3)
|
||||||
|
{
|
||||||
|
startPos = dataPoints[dataPoints.Count - 2];
|
||||||
|
arrowPos = dataPoints[dataPoints.Count - 1];
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
startPos = dataPoints[dataPoints.Count - 3];
|
||||||
|
arrowPos = dataPoints[dataPoints.Count - 2];
|
||||||
|
}
|
||||||
|
UGL.DrawArrow(vh, startPos, arrowPos, lineArrow.width, lineArrow.height,
|
||||||
|
lineArrow.offset, lineArrow.dent, lineArrow.GetColor(lineColor));
|
||||||
|
|
||||||
|
break;
|
||||||
|
|
||||||
|
case LineArrow.Position.Start:
|
||||||
|
startPos = dataPoints[1];
|
||||||
|
arrowPos = dataPoints[0];
|
||||||
|
UGL.DrawArrow(vh, startPos, arrowPos, lineArrow.width, lineArrow.height,
|
||||||
|
lineArrow.offset, lineArrow.dent, lineArrow.GetColor(lineColor));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void DrawPolarLineSymbol(VertexHelper vh)
|
private void DrawPolarLineSymbol(VertexHelper vh)
|
||||||
{
|
{
|
||||||
for (int n = 0; n < chart.series.Count; n++)
|
for (int n = 0; n < chart.series.Count; n++)
|
||||||
|
|||||||
@@ -35,6 +35,7 @@ namespace XCharts.Runtime
|
|||||||
{
|
{
|
||||||
DrawPolarLine(vh, serie);
|
DrawPolarLine(vh, serie);
|
||||||
DrawPolarLineSymbol(vh);
|
DrawPolarLineSymbol(vh);
|
||||||
|
DrawPolarLineArrow(vh, serie);
|
||||||
}
|
}
|
||||||
else if (serie.IsUseCoord<GridCoord>())
|
else if (serie.IsUseCoord<GridCoord>())
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user