mirror of
https://github.com/XCharts-Team/XCharts.git
synced 2026-05-27 19:50:10 +00:00
[enhancement][line] line support end label
This commit is contained in:
@@ -266,6 +266,10 @@ namespace XCharts.Runtime
|
||||
m_SerieGrid = chart.GetChartComponent<GridCoord>(axis.gridIndex);
|
||||
if (m_SerieGrid == null)
|
||||
return;
|
||||
if (m_EndLabel != null && !m_SerieGrid.context.endLabelList.Contains(m_EndLabel))
|
||||
{
|
||||
m_SerieGrid.context.endLabelList.Add(m_EndLabel);
|
||||
}
|
||||
|
||||
var visualMap = chart.GetVisualMapOfSerie(serie);
|
||||
var dataZoom = chart.GetDataZoomOfAxis(axis);
|
||||
|
||||
@@ -60,5 +60,39 @@ namespace XCharts.Runtime
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public override void RefreshEndLabelInternal()
|
||||
{
|
||||
base.RefreshEndLabelInternal();
|
||||
if (m_SerieGrid == null) return;
|
||||
if (!serie.animation.IsFinish()) return;
|
||||
var endLabelList = m_SerieGrid.context.endLabelList;
|
||||
if (endLabelList.Count <= 1) return;
|
||||
|
||||
endLabelList.Sort(delegate (ChartLabel a, ChartLabel b)
|
||||
{
|
||||
return b.transform.position.y.CompareTo(a.transform.position.y);
|
||||
});
|
||||
var lastY = float.NaN;
|
||||
for (int i = 0; i < endLabelList.Count; i++)
|
||||
{
|
||||
var label = endLabelList[i];
|
||||
if (!label.isAnimationEnd) continue;
|
||||
var labelPosition = label.transform.localPosition;
|
||||
if (float.IsNaN(lastY))
|
||||
{
|
||||
lastY = labelPosition.y;
|
||||
}
|
||||
else
|
||||
{
|
||||
var labelHeight = label.GetLabelHeight();
|
||||
if (labelPosition.y + labelHeight > lastY)
|
||||
{
|
||||
label.SetPosition(new Vector3(labelPosition.x, lastY - labelHeight, labelPosition.z));
|
||||
}
|
||||
lastY = label.transform.localPosition.y;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -295,6 +295,14 @@ namespace XCharts.Runtime
|
||||
{
|
||||
AddLineVertToVertexHelper(vh, ltp, lbp, lineColor, isVisualMapGradient, isLineStyleGradient,
|
||||
visualMap, serie.lineStyle, grid, axis, relativedAxis, false, lastDataIsIgnore, isIgnore);
|
||||
if (dataCount == 2 || isBreak)
|
||||
{
|
||||
AddLineVertToVertexHelper(vh, clp, crp, lineColor, isVisualMapGradient, isLineStyleGradient,
|
||||
visualMap, serie.lineStyle, grid, axis, relativedAxis, true, lastDataIsIgnore, isIgnore);
|
||||
serie.context.lineEndPostion = cp;
|
||||
serie.context.lineEndValue = AxisHelper.GetAxisPositionValue(grid, relativedAxis, cp);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (bitp == bibp)
|
||||
@@ -327,6 +335,8 @@ namespace XCharts.Runtime
|
||||
visualMap, serie.lineStyle, grid, axis, relativedAxis, true, lastDataIsIgnore, isIgnore);
|
||||
}
|
||||
}
|
||||
serie.context.lineEndPostion = cp;
|
||||
serie.context.lineEndValue = AxisHelper.GetAxisPositionValue(grid, relativedAxis, cp);
|
||||
lastDataIsIgnore = isIgnore;
|
||||
if (isBreak)
|
||||
break;
|
||||
|
||||
Reference in New Issue
Block a user