From 86f0ae5739b5953f7ea03d5576775400c6fcaeb6 Mon Sep 17 00:00:00 2001 From: monitor1394 Date: Thu, 12 Oct 2023 21:55:16 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D`MarkLine`=E6=8C=87=E5=AE=9A`?= =?UTF-8?q?yValue`=E6=97=B6=E5=AF=B9=E6=95=B0=E5=80=BC=E8=BD=B4=E6=97=A0?= =?UTF-8?q?=E6=95=88=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 | 1 + Runtime/Component/Mark/MarkLineHandler.cs | 18 +++++++++--------- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/Documentation~/zh/changelog.md b/Documentation~/zh/changelog.md index 732f0907..3c9a5127 100644 --- a/Documentation~/zh/changelog.md +++ b/Documentation~/zh/changelog.md @@ -69,6 +69,7 @@ slug: /changelog ## master +* (2023.10.11) 修复`MarkLine`指定`yValue`时对数值轴无效的问题 * (2023.10.11) 修复`Serie`的`showDataDimension`设置无效的问题 ## v3.8.1 diff --git a/Runtime/Component/Mark/MarkLineHandler.cs b/Runtime/Component/Mark/MarkLineHandler.cs index 858097f1..533b1fbb 100644 --- a/Runtime/Component/Mark/MarkLineHandler.cs +++ b/Runtime/Component/Mark/MarkLineHandler.cs @@ -125,19 +125,19 @@ namespace XCharts.Runtime { case MarkLineType.Min: data.runtimeValue = SerieHelper.GetMinData(serie, data.dimension, dataZoom); - GetStartEndPos(xAxis, yAxis, grid, data.runtimeValue, ref sp, ref ep); + GetStartEndPos(yAxis, grid, data.runtimeValue, ref sp, ref ep); break; case MarkLineType.Max: data.runtimeValue = SerieHelper.GetMaxData(serie, data.dimension, dataZoom); - GetStartEndPos(xAxis, yAxis, grid, data.runtimeValue, ref sp, ref ep); + GetStartEndPos(yAxis, grid, data.runtimeValue, ref sp, ref ep); break; case MarkLineType.Average: data.runtimeValue = SerieHelper.GetAverageData(serie, data.dimension, dataZoom); - GetStartEndPos(xAxis, yAxis, grid, data.runtimeValue, ref sp, ref ep); + GetStartEndPos(yAxis, grid, data.runtimeValue, ref sp, ref ep); break; case MarkLineType.Median: data.runtimeValue = SerieHelper.GetMedianData(serie, data.dimension, dataZoom); - GetStartEndPos(xAxis, yAxis, grid, data.runtimeValue, ref sp, ref ep); + GetStartEndPos(yAxis, grid, data.runtimeValue, ref sp, ref ep); break; case MarkLineType.None: if (data.xPosition != 0) @@ -165,7 +165,7 @@ namespace XCharts.Runtime } else { - GetStartEndPos(xAxis, yAxis, grid, data.yValue, ref sp, ref ep); + GetStartEndPos(yAxis, grid, data.yValue, ref sp, ref ep); } } else @@ -179,7 +179,7 @@ namespace XCharts.Runtime } else { - GetStartEndPos(xAxis, yAxis, grid, data.xValue, ref sp, ref ep); + GetStartEndPos(xAxis, grid, data.xValue, ref sp, ref ep); } } break; @@ -258,11 +258,11 @@ namespace XCharts.Runtime 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) + private void GetStartEndPos(Axis xAxis, GridCoord grid, double value, ref Vector3 sp, ref Vector3 ep) { - if (xAxis.IsCategory()) + if (xAxis is YAxis) { - var pY = AxisHelper.GetAxisPosition(grid, yAxis, value); + var pY = AxisHelper.GetAxisPosition(grid, xAxis, value); sp = new Vector3(grid.context.x, pY); ep = new Vector3(grid.context.x + grid.context.width, pY); }