mirror of
https://github.com/XCharts-Team/XCharts.git
synced 2026-05-22 00:20:18 +00:00
修复无法正确表示部分超大或超小数值的问题
This commit is contained in:
@@ -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
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user