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 {