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