From c4bc8c06e7ca89e12b90e8e860e3d19f16c630ad Mon Sep 17 00:00:00 2001 From: monitor1394 Date: Thu, 29 Apr 2021 19:17:12 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8DLog=E8=BD=B4=E6=97=B6?= =?UTF-8?q?=E7=BB=98=E5=88=B6=E5=BC=82=E5=B8=B8=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Runtime/Internal/CoordinateChart_DrawBar.cs | 28 +++++++++++++++---- Runtime/Internal/CoordinateChart_DrawLine.cs | 8 +++--- .../Internal/CoordinateChart_DrawScatter.cs | 2 +- 3 files changed, 28 insertions(+), 10 deletions(-) diff --git a/Runtime/Internal/CoordinateChart_DrawBar.cs b/Runtime/Internal/CoordinateChart_DrawBar.cs index dbe0a0fd..169a6306 100644 --- a/Runtime/Internal/CoordinateChart_DrawBar.cs +++ b/Runtime/Internal/CoordinateChart_DrawBar.cs @@ -86,10 +86,19 @@ namespace XCharts } else { - valueTotal = xMaxValue - xMinValue; - if (valueTotal != 0) - barHig = (xMinValue > 0 ? value - xMinValue : value) - / valueTotal * grid.runtimeWidth; + if (yAxis.IsLog()) + { + int minIndex = xAxis.runtimeMinLogIndex; + float nowIndex = xAxis.GetLogValue(value); + barHig = (nowIndex - minIndex) / xAxis.splitNumber * grid.runtimeWidth; + } + else + { + valueTotal = xMaxValue - xMinValue; + if (valueTotal != 0) + barHig = (xMinValue > 0 ? value - xMinValue : value) + / valueTotal * grid.runtimeWidth; + } } serieData.runtimeStackHig = barHig; var isBarEnd = false; @@ -223,7 +232,16 @@ namespace XCharts valueTotal = yMaxValue - yMinValue; if (valueTotal != 0) { - barHig = (yMinValue > 0 ? value - yMinValue : value) / valueTotal * grid.runtimeHeight; + if (yAxis.IsLog()) + { + int minIndex = yAxis.runtimeMinLogIndex; + float nowIndex = yAxis.GetLogValue(value); + barHig = (nowIndex - minIndex) / yAxis.splitNumber * grid.runtimeHeight; + } + else + { + barHig = (yMinValue > 0 ? value - yMinValue : value) / valueTotal * grid.runtimeHeight; + } } } serieData.runtimeStackHig = barHig; diff --git a/Runtime/Internal/CoordinateChart_DrawLine.cs b/Runtime/Internal/CoordinateChart_DrawLine.cs index f557a4f0..ad12063c 100644 --- a/Runtime/Internal/CoordinateChart_DrawLine.cs +++ b/Runtime/Internal/CoordinateChart_DrawLine.cs @@ -440,7 +440,7 @@ namespace XCharts { int minIndex = xAxis.runtimeMinLogIndex; float nowIndex = xAxis.GetLogValue(xValue); - xDataHig = (nowIndex - minIndex) / (xAxis.splitNumber - 1) * grid.runtimeWidth; + xDataHig = (nowIndex - minIndex) / xAxis.splitNumber * grid.runtimeWidth; } else { @@ -451,7 +451,7 @@ namespace XCharts { int minIndex = yAxis.runtimeMinLogIndex; float nowIndex = yAxis.GetLogValue(yValue); - yDataHig = (nowIndex - minIndex) / (yAxis.splitNumber - 1) * grid.runtimeHeight; + yDataHig = (nowIndex - minIndex) / yAxis.splitNumber * grid.runtimeHeight; } else { @@ -477,7 +477,7 @@ namespace XCharts { int minIndex = yAxis.runtimeMinLogIndex; float nowIndex = yAxis.GetLogValue(yValue); - yDataHig = (nowIndex - minIndex) / (yAxis.splitNumber - 1) * grid.runtimeHeight; + yDataHig = (nowIndex - minIndex) / yAxis.splitNumber * grid.runtimeHeight; } else { @@ -577,7 +577,7 @@ namespace XCharts { int minIndex = xAxis.runtimeMinLogIndex; float nowIndex = xAxis.GetLogValue(value); - dataHig = (nowIndex - minIndex) / (xAxis.splitNumber - 1) * grid.runtimeWidth; + dataHig = (nowIndex - minIndex) / xAxis.splitNumber * grid.runtimeWidth; } else { diff --git a/Runtime/Internal/CoordinateChart_DrawScatter.cs b/Runtime/Internal/CoordinateChart_DrawScatter.cs index 31391e22..5614d043 100644 --- a/Runtime/Internal/CoordinateChart_DrawScatter.cs +++ b/Runtime/Internal/CoordinateChart_DrawScatter.cs @@ -91,7 +91,7 @@ namespace XCharts { int minIndex = axis.runtimeMinLogIndex; float nowIndex = axis.GetLogValue(value); - return (nowIndex - minIndex) / (axis.splitNumber - 1) * totalWidth; + return (nowIndex - minIndex) / axis.splitNumber * totalWidth; } else {