mirror of
https://github.com/XCharts-Team/XCharts.git
synced 2026-05-17 05:50:09 +00:00
修复数据在-1到1之间坐标轴显示错误问题
This commit is contained in:
@@ -353,7 +353,14 @@ namespace XCharts.Runtime
|
||||
}
|
||||
else if (string.IsNullOrEmpty(newNumericFormatter) && !isLog)
|
||||
{
|
||||
newNumericFormatter = MathUtil.IsInteger(maxValue) ? "f0" : "f" + MathUtil.GetPrecision(maxValue);
|
||||
if (Math.Abs(maxValue) >= Math.Abs(minValue))
|
||||
{
|
||||
newNumericFormatter = MathUtil.IsInteger(maxValue) ? "f0" : "f" + MathUtil.GetPrecision(maxValue);
|
||||
}
|
||||
else
|
||||
{
|
||||
newNumericFormatter = MathUtil.IsInteger(minValue) ? "f0" : "f" + MathUtil.GetPrecision(minValue);
|
||||
}
|
||||
}
|
||||
if (string.IsNullOrEmpty(m_Formatter))
|
||||
{
|
||||
|
||||
@@ -682,19 +682,11 @@ namespace XCharts.Runtime
|
||||
public static double GetMaxDivisibleValue(double max, double ceilRate)
|
||||
{
|
||||
if (max == 0) return 0;
|
||||
double pow = 1;
|
||||
if (max > -1 && max < 1)
|
||||
{
|
||||
int count = 1;
|
||||
int intvalue = (int)(max * Mathf.Pow(10, count));
|
||||
while (intvalue == 0 && count < 12)
|
||||
{
|
||||
count++;
|
||||
intvalue = (int)(max * Mathf.Pow(10, count));
|
||||
}
|
||||
var pow = Mathf.Pow(10, count);
|
||||
var value = max > 0 ? (int)((max * (pow + 1))) / pow :
|
||||
(int)((max * (pow - 1))) / pow;
|
||||
return GetMaxCeilRate(value, ceilRate);
|
||||
pow = Mathf.Pow(10, MathUtil.GetPrecision(max));
|
||||
max *= pow;
|
||||
}
|
||||
if (ceilRate == 0)
|
||||
{
|
||||
@@ -720,11 +712,11 @@ namespace XCharts.Runtime
|
||||
if (mmm >= (powmax - pown) && mmm < powmax)
|
||||
mmm = powmax;
|
||||
if (max < 0) return -Math.Ceiling(mmm > -max ? mmm : mm);
|
||||
else return Math.Ceiling(mmm > max ? mmm : mm);
|
||||
else return Math.Ceiling(mmm > max ? mmm : mm) / pow;
|
||||
}
|
||||
else
|
||||
{
|
||||
return GetMaxCeilRate(max, ceilRate);
|
||||
return GetMaxCeilRate(max, ceilRate) / pow;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -747,19 +739,11 @@ namespace XCharts.Runtime
|
||||
public static double GetMinDivisibleValue(double min, double ceilRate)
|
||||
{
|
||||
if (min == 0) return 0;
|
||||
double pow = 1;
|
||||
if (min > -1 && min < 1)
|
||||
{
|
||||
int count = 1;
|
||||
int intvalue = (int)(min * Mathf.Pow(10, count));
|
||||
while (intvalue == 0 && count < 12)
|
||||
{
|
||||
count++;
|
||||
intvalue = (int)(min * Mathf.Pow(10, count));
|
||||
}
|
||||
var pow = Mathf.Pow(10, count);
|
||||
var value = min > 0 ? ((int)(min * (pow - 1))) / pow :
|
||||
((int)(min * (pow + 1))) / pow;
|
||||
return GetMinCeilRate(value, ceilRate);
|
||||
pow = Mathf.Pow(10, MathUtil.GetPrecision(min));
|
||||
min *= pow;
|
||||
}
|
||||
if (ceilRate == 0)
|
||||
{
|
||||
@@ -775,12 +759,12 @@ namespace XCharts.Runtime
|
||||
mm = bigger - bigger % (Mathf.Pow(10, n));
|
||||
mm += min < 0 ? Mathf.Pow(10, n) : -Mathf.Pow(10, n);
|
||||
}
|
||||
if (min < 0) return -Math.Floor(mm);
|
||||
else return Math.Floor(mm);
|
||||
if (min < 0) return -Math.Floor(mm) / pow;
|
||||
else return Math.Floor(mm) / pow;
|
||||
}
|
||||
else
|
||||
{
|
||||
return GetMinCeilRate(min, ceilRate);
|
||||
return GetMinCeilRate(min, ceilRate) / pow;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user