From 06bd26dc5fdb44373677f55022e609b74b2949a2 Mon Sep 17 00:00:00 2001 From: monitor1394 Date: Fri, 25 Apr 2025 22:42:11 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D`MarkArea`=E6=8C=87=E5=AE=9A`?= =?UTF-8?q?yValue`=E6=88=96`xValue`=E6=97=B6=E7=BB=98=E5=88=B6=E5=8C=BA?= =?UTF-8?q?=E5=9F=9F=E4=B8=8D=E5=87=86=E7=A1=AE=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Documentation~/zh/changelog.md | 3 ++ Runtime/Component/Mark/MarkAreaHandler.cs | 43 ++++++++++------------- 2 files changed, 21 insertions(+), 25 deletions(-) diff --git a/Documentation~/zh/changelog.md b/Documentation~/zh/changelog.md index e33d595c..fe70e024 100644 --- a/Documentation~/zh/changelog.md +++ b/Documentation~/zh/changelog.md @@ -80,6 +80,9 @@ slug: /changelog ## master +* (2025.04.25) 修复`MarkArea`指定`yValue`或`xValue`时绘制区域不准确的问题 +* (2025.04.17) 增加`UITable`的`Title`支持设置标题 +* (2025.04.17) 增加`UITable`的`Viewport`支持设置表格视口边距边框 * (2025.04.15) 增加`Bar`支持通过`VisualMap`设置颜色 * (2025.04.14) 增加`AxisLabel`的`showZeroLabel`设置是否显示0刻度 * (2025.04.08) 增加`UIStatistic`的`desc`描述文本设置支持 diff --git a/Runtime/Component/Mark/MarkAreaHandler.cs b/Runtime/Component/Mark/MarkAreaHandler.cs index df8eb1f9..b281a606 100644 --- a/Runtime/Component/Mark/MarkAreaHandler.cs +++ b/Runtime/Component/Mark/MarkAreaHandler.cs @@ -40,7 +40,7 @@ namespace XCharts.Runtime private void InitMarkArea(MarkArea markArea) { markArea.painter = chart.m_PainterUpper; - markArea.refreshComponent = delegate() + markArea.refreshComponent = delegate () { var label = ChartHelper.AddChartLabel("label", m_MarkLineLabelRoot.transform, markArea.label, chart.theme.axis, component.text, Color.clear, TextAnchor.MiddleCenter); @@ -142,31 +142,12 @@ namespace XCharts.Runtime else if (data.yValue != 0) { data.runtimeValue = data.yValue; - if (yAxis.IsCategory()) - { - var pY = AxisHelper.GetAxisPosition(grid, yAxis, data.yValue, showData.Count, dataZoom); - return start ? - new Vector3(grid.context.x, pY) : - new Vector3(grid.context.x + grid.context.width, pY); - } - else - { - return GetPosition(xAxis, yAxis, grid, data.runtimeValue, start); - } + return GetPosition(yAxis, grid, data.runtimeValue, start); } else { data.runtimeValue = data.xValue; - if (xAxis.IsCategory()) - { - var pX = AxisHelper.GetAxisPosition(grid, xAxis, data.xValue, showData.Count, dataZoom); - return start ? new Vector3(pX, grid.context.y + grid.context.height) : - new Vector3(pX, grid.context.y); - } - else - { - return GetPosition(xAxis, yAxis, grid, data.xValue, start); - } + return GetPosition(xAxis, grid, data.xValue, start); } default: break; @@ -178,16 +159,28 @@ namespace XCharts.Runtime { if (yAxis.IsCategory()) { - var pX = AxisHelper.GetAxisPosition(grid, xAxis, value); + return GetPosition(xAxis, grid, value, start); + } + else + { + return GetPosition(yAxis, grid, value, start); + } + } + + private Vector3 GetPosition(Axis axis, GridCoord grid, double value, bool start) + { + if (axis is XAxis) + { + var pX = AxisHelper.GetAxisPosition(grid, axis, value); return start ? new Vector3(pX, grid.context.y + grid.context.height) : new Vector3(pX, grid.context.y); } else { - var pY = AxisHelper.GetAxisPosition(grid, yAxis, value); + var pY = AxisHelper.GetAxisPosition(grid, axis, value); return start ? - new Vector3(grid.context.x, pY + grid.context.height) : + new Vector3(grid.context.x, pY) : new Vector3(grid.context.x + grid.context.width, pY); } }