mirror of
https://github.com/XCharts-Team/XCharts.git
synced 2026-05-14 20:00:09 +00:00
优化Log对数轴
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user