优化Log对数轴

This commit is contained in:
monitor1394
2023-10-19 23:06:26 +08:00
parent 6b931497ab
commit 68d5bc36d6
3 changed files with 14 additions and 22 deletions

View File

@@ -682,7 +682,7 @@ namespace XCharts.Runtime
public static double GetMaxDivisibleValue(double max, double ceilRate)
{
if (max == 0) return 0;
double pow = 1;
double pow = 1;
if (max > -1 && max < 1)
{
pow = Mathf.Pow(10, MathUtil.GetPrecision(max));
@@ -739,7 +739,7 @@ namespace XCharts.Runtime
public static double GetMinDivisibleValue(double min, double ceilRate)
{
if (min == 0) return 0;
double pow = 1;
double pow = 1;
if (min > -1 && min < 1)
{
pow = Mathf.Pow(10, MathUtil.GetPrecision(min));
@@ -770,20 +770,13 @@ namespace XCharts.Runtime
public static double GetMaxLogValue(double value, float logBase, bool isLogBaseE, out int splitNumber)
{
splitNumber = 0;
splitNumber = 1;
if (value <= 0) return 0;
double max = 0;
double max = isLogBaseE ? Math.Exp(splitNumber) : Math.Pow(logBase, splitNumber);
while (max < value)
{
if (isLogBaseE)
{
max = Math.Exp(splitNumber);
}
else
{
max = Math.Pow(logBase, splitNumber);
}
splitNumber++;
max = isLogBaseE ? Math.Exp(splitNumber) : Math.Pow(logBase, splitNumber);
}
return max;
}
@@ -791,19 +784,13 @@ namespace XCharts.Runtime
public static double GetMinLogValue(double value, float logBase, bool isLogBaseE, out int splitNumber)
{
splitNumber = 0;
if (value <= 0) return 0;
if (value > 1) return 1;
double min = 1;
double min = isLogBaseE ? Math.Exp(-splitNumber) : Math.Pow(logBase, -splitNumber);
while (min > value)
{
if (isLogBaseE)
{
min = Math.Exp(-splitNumber);
}
else
{
min = Math.Pow(logBase, -splitNumber);
}
splitNumber++;
min = isLogBaseE ? Math.Exp(-splitNumber) : Math.Pow(logBase, -splitNumber);
}
return min;
}