修复Log轴时绘制异常的问题

This commit is contained in:
monitor1394
2021-04-29 19:17:12 +08:00
parent 11fc9d15a2
commit 13a81b8374
3 changed files with 28 additions and 10 deletions

View File

@@ -86,10 +86,19 @@ namespace XCharts
} }
else else
{ {
valueTotal = xMaxValue - xMinValue; if (yAxis.IsLog())
if (valueTotal != 0) {
barHig = (xMinValue > 0 ? value - xMinValue : value) int minIndex = xAxis.runtimeMinLogIndex;
/ valueTotal * grid.runtimeWidth; 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; serieData.runtimeStackHig = barHig;
var isBarEnd = false; var isBarEnd = false;
@@ -223,7 +232,16 @@ namespace XCharts
valueTotal = yMaxValue - yMinValue; valueTotal = yMaxValue - yMinValue;
if (valueTotal != 0) 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; serieData.runtimeStackHig = barHig;

View File

@@ -440,7 +440,7 @@ namespace XCharts
{ {
int minIndex = xAxis.runtimeMinLogIndex; int minIndex = xAxis.runtimeMinLogIndex;
float nowIndex = xAxis.GetLogValue(xValue); float nowIndex = xAxis.GetLogValue(xValue);
xDataHig = (nowIndex - minIndex) / (xAxis.splitNumber - 1) * grid.runtimeWidth; xDataHig = (nowIndex - minIndex) / xAxis.splitNumber * grid.runtimeWidth;
} }
else else
{ {
@@ -451,7 +451,7 @@ namespace XCharts
{ {
int minIndex = yAxis.runtimeMinLogIndex; int minIndex = yAxis.runtimeMinLogIndex;
float nowIndex = yAxis.GetLogValue(yValue); float nowIndex = yAxis.GetLogValue(yValue);
yDataHig = (nowIndex - minIndex) / (yAxis.splitNumber - 1) * grid.runtimeHeight; yDataHig = (nowIndex - minIndex) / yAxis.splitNumber * grid.runtimeHeight;
} }
else else
{ {
@@ -477,7 +477,7 @@ namespace XCharts
{ {
int minIndex = yAxis.runtimeMinLogIndex; int minIndex = yAxis.runtimeMinLogIndex;
float nowIndex = yAxis.GetLogValue(yValue); float nowIndex = yAxis.GetLogValue(yValue);
yDataHig = (nowIndex - minIndex) / (yAxis.splitNumber - 1) * grid.runtimeHeight; yDataHig = (nowIndex - minIndex) / yAxis.splitNumber * grid.runtimeHeight;
} }
else else
{ {
@@ -577,7 +577,7 @@ namespace XCharts
{ {
int minIndex = xAxis.runtimeMinLogIndex; int minIndex = xAxis.runtimeMinLogIndex;
float nowIndex = xAxis.GetLogValue(value); float nowIndex = xAxis.GetLogValue(value);
dataHig = (nowIndex - minIndex) / (xAxis.splitNumber - 1) * grid.runtimeWidth; dataHig = (nowIndex - minIndex) / xAxis.splitNumber * grid.runtimeWidth;
} }
else else
{ {

View File

@@ -91,7 +91,7 @@ namespace XCharts
{ {
int minIndex = axis.runtimeMinLogIndex; int minIndex = axis.runtimeMinLogIndex;
float nowIndex = axis.GetLogValue(value); float nowIndex = axis.GetLogValue(value);
return (nowIndex - minIndex) / (axis.splitNumber - 1) * totalWidth; return (nowIndex - minIndex) / axis.splitNumber * totalWidth;
} }
else else
{ {