修复MarkLine在开启Clip后还绘制在坐标系外的问题

This commit is contained in:
monitor1394
2023-08-25 07:39:10 +08:00
parent d6f1c82a08
commit dc46477c15
3 changed files with 15 additions and 5 deletions

View File

@@ -78,6 +78,7 @@ slug: /changelog
日志详情:
* (2023.08.25) 修复`MarkLine`在开启`Clip`后还绘制在坐标系外的问题
* (2023.08.24) 优化`YAxis`在数据全为0时默认设置0-1的范围
* (2023.08.23) 修复`YAxis``Label`可能会重复的问题
* (2023.08.22) 修复`Bar`显示隐藏时绘制表现异常的问题

View File

@@ -129,6 +129,7 @@ namespace XCharts.Runtime
public Vector3 runtimeCurrentEndPosition { get; internal set; }
public ChartLabel runtimeLabel { get; internal set; }
public double runtimeValue { get; internal set; }
public bool runtimeInGrid { get; internal set; }
/// <summary>
/// Name of the marker, which will display as a label.

View File

@@ -36,7 +36,7 @@ namespace XCharts.Runtime
if (data.runtimeLabel != null)
{
var pos = MarkLineHelper.GetLabelPosition(data);
data.runtimeLabel.SetActive(data.label.show && pos != Vector3.zero);
data.runtimeLabel.SetActive(data.label.show && data.runtimeInGrid);
data.runtimeLabel.SetPosition(pos);
data.runtimeLabel.SetText(MarkLineHelper.GetFormatterContent(serie, data));
}
@@ -79,7 +79,7 @@ namespace XCharts.Runtime
content, Color.clear, TextAnchor.MiddleCenter);
var pos = MarkLineHelper.GetLabelPosition(data);
label.SetIconActive(false);
label.SetActive(data.label.show && pos != Vector3.zero);
label.SetActive(data.label.show && data.runtimeInGrid);
label.SetPosition(pos);
data.runtimeLabel = label;
};
@@ -218,9 +218,17 @@ namespace XCharts.Runtime
{
if (!animation.IsFinish())
ep = Vector3.Lerp(sp, ep, animation.GetCurrDetail());
if ((!chart.IsInChart(sp) && !chart.IsInChart(ep)) ||
(serie.clip && !grid.Contains(sp) && !grid.Contains(ep)))
{
data.runtimeInGrid = false;
m_RefreshLabel = true;
return;
}
data.runtimeCurrentEndPosition = ep;
if (sp != Vector3.zero || ep != Vector3.zero)
{
data.runtimeInGrid = true;
m_RefreshLabel = true;
chart.ClampInChart(ref sp);
chart.ClampInChart(ref ep);
@@ -247,7 +255,7 @@ namespace XCharts.Runtime
Color32 borderColor;
SerieHelper.GetSymbolInfo(out borderColor, out tickness, out cornerRadius, serie, null, chart.theme);
chart.DrawClipSymbol(vh, symbol.type, symbol.size, tickness, pos, lineColor, lineColor,
ColorUtil.clearColor32, borderColor, symbol.gap, true, cornerRadius, grid, startPos);
ColorUtil.clearColor32, borderColor, symbol.gap, serie.clip, cornerRadius, grid, startPos);
}
private void GetStartEndPos(Axis xAxis, Axis yAxis, GridCoord grid, double value, ref Vector3 sp, ref Vector3 ep)