mirror of
https://github.com/XCharts-Team/XCharts.git
synced 2026-05-19 06:50:18 +00:00
修复无法正确表示部分超大或超小数值的问题
This commit is contained in:
@@ -34,6 +34,7 @@
|
||||
|
||||
## Latest
|
||||
|
||||
* (2021.05.01) Fixed an issue where some super large or super small values could not be properly represented
|
||||
* (2021.04.29) Fixed an issue with `Radar` switching to `Circle` anomaly #139
|
||||
* (2021.04.29) Added `Settings`'s `reversePainter` to set whether or not `Serie` is drawn in reverse order
|
||||
* (2021.04.28) Fixed bug where `AxisLabel` displayed incorrectly with `DataRoom` (#138)
|
||||
|
||||
@@ -34,6 +34,7 @@
|
||||
|
||||
## Latest
|
||||
|
||||
* (2021.05.01) 修复无法正确表示部分超大或超小数值的问题
|
||||
* (2021.04.29) 修复`Radar`切换到`Circle`异常的问题 #139
|
||||
* (2021.04.29) 增加`Settings`的`reversePainter`可设置`Serie`的绘制是否逆序
|
||||
* (2021.04.28) 增加`SerieData`的`ignore`可忽略当前数据项
|
||||
|
||||
@@ -107,7 +107,7 @@ namespace XCharts
|
||||
[SerializeField] protected AxisSplitLine m_SplitLine = AxisSplitLine.defaultSplitLine;
|
||||
[SerializeField] protected AxisSplitArea m_SplitArea = AxisSplitArea.defaultSplitArea;
|
||||
|
||||
[NonSerialized] private float m_MinMaxValueRange;
|
||||
[NonSerialized] private double m_MinMaxValueRange;
|
||||
[NonSerialized] private bool m_NeedUpdateFilterData;
|
||||
|
||||
/// <summary>
|
||||
@@ -412,7 +412,7 @@ namespace XCharts
|
||||
public int runtimeMinLogIndex { get { return logBaseE ? (int)Mathf.Log(runtimeMinValue) : (int)Mathf.Log(runtimeMinValue, logBase); } }
|
||||
public int runtimeMaxLogIndex { get { return logBaseE ? (int)Mathf.Log(runtimeMaxValue) : (int)Mathf.Log(runtimeMaxValue, logBase); } }
|
||||
internal bool runtimeLastCheckInverse { get; set; }
|
||||
internal float runtimeMinMaxRange { get { return m_MinMaxValueRange; } set { m_MinMaxValueRange = value; } }
|
||||
internal double runtimeMinMaxRange { get { return m_MinMaxValueRange; } set { m_MinMaxValueRange = value; } }
|
||||
internal List<string> runtimeData { get { return m_RuntimeData; } }
|
||||
private int filterStart;
|
||||
private int filterEnd;
|
||||
|
||||
@@ -1098,7 +1098,7 @@ namespace XCharts
|
||||
{
|
||||
get
|
||||
{
|
||||
float max = int.MinValue;
|
||||
float max = float.MinValue;
|
||||
foreach (var sdata in data)
|
||||
{
|
||||
if (sdata.show && sdata.data[1] > max)
|
||||
@@ -1117,7 +1117,7 @@ namespace XCharts
|
||||
{
|
||||
get
|
||||
{
|
||||
float max = int.MinValue;
|
||||
float max = float.MinValue;
|
||||
foreach (var sdata in data)
|
||||
{
|
||||
if (sdata.show && sdata.data[0] > max)
|
||||
@@ -1136,7 +1136,7 @@ namespace XCharts
|
||||
{
|
||||
get
|
||||
{
|
||||
float min = int.MaxValue;
|
||||
float min = float.MaxValue;
|
||||
foreach (var sdata in data)
|
||||
{
|
||||
if (sdata.show && sdata.data[1] < min)
|
||||
@@ -1155,7 +1155,7 @@ namespace XCharts
|
||||
{
|
||||
get
|
||||
{
|
||||
float min = int.MaxValue;
|
||||
float min = float.MaxValue;
|
||||
foreach (var sdata in data)
|
||||
{
|
||||
if (sdata.show && sdata.data[0] < min)
|
||||
|
||||
@@ -40,8 +40,8 @@ namespace XCharts
|
||||
#endif
|
||||
protected override void GetSeriesMinMaxValue(Axis axis, int axisIndex, out float tempMinValue, out float tempMaxValue)
|
||||
{
|
||||
tempMinValue = int.MaxValue;
|
||||
tempMaxValue = int.MinValue;
|
||||
tempMinValue = float.MaxValue;
|
||||
tempMaxValue = float.MinValue;
|
||||
foreach (var serie in m_Series.list)
|
||||
{
|
||||
if (serie.type != SerieType.Gantt) continue;
|
||||
@@ -57,9 +57,8 @@ namespace XCharts
|
||||
}
|
||||
}
|
||||
}
|
||||
if (tempMinValue == int.MaxValue) tempMinValue = 0;
|
||||
if (tempMaxValue == int.MinValue) tempMaxValue = 0;
|
||||
//AxisHelper.AdjustMinMaxValue(axis, ref tempMinValue, ref tempMaxValue, true, 60);
|
||||
if (tempMinValue == float.MaxValue) tempMinValue = 0;
|
||||
if (tempMaxValue == float.MinValue) tempMaxValue = 0;
|
||||
}
|
||||
|
||||
protected override void OnRefreshLabel()
|
||||
|
||||
@@ -37,12 +37,12 @@ namespace XCharts
|
||||
if (axis.interval > 0)
|
||||
{
|
||||
if (coordinateWid <= 0) return 0;
|
||||
int num = Mathf.CeilToInt(axis.runtimeMinMaxRange / axis.interval);
|
||||
int num = (int)(axis.runtimeMinMaxRange / axis.interval);
|
||||
int maxNum = Mathf.CeilToInt(coordinateWid / 15);
|
||||
if (num > maxNum)
|
||||
{
|
||||
axis.interval *= 2;
|
||||
num = Mathf.CeilToInt(axis.runtimeMinMaxRange / axis.interval);
|
||||
num = (int)(axis.runtimeMinMaxRange / axis.interval);
|
||||
}
|
||||
return num;
|
||||
}
|
||||
@@ -56,12 +56,12 @@ namespace XCharts
|
||||
if (axis.interval > 0)
|
||||
{
|
||||
if (coordinateWid <= 0) return 0;
|
||||
int num = Mathf.CeilToInt(axis.runtimeMinMaxRange / axis.interval);
|
||||
int num = (int)(axis.runtimeMinMaxRange / axis.interval);
|
||||
int maxNum = Mathf.CeilToInt(coordinateWid / 15);
|
||||
if (num > maxNum)
|
||||
{
|
||||
axis.interval *= 2;
|
||||
num = Mathf.CeilToInt(axis.runtimeMinMaxRange / axis.interval);
|
||||
num = (int)(axis.runtimeMinMaxRange / axis.interval);
|
||||
}
|
||||
return num;
|
||||
}
|
||||
@@ -238,8 +238,14 @@ namespace XCharts
|
||||
if (axis.type == Axis.AxisType.Value && axis.interval > 0)
|
||||
{
|
||||
if (axis.runtimeMinMaxRange <= 0) return 0;
|
||||
if (index >= splitNum) return coordinateWidth - (index - 1) * axis.interval * coordinateWidth / axis.runtimeMinMaxRange;
|
||||
else return axis.interval * coordinateWidth / axis.runtimeMinMaxRange;
|
||||
if (index >= splitNum)
|
||||
{
|
||||
return (float)(coordinateWidth - (index - 1) * axis.interval * coordinateWidth / axis.runtimeMinMaxRange);
|
||||
}
|
||||
else
|
||||
{
|
||||
return (float)(axis.interval * coordinateWidth / axis.runtimeMinMaxRange);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -343,7 +349,7 @@ namespace XCharts
|
||||
break;
|
||||
}
|
||||
}
|
||||
var tempRange = maxValue - minValue;
|
||||
double tempRange = maxValue - minValue;
|
||||
if (axis.runtimeMinMaxRange != tempRange)
|
||||
{
|
||||
axis.runtimeMinMaxRange = tempRange;
|
||||
|
||||
@@ -432,8 +432,8 @@ namespace XCharts
|
||||
public static void GetMinMaxValue(Series series, DataZoom dataZoom, int axisIndex, bool isValueAxis,
|
||||
bool inverse, bool yValue, out float minVaule, out float maxValue, bool isPolar = false)
|
||||
{
|
||||
float min = int.MaxValue;
|
||||
float max = int.MinValue;
|
||||
float min = float.MaxValue;
|
||||
float max = float.MinValue;
|
||||
var isPercentStack = SeriesHelper.IsPercentStack(series, SerieType.Bar);
|
||||
if (!SeriesHelper.IsStack(series) || (isValueAxis && !yValue))
|
||||
{
|
||||
@@ -512,8 +512,8 @@ namespace XCharts
|
||||
}
|
||||
}
|
||||
}
|
||||
float tmax = int.MinValue;
|
||||
float tmin = int.MaxValue;
|
||||
float tmax = float.MinValue;
|
||||
float tmin = float.MaxValue;
|
||||
foreach (var tt in _serieTotalValueForMinMax)
|
||||
{
|
||||
if (tt.Value > tmax) tmax = tt.Value;
|
||||
@@ -523,15 +523,15 @@ namespace XCharts
|
||||
if (tmin < min) min = tmin;
|
||||
}
|
||||
}
|
||||
if (max == int.MinValue && min == int.MaxValue)
|
||||
if (max == float.MinValue && min == float.MaxValue)
|
||||
{
|
||||
minVaule = 0;
|
||||
maxValue = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
minVaule = min > 1 ? Mathf.FloorToInt(min) : min;
|
||||
maxValue = max > 1 ? Mathf.CeilToInt(max) : max;
|
||||
minVaule = min > 1 ? Mathf.Floor(min) : min;
|
||||
maxValue = max > 1 ? Mathf.Ceil(max) : max;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -221,15 +221,15 @@ namespace XCharts
|
||||
}
|
||||
|
||||
var barHig = 0f;
|
||||
var valueTotal = 0f;
|
||||
double valueTotal = 0f;
|
||||
if (isPercentStack)
|
||||
{
|
||||
valueTotal = Internal_GetBarSameStackTotalValue(serie.stack, i, SerieType.Bar);
|
||||
barHig = valueTotal != 0 ? (value / valueTotal * grid.runtimeHeight) : 0;
|
||||
barHig = valueTotal != 0 ? (float)(value / valueTotal * grid.runtimeHeight) : 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
valueTotal = yMaxValue - yMinValue;
|
||||
valueTotal = (double)(yMaxValue - yMinValue);
|
||||
if (valueTotal != 0)
|
||||
{
|
||||
if (yAxis.IsLog())
|
||||
@@ -240,7 +240,7 @@ namespace XCharts
|
||||
}
|
||||
else
|
||||
{
|
||||
barHig = (yMinValue > 0 ? value - yMinValue : value) / valueTotal * grid.runtimeHeight;
|
||||
barHig = (float)((yMinValue > 0 ? value - yMinValue : value) / valueTotal * grid.runtimeHeight);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -60,12 +60,12 @@ namespace XCharts
|
||||
if (!xAxis.boundaryGap) pX -= categoryWidth / 2;
|
||||
float pY = zeroY;
|
||||
var barHig = 0f;
|
||||
var valueTotal = yMaxValue - yMinValue;
|
||||
double valueTotal = yMaxValue - yMinValue;
|
||||
var minCut = (yMinValue > 0 ? yMinValue : 0);
|
||||
if (valueTotal != 0)
|
||||
{
|
||||
barHig = (close - open) / valueTotal * grid.runtimeHeight;
|
||||
pY += (open - minCut) / valueTotal * grid.runtimeHeight;
|
||||
barHig = (float)((close - open) / valueTotal * grid.runtimeHeight);
|
||||
pY += (float)((open - minCut) / valueTotal * grid.runtimeHeight);
|
||||
}
|
||||
serieData.runtimeStackHig = barHig;
|
||||
var isBarEnd = false;
|
||||
@@ -96,8 +96,8 @@ namespace XCharts
|
||||
var itemWidth = Mathf.Abs(prt.x - plb.x);
|
||||
var itemHeight = Mathf.Abs(plt.y - prb.y);
|
||||
var center = new Vector3((plb.x + prt.x) / 2, (plt.y + prb.y) / 2);
|
||||
var lowPos = new Vector3(center.x, zeroY + (lowest - minCut) / valueTotal * grid.runtimeHeight);
|
||||
var heighPos = new Vector3(center.x, zeroY + (heighest - minCut) / valueTotal * grid.runtimeHeight);
|
||||
var lowPos = new Vector3(center.x, zeroY + (float)((lowest - minCut) / valueTotal * grid.runtimeHeight));
|
||||
var heighPos = new Vector3(center.x, zeroY + (float)((heighest - minCut) / valueTotal * grid.runtimeHeight));
|
||||
var openCenterPos = new Vector3(center.x, prb.y);
|
||||
var closeCenterPos = new Vector3(center.x, prt.y);
|
||||
if (barWidth > 2f * borderWidth)
|
||||
|
||||
@@ -455,8 +455,9 @@ namespace XCharts
|
||||
}
|
||||
else
|
||||
{
|
||||
if ((yMaxValue - yMinValue) <= 0) yDataHig = 0;
|
||||
else yDataHig = (yValue - yMinValue) / (yMaxValue - yMinValue) * grid.runtimeHeight;
|
||||
double valueTotal = yMaxValue - yMinValue;
|
||||
if (valueTotal <= 0) yDataHig = 0;
|
||||
else yDataHig = (float)((yValue - yMinValue) / valueTotal * grid.runtimeHeight);
|
||||
}
|
||||
np = new Vector3(pX + xDataHig, pY + yDataHig);
|
||||
}
|
||||
@@ -481,8 +482,9 @@ namespace XCharts
|
||||
}
|
||||
else
|
||||
{
|
||||
if ((yMaxValue - yMinValue) <= 0) yDataHig = 0;
|
||||
else yDataHig = (yValue - yMinValue) / (yMaxValue - yMinValue) * grid.runtimeHeight;
|
||||
double valueTotal = yMaxValue - yMinValue;
|
||||
if (valueTotal <= 0) yDataHig = 0;
|
||||
else yDataHig = (float)((yValue - yMinValue) / valueTotal * grid.runtimeHeight);
|
||||
}
|
||||
np = new Vector3(pX, pY + yDataHig);
|
||||
}
|
||||
|
||||
@@ -95,7 +95,7 @@ namespace XCharts
|
||||
}
|
||||
else
|
||||
{
|
||||
return (value - axis.runtimeMinValue) / (axis.runtimeMaxValue - axis.runtimeMinValue) * totalWidth;
|
||||
return (float)((value - axis.runtimeMinValue) / axis.runtimeMinMaxRange * totalWidth);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -712,20 +712,20 @@ namespace XCharts
|
||||
}
|
||||
if (ceilRate == 0)
|
||||
{
|
||||
int bigger = Mathf.CeilToInt(Mathf.Abs(max));
|
||||
var bigger = Mathf.Ceil(Mathf.Abs(max));
|
||||
int n = 1;
|
||||
while (bigger / (Mathf.Pow(10, n)) > 10)
|
||||
{
|
||||
n++;
|
||||
}
|
||||
float mm = bigger;
|
||||
if (mm > 10)
|
||||
if (mm > 10 && n < 38)
|
||||
{
|
||||
mm = bigger - bigger % (Mathf.Pow(10, n));
|
||||
mm += max > 0 ? Mathf.Pow(10, n) : -Mathf.Pow(10, n);
|
||||
}
|
||||
if (max < 0) return -Mathf.CeilToInt(mm);
|
||||
else return Mathf.CeilToInt(mm);
|
||||
if (max < 0) return -Mathf.Ceil(mm);
|
||||
else return Mathf.Ceil(mm);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -752,20 +752,20 @@ namespace XCharts
|
||||
}
|
||||
if (ceilRate == 0)
|
||||
{
|
||||
int bigger = Mathf.FloorToInt(Mathf.Abs(min));
|
||||
var bigger = Mathf.Floor(Mathf.Abs(min));
|
||||
int n = 1;
|
||||
while (bigger / (Mathf.Pow(10, n)) > 10)
|
||||
{
|
||||
n++;
|
||||
}
|
||||
float mm = bigger;
|
||||
if (mm > 10)
|
||||
if (mm > 10 && n < 38)
|
||||
{
|
||||
mm = bigger - bigger % (Mathf.Pow(10, n));
|
||||
mm += min < 0 ? Mathf.Pow(10, n) : -Mathf.Pow(10, n);
|
||||
}
|
||||
if (min < 0) return -Mathf.FloorToInt(mm);
|
||||
else return Mathf.FloorToInt(mm);
|
||||
if (min < 0) return -Mathf.Floor(mm);
|
||||
else return Mathf.Floor(mm);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -706,7 +706,7 @@ namespace XCharts
|
||||
if (dist > radius) dist = radius;
|
||||
float min = m_RadiusAxis.runtimeMinValue;
|
||||
float max = m_RadiusAxis.runtimeMaxValue;
|
||||
var value = min + dist / radius * m_RadiusAxis.runtimeMinMaxRange;
|
||||
var value = (float)(min + dist / radius * m_RadiusAxis.runtimeMinMaxRange);
|
||||
m_RadiusAxis.UpdateTooptipLabelText(ChartCached.FloatToStr(value));
|
||||
m_RadiusAxis.UpdateTooltipLabelPos(ChartHelper.GetPos(cenPos, dist, m_AngleAxis.runtimeStartAngle, true));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user