mirror of
https://github.com/XCharts-Team/XCharts.git
synced 2026-05-25 02:10:16 +00:00
优化数据存储类型由float全部转为double
This commit is contained in:
@@ -10,6 +10,7 @@ using UnityEngine.UI;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using XUGL;
|
||||
using System;
|
||||
|
||||
namespace XCharts
|
||||
{
|
||||
@@ -286,8 +287,8 @@ namespace XCharts
|
||||
var symbol = SerieHelper.GetSerieSymbol(serie, serieData);
|
||||
var symbolSize = symbol.GetSize(serieData == null ? null : serieData.data,
|
||||
m_Theme.serie.lineSymbolSize);
|
||||
if (Mathf.Abs(xValue - xdata) / xRate < symbolSize
|
||||
&& Mathf.Abs(yValue - ydata) / yRate < symbolSize)
|
||||
if (Math.Abs(xValue - xdata) / xRate < symbolSize
|
||||
&& Math.Abs(yValue - ydata) / yRate < symbolSize)
|
||||
{
|
||||
tooltip.runtimeDataIndex[i] = n;
|
||||
RefreshPainter(serie);
|
||||
@@ -900,8 +901,8 @@ namespace XCharts
|
||||
axis.runtimeMaxValue = SeriesHelper.GetMaxSerieDataCount(m_Series) - 1;
|
||||
return;
|
||||
}
|
||||
float tempMinValue = 0;
|
||||
float tempMaxValue = 0;
|
||||
double tempMinValue = 0;
|
||||
double tempMaxValue = 0;
|
||||
GetSeriesMinMaxValue(axis, axisIndex, out tempMinValue, out tempMaxValue);
|
||||
if (tempMinValue != axis.runtimeMinValue || tempMaxValue != axis.runtimeMaxValue)
|
||||
{
|
||||
@@ -919,13 +920,13 @@ namespace XCharts
|
||||
{
|
||||
axis.runtimeZeroXOffset = axis.runtimeMinValue > 0 ? 0 :
|
||||
axis.runtimeMaxValue < 0 ? grid.runtimeWidth :
|
||||
Mathf.Abs(axis.runtimeMinValue) * (grid.runtimeWidth / (Mathf.Abs(axis.runtimeMinValue) + Mathf.Abs(axis.runtimeMaxValue)));
|
||||
(float)(Math.Abs(axis.runtimeMinValue) * (grid.runtimeWidth / (Math.Abs(axis.runtimeMinValue) + Math.Abs(axis.runtimeMaxValue))));
|
||||
}
|
||||
if (grid != null && axis is YAxis && axis.IsValue())
|
||||
{
|
||||
axis.runtimeZeroYOffset = axis.runtimeMinValue > 0 ? 0 :
|
||||
axis.runtimeMaxValue < 0 ? grid.runtimeHeight :
|
||||
Mathf.Abs(axis.runtimeMinValue) * (grid.runtimeHeight / (Mathf.Abs(axis.runtimeMinValue) + Mathf.Abs(axis.runtimeMaxValue)));
|
||||
(float)(Math.Abs(axis.runtimeMinValue) * (grid.runtimeHeight / (Math.Abs(axis.runtimeMinValue) + Math.Abs(axis.runtimeMaxValue))));
|
||||
}
|
||||
}
|
||||
var dataZoom = DataZoomHelper.GetAxisRelatedDataZoom(axis, dataZooms);
|
||||
@@ -947,7 +948,7 @@ namespace XCharts
|
||||
}
|
||||
}
|
||||
|
||||
protected virtual void GetSeriesMinMaxValue(Axis axis, int axisIndex, out float tempMinValue, out float tempMaxValue)
|
||||
protected virtual void GetSeriesMinMaxValue(Axis axis, int axisIndex, out double tempMinValue, out double tempMaxValue)
|
||||
{
|
||||
if (IsValue())
|
||||
{
|
||||
@@ -1344,8 +1345,8 @@ namespace XCharts
|
||||
{
|
||||
case Tooltip.Type.Corss:
|
||||
case Tooltip.Type.Line:
|
||||
float pX = grid.runtimeX + tooltip.runtimeXValues[i] * splitWidth
|
||||
+ (xAxis.boundaryGap ? splitWidth / 2 : 0);
|
||||
float pX = (float)(grid.runtimeX + tooltip.runtimeXValues[i] * splitWidth
|
||||
+ (xAxis.boundaryGap ? splitWidth / 2 : 0));
|
||||
if (xAxis.IsValue()) pX = tooltip.runtimePointerPos.x;
|
||||
Vector2 sp = new Vector2(pX, grid.runtimeY);
|
||||
Vector2 ep = new Vector2(pX, grid.runtimeY + grid.runtimeHeight);
|
||||
@@ -1360,9 +1361,9 @@ namespace XCharts
|
||||
break;
|
||||
case Tooltip.Type.Shadow:
|
||||
float tooltipSplitWid = splitWidth < 1 ? 1 : splitWidth;
|
||||
pX = grid.runtimeX + splitWidth * tooltip.runtimeXValues[i] -
|
||||
(xAxis.boundaryGap ? 0 : splitWidth / 2);
|
||||
if (xAxis.IsValue()) pX = tooltip.runtimeXValues[i];
|
||||
pX = (float)(grid.runtimeX + splitWidth * tooltip.runtimeXValues[i] -
|
||||
(xAxis.boundaryGap ? 0 : splitWidth / 2));
|
||||
if (xAxis.IsValue()) pX = (float)tooltip.runtimeXValues[i];
|
||||
float pY = grid.runtimeY + grid.runtimeHeight;
|
||||
Vector3 p1 = new Vector3(pX, grid.runtimeY);
|
||||
Vector3 p2 = new Vector3(pX, pY);
|
||||
@@ -1396,7 +1397,7 @@ namespace XCharts
|
||||
{
|
||||
case Tooltip.Type.Corss:
|
||||
case Tooltip.Type.Line:
|
||||
float pY = grid.runtimeY + tooltip.runtimeYValues[i] * splitWidth + (yAxis.boundaryGap ? splitWidth / 2 : 0);
|
||||
float pY = (float)(grid.runtimeY + tooltip.runtimeYValues[i] * splitWidth + (yAxis.boundaryGap ? splitWidth / 2 : 0));
|
||||
Vector2 sp = new Vector2(grid.runtimeX, pY);
|
||||
Vector2 ep = new Vector2(grid.runtimeX + grid.runtimeWidth, pY);
|
||||
var lineColor = TooltipHelper.GetLineColor(tooltip, m_Theme);
|
||||
@@ -1411,8 +1412,8 @@ namespace XCharts
|
||||
case Tooltip.Type.Shadow:
|
||||
float tooltipSplitWid = splitWidth < 1 ? 1 : splitWidth;
|
||||
float pX = grid.runtimeX + grid.runtimeWidth;
|
||||
pY = grid.runtimeY + splitWidth * tooltip.runtimeYValues[i] -
|
||||
(yAxis.boundaryGap ? 0 : splitWidth / 2);
|
||||
pY = (float)(grid.runtimeY + splitWidth * tooltip.runtimeYValues[i] -
|
||||
(yAxis.boundaryGap ? 0 : splitWidth / 2));
|
||||
Vector3 p1 = new Vector3(grid.runtimeX, pY);
|
||||
Vector3 p2 = new Vector3(grid.runtimeX, pY + tooltipSplitWid);
|
||||
Vector3 p3 = new Vector3(pX, pY + tooltipSplitWid);
|
||||
@@ -1559,7 +1560,7 @@ namespace XCharts
|
||||
serieData.labelObject.UpdateIcon(serieData.iconStyle);
|
||||
if (serie.show && serieLabel.show && serieData.canShowLabel && !isIgnore)
|
||||
{
|
||||
float value = 0f;
|
||||
double value = 0;
|
||||
|
||||
if (serie.type == SerieType.Heatmap)
|
||||
{
|
||||
|
||||
@@ -44,8 +44,8 @@ namespace XCharts
|
||||
var isPercentStack = SeriesHelper.IsPercentStack(m_Series, serie.stack, SerieType.Bar);
|
||||
bool dataChanging = false;
|
||||
float dataChangeDuration = serie.animation.GetUpdateAnimationDuration();
|
||||
float xMinValue = xAxis.GetCurrMinValue(dataChangeDuration);
|
||||
float xMaxValue = xAxis.GetCurrMaxValue(dataChangeDuration);
|
||||
double xMinValue = xAxis.GetCurrMinValue(dataChangeDuration);
|
||||
double xMaxValue = xAxis.GetCurrMaxValue(dataChangeDuration);
|
||||
var isAllBarEnd = true;
|
||||
for (int i = serie.minShow; i < maxCount; i++)
|
||||
{
|
||||
@@ -61,7 +61,7 @@ namespace XCharts
|
||||
var itemStyle = SerieHelper.GetItemStyle(serie, serieData, highlight);
|
||||
|
||||
serieData.canShowLabel = true;
|
||||
float value = showData[i].GetCurrData(1, dataChangeDuration, xAxis.inverse, xMinValue, xMaxValue);
|
||||
double value = showData[i].GetCurrData(1, dataChangeDuration, xAxis.inverse, xMinValue, xMaxValue);
|
||||
float borderWidth = value == 0 ? 0 : itemStyle.runtimeBorderWidth;
|
||||
if (showData[i].IsDataChanged()) dataChanging = true;
|
||||
float axisLineWidth = value == 0 ? 0
|
||||
@@ -79,11 +79,11 @@ 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.runtimeWidth) : 0;
|
||||
barHig = valueTotal != 0 ? (float)((value / valueTotal * grid.runtimeWidth)) : 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -97,8 +97,8 @@ namespace XCharts
|
||||
{
|
||||
valueTotal = xMaxValue - xMinValue;
|
||||
if (valueTotal != 0)
|
||||
barHig = (xMinValue > 0 ? value - xMinValue : value)
|
||||
/ valueTotal * grid.runtimeWidth;
|
||||
barHig = (float)((xMinValue > 0 ? value - xMinValue : value)
|
||||
/ valueTotal * grid.runtimeWidth);
|
||||
}
|
||||
}
|
||||
serieData.runtimeStackHig = barHig;
|
||||
@@ -193,8 +193,8 @@ namespace XCharts
|
||||
var isPercentStack = SeriesHelper.IsPercentStack(m_Series, serie.stack, SerieType.Bar);
|
||||
bool dataChanging = false;
|
||||
float dataChangeDuration = serie.animation.GetUpdateAnimationDuration();
|
||||
float yMinValue = yAxis.GetCurrMinValue(dataChangeDuration);
|
||||
float yMaxValue = yAxis.GetCurrMaxValue(dataChangeDuration);
|
||||
double yMinValue = yAxis.GetCurrMinValue(dataChangeDuration);
|
||||
double yMaxValue = yAxis.GetCurrMaxValue(dataChangeDuration);
|
||||
var isAllBarEnd = true;
|
||||
for (int i = serie.minShow; i < maxCount; i++)
|
||||
{
|
||||
@@ -208,7 +208,7 @@ namespace XCharts
|
||||
|| serie.data[i].highlighted
|
||||
|| serie.highlighted;
|
||||
var itemStyle = SerieHelper.GetItemStyle(serie, serieData, highlight);
|
||||
float value = serieData.GetCurrData(1, dataChangeDuration, yAxis.inverse, yMinValue, yMaxValue);
|
||||
double value = serieData.GetCurrData(1, dataChangeDuration, yAxis.inverse, yMinValue, yMaxValue);
|
||||
float borderWidth = value == 0 ? 0 : itemStyle.runtimeBorderWidth;
|
||||
if (serieData.IsDataChanged()) dataChanging = true;
|
||||
float pX = grid.runtimeX + i * categoryWidth;
|
||||
@@ -240,7 +240,7 @@ namespace XCharts
|
||||
if (yAxis.IsLog())
|
||||
{
|
||||
int minIndex = yAxis.runtimeMinLogIndex;
|
||||
float nowIndex = yAxis.GetLogValue(value);
|
||||
var nowIndex = yAxis.GetLogValue(value);
|
||||
barHig = (nowIndex - minIndex) / yAxis.splitNumber * grid.runtimeHeight;
|
||||
}
|
||||
else
|
||||
@@ -621,10 +621,10 @@ namespace XCharts
|
||||
return gap;
|
||||
}
|
||||
|
||||
public float Internal_GetBarSameStackTotalValue(string stack, int dataIndex, SerieType type)
|
||||
public double Internal_GetBarSameStackTotalValue(string stack, int dataIndex, SerieType type)
|
||||
{
|
||||
if (string.IsNullOrEmpty(stack)) return 0;
|
||||
float total = 0;
|
||||
double total = 0;
|
||||
foreach (var serie in m_Series.list)
|
||||
{
|
||||
if (serie.type == type)
|
||||
|
||||
@@ -31,8 +31,8 @@ namespace XCharts
|
||||
|
||||
bool dataChanging = false;
|
||||
float dataChangeDuration = serie.animation.GetUpdateAnimationDuration();
|
||||
float yMinValue = yAxis.GetCurrMinValue(dataChangeDuration);
|
||||
float yMaxValue = yAxis.GetCurrMaxValue(dataChangeDuration);
|
||||
double yMinValue = yAxis.GetCurrMinValue(dataChangeDuration);
|
||||
double yMaxValue = yAxis.GetCurrMaxValue(dataChangeDuration);
|
||||
var isAllBarEnd = true;
|
||||
var isYAxis = false;
|
||||
for (int i = serie.minShow; i < maxCount; i++)
|
||||
|
||||
@@ -134,7 +134,7 @@ namespace XCharts
|
||||
}
|
||||
else
|
||||
{
|
||||
float yValue = SampleValue(ref showData, serie.sampleType, rate, serie.minShow, maxCount, totalAverage,
|
||||
double yValue = SampleValue(ref showData, serie.sampleType, rate, serie.minShow, maxCount, totalAverage,
|
||||
i, dataChangeDuration, ref dataChanging, yAxis);
|
||||
showData[i].runtimeStackHig = GetDataPoint(xAxis, yAxis, showData, yValue, startX, i, scaleWid, isStack,
|
||||
ref np, dataChangeDuration);
|
||||
@@ -155,7 +155,7 @@ namespace XCharts
|
||||
}
|
||||
else
|
||||
{
|
||||
float yValue = showData[i].GetCurrData(1, dataChangeDuration, yAxis.inverse, yAxis.runtimeMinValue, yAxis.runtimeMaxValue);
|
||||
double yValue = showData[i].GetCurrData(1, dataChangeDuration, yAxis.inverse, yAxis.runtimeMinValue, yAxis.runtimeMaxValue);
|
||||
showData[i].runtimeStackHig = GetDataPoint(xAxis, yAxis, showData, yValue, startX, i, scaleWid, isStack, ref np,
|
||||
dataChangeDuration);
|
||||
serie.dataPoints.Add(np);
|
||||
@@ -188,7 +188,7 @@ namespace XCharts
|
||||
}
|
||||
else
|
||||
{
|
||||
float yValue = showData[i].GetCurrData(1, dataChangeDuration, yAxis.inverse, yAxis.runtimeMinValue, yAxis.runtimeMaxValue);
|
||||
double yValue = showData[i].GetCurrData(1, dataChangeDuration, yAxis.inverse, yAxis.runtimeMinValue, yAxis.runtimeMaxValue);
|
||||
showData[i].runtimeStackHig = GetDataPoint(xAxis, yAxis, showData, yValue, startX, i, scaleWid, isStack, ref firstLastPos, dataChangeDuration);
|
||||
}
|
||||
}
|
||||
@@ -206,7 +206,7 @@ namespace XCharts
|
||||
}
|
||||
else
|
||||
{
|
||||
float yValue = showData[i].GetCurrData(1, dataChangeDuration, yAxis.inverse, yAxis.runtimeMinValue, yAxis.runtimeMaxValue);
|
||||
double yValue = showData[i].GetCurrData(1, dataChangeDuration, yAxis.inverse, yAxis.runtimeMinValue, yAxis.runtimeMaxValue);
|
||||
showData[i].runtimeStackHig = GetDataPoint(xAxis, yAxis, showData, yValue, startX, i, scaleWid, isStack, ref lastNextPos, dataChangeDuration);
|
||||
}
|
||||
}
|
||||
@@ -334,12 +334,12 @@ namespace XCharts
|
||||
return lp;
|
||||
}
|
||||
|
||||
internal float DataAverage(ref List<SerieData> showData, SampleType sampleType, int minCount, int maxCount, int rate)
|
||||
internal double DataAverage(ref List<SerieData> showData, SampleType sampleType, int minCount, int maxCount, int rate)
|
||||
{
|
||||
var totalAverage = 0f;
|
||||
double totalAverage = 0;
|
||||
if (rate > 1 && sampleType == SampleType.Peak)
|
||||
{
|
||||
var total = 0f;
|
||||
double total = 0;
|
||||
for (int i = minCount; i < maxCount; i++)
|
||||
{
|
||||
total += showData[i].data[1];
|
||||
@@ -349,13 +349,13 @@ namespace XCharts
|
||||
return totalAverage;
|
||||
}
|
||||
|
||||
internal float SampleValue(ref List<SerieData> showData, SampleType sampleType, int rate,
|
||||
int minCount, int maxCount, float totalAverage, int index, float dataChangeDuration,
|
||||
internal double SampleValue(ref List<SerieData> showData, SampleType sampleType, int rate,
|
||||
int minCount, int maxCount, double totalAverage, int index, float dataChangeDuration,
|
||||
ref bool dataChanging, Axis axis)
|
||||
{
|
||||
var inverse = axis.inverse;
|
||||
var minValue = axis.runtimeMinValue;
|
||||
var MaxValue = axis.runtimeMaxValue;
|
||||
double minValue = axis.runtimeMinValue;
|
||||
double MaxValue = axis.runtimeMaxValue;
|
||||
if (rate <= 1 || index == minCount)
|
||||
{
|
||||
if (showData[index].IsDataChanged()) dataChanging = true;
|
||||
@@ -365,7 +365,7 @@ namespace XCharts
|
||||
{
|
||||
case SampleType.Sum:
|
||||
case SampleType.Average:
|
||||
float total = 0;
|
||||
double total = 0;
|
||||
for (int i = index; i > index - rate; i--)
|
||||
{
|
||||
total += showData[i].GetCurrData(1, dataChangeDuration, inverse, minValue, MaxValue);
|
||||
@@ -374,7 +374,7 @@ namespace XCharts
|
||||
if (sampleType == SampleType.Average) return total / rate;
|
||||
else return total;
|
||||
case SampleType.Max:
|
||||
float max = float.MinValue;
|
||||
double max = double.MinValue;
|
||||
for (int i = index; i > index - rate; i--)
|
||||
{
|
||||
var value = showData[i].GetCurrData(1, dataChangeDuration, inverse, minValue, MaxValue);
|
||||
@@ -383,7 +383,7 @@ namespace XCharts
|
||||
}
|
||||
return max;
|
||||
case SampleType.Min:
|
||||
float min = float.MaxValue;
|
||||
double min = double.MaxValue;
|
||||
for (int i = index; i > index - rate; i--)
|
||||
{
|
||||
var value = showData[i].GetCurrData(1, dataChangeDuration, inverse, minValue, MaxValue);
|
||||
@@ -392,8 +392,8 @@ namespace XCharts
|
||||
}
|
||||
return min;
|
||||
case SampleType.Peak:
|
||||
max = float.MinValue;
|
||||
min = float.MaxValue;
|
||||
max = double.MinValue;
|
||||
min = double.MaxValue;
|
||||
total = 0;
|
||||
for (int i = index; i > index - rate; i--)
|
||||
{
|
||||
@@ -411,7 +411,7 @@ namespace XCharts
|
||||
return showData[index].GetCurrData(1, dataChangeDuration, inverse, minValue, MaxValue);
|
||||
}
|
||||
|
||||
private float GetDataPoint(Axis xAxis, Axis yAxis, List<SerieData> showData, float yValue, float startX, int i,
|
||||
private float GetDataPoint(Axis xAxis, Axis yAxis, List<SerieData> showData, double yValue, float startX, int i,
|
||||
float scaleWid, bool isStack, ref Vector3 np, float duration, bool isIngoreValue = false)
|
||||
{
|
||||
if (isIngoreValue)
|
||||
@@ -420,15 +420,15 @@ namespace XCharts
|
||||
return 0;
|
||||
}
|
||||
float xDataHig, yDataHig;
|
||||
float xMinValue = xAxis.GetCurrMinValue(duration);
|
||||
float xMaxValue = xAxis.GetCurrMaxValue(duration);
|
||||
float yMinValue = yAxis.GetCurrMinValue(duration);
|
||||
float yMaxValue = yAxis.GetCurrMaxValue(duration);
|
||||
double xMinValue = xAxis.GetCurrMinValue(duration);
|
||||
double xMaxValue = xAxis.GetCurrMaxValue(duration);
|
||||
double yMinValue = yAxis.GetCurrMinValue(duration);
|
||||
double yMaxValue = yAxis.GetCurrMaxValue(duration);
|
||||
if (xAxis.IsValue() || xAxis.IsLog())
|
||||
{
|
||||
var grid = GetAxisGridOrDefault(xAxis);
|
||||
var axisLineWidth = xAxis.axisLine.GetWidth(m_Theme.axis.lineWidth);
|
||||
float xValue = i > showData.Count - 1 ? 0 : showData[i].GetData(0, xAxis.inverse);
|
||||
double xValue = i > showData.Count - 1 ? 0 : showData[i].GetData(0, xAxis.inverse);
|
||||
float pX = grid.runtimeX + axisLineWidth;
|
||||
float pY = grid.runtimeY + axisLineWidth;
|
||||
if (isStack)
|
||||
@@ -447,7 +447,7 @@ namespace XCharts
|
||||
else
|
||||
{
|
||||
if ((xMaxValue - xMinValue) <= 0) xDataHig = 0;
|
||||
else xDataHig = (xValue - xMinValue) / (xMaxValue - xMinValue) * grid.runtimeWidth;
|
||||
else xDataHig = (float)((xValue - xMinValue) / (xMaxValue - xMinValue)) * grid.runtimeWidth;
|
||||
}
|
||||
if (yAxis.IsLog())
|
||||
{
|
||||
@@ -459,7 +459,7 @@ namespace XCharts
|
||||
{
|
||||
double valueTotal = yMaxValue - yMinValue;
|
||||
if (valueTotal <= 0) yDataHig = 0;
|
||||
else yDataHig = (float)((yValue - yMinValue) / valueTotal * grid.runtimeHeight);
|
||||
else yDataHig = (float)((yValue - yMinValue) / valueTotal) * grid.runtimeHeight;
|
||||
}
|
||||
np = new Vector3(pX + xDataHig, pY + yDataHig);
|
||||
}
|
||||
@@ -530,11 +530,11 @@ namespace XCharts
|
||||
if (rate < 1) rate = 1;
|
||||
var dataChanging = false;
|
||||
float dataChangeDuration = serie.animation.GetUpdateAnimationDuration();
|
||||
float xMinValue = xAxis.GetCurrMinValue(dataChangeDuration);
|
||||
float xMaxValue = xAxis.GetCurrMaxValue(dataChangeDuration);
|
||||
double xMinValue = xAxis.GetCurrMinValue(dataChangeDuration);
|
||||
double xMaxValue = xAxis.GetCurrMaxValue(dataChangeDuration);
|
||||
for (i = serie.minShow; i < maxCount; i += rate)
|
||||
{
|
||||
float value = showData[i].GetCurrData(1, dataChangeDuration, xAxis.inverse, xAxis.runtimeMinValue, xAxis.runtimeMaxValue);
|
||||
double value = showData[i].GetCurrData(1, dataChangeDuration, xAxis.inverse, xAxis.runtimeMinValue, xAxis.runtimeMaxValue);
|
||||
float pY = startY + i * scaleWid;
|
||||
float pX = grid.runtimeX + yAxis.axisLine.GetWidth(m_Theme.axis.lineWidth);
|
||||
if (isStack)
|
||||
@@ -553,7 +553,7 @@ namespace XCharts
|
||||
}
|
||||
else
|
||||
{
|
||||
dataHig = (value - xMinValue) / (xMaxValue - xMinValue) * grid.runtimeWidth;
|
||||
dataHig = (float)((value - xMinValue) / (xMaxValue - xMinValue) * grid.runtimeWidth);
|
||||
}
|
||||
showData[i].runtimeStackHig = dataHig;
|
||||
np = new Vector3(pX + dataHig, pY);
|
||||
@@ -567,7 +567,7 @@ namespace XCharts
|
||||
if (maxCount % rate != 0)
|
||||
{
|
||||
i = maxCount - 1;
|
||||
float value = showData[i].GetCurrData(1, dataChangeDuration, xAxis.inverse, xAxis.runtimeMinValue, xAxis.runtimeMaxValue);
|
||||
double value = showData[i].GetCurrData(1, dataChangeDuration, xAxis.inverse, xAxis.runtimeMinValue, xAxis.runtimeMaxValue);
|
||||
float pY = startY + i * scaleWid;
|
||||
float pX = grid.runtimeX + yAxis.axisLine.GetWidth(m_Theme.axis.lineWidth);
|
||||
if (isStack)
|
||||
@@ -586,7 +586,7 @@ namespace XCharts
|
||||
}
|
||||
else
|
||||
{
|
||||
dataHig = (value - xMinValue) / (xMaxValue - xMinValue) * grid.runtimeWidth;
|
||||
dataHig = (float)((value - xMinValue) / (xMaxValue - xMinValue)) * grid.runtimeWidth;
|
||||
}
|
||||
showData[i].runtimeStackHig = dataHig;
|
||||
np = new Vector3(pX + dataHig, pY);
|
||||
@@ -664,9 +664,9 @@ namespace XCharts
|
||||
}
|
||||
}
|
||||
|
||||
private float GetStackValue(List<List<SerieData>> stackDataList, int dataIndex, float dataChangeDuration, Axis xAxis)
|
||||
private double GetStackValue(List<List<SerieData>> stackDataList, int dataIndex, float dataChangeDuration, Axis xAxis)
|
||||
{
|
||||
float value = 0;
|
||||
double value = 0;
|
||||
foreach (var dataList in stackDataList)
|
||||
{
|
||||
value += dataList[dataIndex].GetCurrData(1, dataChangeDuration, xAxis.inverse, xAxis.runtimeMinValue, xAxis.runtimeMaxValue);
|
||||
|
||||
@@ -38,8 +38,8 @@ namespace XCharts
|
||||
var toColor = SerieHelper.GetItemToColor(serie, serieData, m_Theme, colorIndex, highlight);
|
||||
var symbolBorder = SerieHelper.GetSymbolBorder(serie, serieData, m_Theme, highlight);
|
||||
var cornerRadius = SerieHelper.GetSymbolCornerRadius(serie, serieData, highlight);
|
||||
float xValue = serieData.GetCurrData(0, dataChangeDuration, xAxis.inverse);
|
||||
float yValue = serieData.GetCurrData(1, dataChangeDuration, yAxis.inverse);
|
||||
double xValue = serieData.GetCurrData(0, dataChangeDuration, xAxis.inverse);
|
||||
double yValue = serieData.GetCurrData(1, dataChangeDuration, yAxis.inverse);
|
||||
if (serieData.IsDataChanged()) dataChanging = true;
|
||||
float pX = grid.runtimeX + xAxis.axisLine.GetWidth(m_Theme.axis.lineWidth);
|
||||
float pY = grid.runtimeY + yAxis.axisLine.GetWidth(m_Theme.axis.lineWidth);
|
||||
@@ -88,7 +88,7 @@ namespace XCharts
|
||||
}
|
||||
}
|
||||
|
||||
private float GetDataHig(Axis axis, float value, float totalWidth)
|
||||
private float GetDataHig(Axis axis, double value, float totalWidth)
|
||||
{
|
||||
if (axis.IsLog())
|
||||
{
|
||||
|
||||
@@ -196,11 +196,11 @@ namespace XCharts
|
||||
var destAngle = GetCurrAngle(serie, true);
|
||||
serie.animation.InitProgress(0, serie.startAngle, destAngle);
|
||||
var currAngle = serie.animation.IsFinish() ? GetCurrAngle(serie, false) : serie.animation.GetCurrDetail();
|
||||
DrawProgressBar(vh, serie, currAngle);
|
||||
DrawProgressBar(vh, serie, (float)currAngle);
|
||||
DrawStageColor(vh, serie);
|
||||
DrawLineStyle(vh, serie);
|
||||
DrawAxisTick(vh, serie);
|
||||
DrawPointer(vh, serie, currAngle);
|
||||
DrawPointer(vh, serie, (float)currAngle);
|
||||
TitleStyleHelper.CheckTitle(serie, ref chart.m_ReinitTitle, ref m_UpdateTitleText);
|
||||
SerieLabelHelper.CheckLabel(serie, ref chart.m_ReinitLabel, ref m_UpdateLabelText);
|
||||
CheckAnimation(serie);
|
||||
@@ -325,11 +325,11 @@ namespace XCharts
|
||||
{
|
||||
if (serie.animation.HasFadeOut())
|
||||
{
|
||||
return serie.animation.GetCurrDetail();
|
||||
return (float)serie.animation.GetCurrDetail();
|
||||
}
|
||||
float rangeValue = serie.max - serie.min;
|
||||
float rangeAngle = serie.endAngle - serie.startAngle;
|
||||
float value = 0;
|
||||
double value = 0;
|
||||
float angle = serie.startAngle;
|
||||
if (serie.dataCount > 0)
|
||||
{
|
||||
@@ -337,11 +337,11 @@ namespace XCharts
|
||||
serieData.labelPosition = serie.runtimeCenterPos + serie.label.offset;
|
||||
value = dest ? serieData.GetData(1)
|
||||
: serieData.GetCurrData(1, serie.animation.GetUpdateAnimationDuration());
|
||||
value = Mathf.Clamp(value, serie.min, serie.max);
|
||||
value = MathUtil.Clamp(value, serie.min, serie.max);
|
||||
}
|
||||
if (rangeValue > 0)
|
||||
{
|
||||
angle += rangeAngle * (value - serie.min) / rangeValue;
|
||||
angle += rangeAngle * (float)(value - serie.min) / rangeValue;
|
||||
}
|
||||
return angle;
|
||||
}
|
||||
@@ -382,7 +382,7 @@ namespace XCharts
|
||||
? serie.runtimeInsideRadius * serie.gaugePointer.length
|
||||
: serie.gaugePointer.length;
|
||||
if (Vector3.Distance(local, serie.runtimeCenterPos) > len) continue;
|
||||
var currAngle = serie.animation.IsFinish() ? GetCurrAngle(serie, false) : serie.animation.GetCurrDetail();
|
||||
var currAngle = (float)(serie.animation.IsFinish() ? GetCurrAngle(serie, false) : serie.animation.GetCurrDetail());
|
||||
var p1 = ChartHelper.GetPosition(serie.runtimeCenterPos, currAngle, len);
|
||||
var p2 = ChartHelper.GetPosition(serie.runtimeCenterPos, currAngle + 180, serie.gaugePointer.width);
|
||||
var p3 = ChartHelper.GetPosition(serie.runtimeCenterPos, currAngle - 90, serie.gaugePointer.width / 2);
|
||||
|
||||
@@ -224,7 +224,7 @@ namespace XCharts
|
||||
if (value <= 0) return;
|
||||
var colorIndex = chart.m_LegendRealShowName.IndexOf(serie.name);
|
||||
|
||||
var realHig = (value - serie.min) / (serie.max - serie.min) * radius * 2;
|
||||
var realHig = (float)((value - serie.min) / (serie.max - serie.min) * radius * 2);
|
||||
serie.animation.InitProgress(1, 0, realHig);
|
||||
|
||||
var hig = serie.animation.IsFinish() ? realHig : serie.animation.GetCurrDetail();
|
||||
@@ -338,7 +338,7 @@ namespace XCharts
|
||||
var colorIndex = chart.m_LegendRealShowName.IndexOf(serie.name);
|
||||
|
||||
var realHig = (value - serie.min) / (serie.max - serie.min) * vessel.runtimeHeight;
|
||||
serie.animation.InitProgress(1, 0, realHig);
|
||||
serie.animation.InitProgress(1, 0, (float)realHig);
|
||||
var hig = serie.animation.IsFinish() ? realHig : serie.animation.GetCurrDetail();
|
||||
var color = SerieHelper.GetItemColor(serie, serieData, chart.theme, colorIndex, false);
|
||||
var toColor = SerieHelper.GetItemToColor(serie, serieData, chart.theme, colorIndex, false);
|
||||
@@ -351,7 +351,7 @@ namespace XCharts
|
||||
}
|
||||
else
|
||||
{
|
||||
var startY = cenPos.y - vessel.runtimeHeight / 2 + hig;
|
||||
var startY = (float)(cenPos.y - vessel.runtimeHeight / 2 + hig);
|
||||
var waveStartPos = new Vector3(cenPos.x - vessel.runtimeWidth / 2, startY);
|
||||
var waveEndPos = new Vector3(cenPos.x + vessel.runtimeWidth / 2, startY);
|
||||
var startX = waveStartPos.x;
|
||||
|
||||
@@ -199,7 +199,7 @@ namespace XCharts
|
||||
{
|
||||
var serieData = data[n];
|
||||
serieData.index = n;
|
||||
float value = isAllZeroValue ? zeroReplaceValue : serieData.GetCurrData(1, dataChangeDuration);
|
||||
var value = isAllZeroValue ? zeroReplaceValue : serieData.GetCurrData(1, dataChangeDuration);
|
||||
serieData.runtimePieStartAngle = startDegree;
|
||||
serieData.runtimePieToAngle = startDegree;
|
||||
serieData.runtimePieHalfAngle = startDegree;
|
||||
@@ -210,12 +210,11 @@ namespace XCharts
|
||||
}
|
||||
float degree = serie.pieRoseType == RoseType.Area
|
||||
? (totalDegree / showdataCount)
|
||||
: (totalDegree * value / dataTotalFilterMinAngle);
|
||||
: (float)(totalDegree * value / dataTotalFilterMinAngle);
|
||||
if (serie.minAngle > 0 && degree < serie.minAngle) degree = serie.minAngle;
|
||||
serieData.runtimePieToAngle = startDegree + degree;
|
||||
serieData.runtimePieOutsideRadius = serie.pieRoseType > 0 ?
|
||||
serie.runtimeInsideRadius +
|
||||
(serie.runtimeOutsideRadius - serie.runtimeInsideRadius) * value / serie.runtimeDataMax :
|
||||
serie.runtimeInsideRadius + (float)((serie.runtimeOutsideRadius - serie.runtimeInsideRadius) * value / serie.runtimeDataMax) :
|
||||
serie.runtimeOutsideRadius;
|
||||
if (serieData.highlighted)
|
||||
{
|
||||
@@ -266,7 +265,7 @@ namespace XCharts
|
||||
SerieLabelHelper.AvoidLabelOverlap(serie, chart.theme.common);
|
||||
}
|
||||
|
||||
private float GetTotalAngle(Serie serie, float dataTotal, ref float totalAngle)
|
||||
private double GetTotalAngle(Serie serie, double dataTotal, ref float totalAngle)
|
||||
{
|
||||
totalAngle = 360f;
|
||||
if (serie.minAngle > 0)
|
||||
|
||||
@@ -334,15 +334,15 @@ namespace XCharts
|
||||
for (int n = 0; n < dataCount; n++)
|
||||
{
|
||||
if (n >= serieData.data.Count) break;
|
||||
float max = radar.GetIndicatorMax(n);
|
||||
float value = serieData.GetCurrData(n, dataChangeDuration);
|
||||
var max = radar.GetIndicatorMax(n);
|
||||
var value = serieData.GetCurrData(n, dataChangeDuration);
|
||||
if (serieData.IsDataChanged()) dataChanging = true;
|
||||
if (max == 0)
|
||||
{
|
||||
max = serie.runtimeDataMax;
|
||||
}
|
||||
var radius = max < 0 ? radar.runtimeDataRadius - radar.runtimeDataRadius * value / max
|
||||
: radar.runtimeDataRadius * value / max;
|
||||
var radius = (float)(max < 0 ? radar.runtimeDataRadius - radar.runtimeDataRadius * value / max
|
||||
: radar.runtimeDataRadius * value / max);
|
||||
var currAngle = (n + (radar.positionType == Radar.PositionType.Between ? 0.5f : 0)) * angle;
|
||||
radius *= rate;
|
||||
if (n == 0)
|
||||
@@ -505,8 +505,8 @@ namespace XCharts
|
||||
{
|
||||
max = serie.runtimeDataMax;
|
||||
}
|
||||
var radius = max < 0 ? radar.runtimeDataRadius - radar.runtimeDataRadius * value / max
|
||||
: radar.runtimeDataRadius * value / max;
|
||||
var radius = (float)(max < 0 ? radar.runtimeDataRadius - radar.runtimeDataRadius * value / max
|
||||
: radar.runtimeDataRadius * value / max);
|
||||
var currAngle = (index + (radar.positionType == Radar.PositionType.Between ? 0.5f : 0)) * angle;
|
||||
radius *= rate;
|
||||
if (index == startIndex)
|
||||
|
||||
@@ -81,7 +81,7 @@ namespace XCharts
|
||||
if (serieData.IsDataChanged()) dataChanging = true;
|
||||
var value = serieData.GetFirstData(dataChangeDuration);
|
||||
var max = serieData.GetLastData();
|
||||
var degree = 360 * value / max;
|
||||
var degree = (float)(360 * value / max);
|
||||
var startDegree = GetStartAngle(serie);
|
||||
var toDegree = GetToAngle(serie, degree);
|
||||
var itemStyle = SerieHelper.GetItemStyle(serie, serieData, serieData.highlighted);
|
||||
|
||||
@@ -16,7 +16,7 @@ namespace XCharts
|
||||
/// <param name="value">当前label对应的数值数据,Value轴或Time轴有效</param>
|
||||
/// <param name="category">当前label对应的类目数据,Category轴有效</param>
|
||||
/// <returns>最终显示的文本内容</returns>
|
||||
public delegate string DelegateAxisLabelFormatter(int labelIndex, float value, string category);
|
||||
public delegate string DelegateAxisLabelFormatter(int labelIndex, double value, string category);
|
||||
/// <summary>
|
||||
/// The delegate function for SerieLabel‘s formatter.
|
||||
/// SerieLabel的formatter自定义委托。
|
||||
@@ -24,5 +24,5 @@ namespace XCharts
|
||||
/// <param name="dataIndex">数据索引</param>
|
||||
/// <param name="value">数值</param>
|
||||
/// <returns>最终显示的文本内容</returns>
|
||||
public delegate string DelegateSerieLabelFormatter(int dataIndex, float value);
|
||||
public delegate string DelegateSerieLabelFormatter(int dataIndex, double value);
|
||||
}
|
||||
@@ -28,10 +28,10 @@ namespace XCharts
|
||||
private static Dictionary<string, string> s_AxisLabel = new Dictionary<string, string>();
|
||||
|
||||
|
||||
private static Dictionary<float, Dictionary<string, string>> s_NumberToStr = new Dictionary<float, Dictionary<string, string>>();
|
||||
private static Dictionary<double, Dictionary<string, string>> s_NumberToStr = new Dictionary<double, Dictionary<string, string>>();
|
||||
private static Dictionary<int, Dictionary<string, string>> s_PrecisionToStr = new Dictionary<int, Dictionary<string, string>>();
|
||||
|
||||
public static string FloatToStr(float value, string numericFormatter = "F", int precision = 0)
|
||||
public static string FloatToStr(double value, string numericFormatter = "F", int precision = 0)
|
||||
{
|
||||
if (precision > 0 && numericFormatter.Length == 1)
|
||||
{
|
||||
@@ -51,7 +51,7 @@ namespace XCharts
|
||||
}
|
||||
}
|
||||
|
||||
public static string NumberToStr(float value, string formatter)
|
||||
public static string NumberToStr(double value, string formatter)
|
||||
{
|
||||
if (!s_NumberToStr.ContainsKey(value))
|
||||
{
|
||||
|
||||
@@ -725,7 +725,7 @@ namespace XCharts
|
||||
return (Color32)color;
|
||||
}
|
||||
|
||||
public static float GetMaxDivisibleValue(float max, int ceilRate)
|
||||
public static double GetMaxDivisibleValue(double max, int ceilRate)
|
||||
{
|
||||
if (max == 0) return 0;
|
||||
if (max > -1 && max < 1)
|
||||
@@ -742,20 +742,20 @@ namespace XCharts
|
||||
}
|
||||
if (ceilRate == 0)
|
||||
{
|
||||
var bigger = Mathf.Ceil(Mathf.Abs(max));
|
||||
var bigger = Math.Ceiling(Math.Abs(max));
|
||||
int n = 1;
|
||||
while (bigger / (Mathf.Pow(10, n)) > 10)
|
||||
{
|
||||
n++;
|
||||
}
|
||||
float mm = bigger;
|
||||
double mm = bigger;
|
||||
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.Ceil(mm);
|
||||
else return Mathf.Ceil(mm);
|
||||
if (max < 0) return -Math.Ceiling(mm);
|
||||
else return Math.Ceiling(mm);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -765,7 +765,7 @@ namespace XCharts
|
||||
}
|
||||
}
|
||||
|
||||
public static float GetMinDivisibleValue(float min, int ceilRate)
|
||||
public static double GetMinDivisibleValue(double min, int ceilRate)
|
||||
{
|
||||
if (min == 0) return 0;
|
||||
if (min > -1 && min < 1)
|
||||
@@ -782,20 +782,20 @@ namespace XCharts
|
||||
}
|
||||
if (ceilRate == 0)
|
||||
{
|
||||
var bigger = Mathf.Floor(Mathf.Abs(min));
|
||||
var bigger = Math.Floor(Math.Abs(min));
|
||||
int n = 1;
|
||||
while (bigger / (Mathf.Pow(10, n)) > 10)
|
||||
{
|
||||
n++;
|
||||
}
|
||||
float mm = bigger;
|
||||
double mm = bigger;
|
||||
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.Floor(mm);
|
||||
else return Mathf.Floor(mm);
|
||||
if (min < 0) return -Math.Floor(mm);
|
||||
else return Math.Floor(mm);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -805,11 +805,11 @@ namespace XCharts
|
||||
}
|
||||
}
|
||||
|
||||
public static float GetMaxLogValue(float value, float logBase, bool isLogBaseE, out int splitNumber)
|
||||
public static double GetMaxLogValue(double value, float logBase, bool isLogBaseE, out int splitNumber)
|
||||
{
|
||||
splitNumber = 0;
|
||||
if (value <= 0) return 0;
|
||||
float max = 0;
|
||||
double max = 0;
|
||||
while (max < value)
|
||||
{
|
||||
if (isLogBaseE)
|
||||
@@ -825,7 +825,7 @@ namespace XCharts
|
||||
return max;
|
||||
}
|
||||
|
||||
public static float GetMinLogValue(float value, float logBase, bool isLogBaseE, out int splitNumber)
|
||||
public static float GetMinLogValue(double value, float logBase, bool isLogBaseE, out int splitNumber)
|
||||
{
|
||||
splitNumber = 0;
|
||||
if (value > 1) return 1;
|
||||
@@ -845,7 +845,7 @@ namespace XCharts
|
||||
return min;
|
||||
}
|
||||
|
||||
public static int GetFloatAccuracy(float value)
|
||||
public static int GetFloatAccuracy(double value)
|
||||
{
|
||||
if (value > 1 || value < -1) return 0;
|
||||
int count = 1;
|
||||
|
||||
52
Runtime/Internal/Utility/MathUtil.cs
Normal file
52
Runtime/Internal/Utility/MathUtil.cs
Normal file
@@ -0,0 +1,52 @@
|
||||
/************************************************/
|
||||
/* */
|
||||
/* Copyright (c) 2018 - 2021 monitor1394 */
|
||||
/* https://github.com/monitor1394 */
|
||||
/* */
|
||||
/************************************************/
|
||||
|
||||
using System.Text;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text.RegularExpressions;
|
||||
using UnityEngine;
|
||||
using UnityEngine.EventSystems;
|
||||
using UnityEngine.UI;
|
||||
|
||||
namespace XCharts
|
||||
{
|
||||
public static class MathUtil
|
||||
{
|
||||
public static double Abs(double d)
|
||||
{
|
||||
return d > 0 ? d : -d;
|
||||
}
|
||||
|
||||
public static double Clamp(double d, double min, double max)
|
||||
{
|
||||
if (d >= min && d <= max) return d;
|
||||
else if (d < min) return min;
|
||||
else return max;
|
||||
}
|
||||
|
||||
public static bool Approximately(double a, double b)
|
||||
{
|
||||
return Math.Abs(b - a) < Math.Max(0.000001f * Math.Max(Math.Abs(a), Math.Abs(b)), Mathf.Epsilon * 8);
|
||||
}
|
||||
|
||||
public static double Clamp01(double value)
|
||||
{
|
||||
if (value < 0F)
|
||||
return 0F;
|
||||
else if (value > 1F)
|
||||
return 1F;
|
||||
else
|
||||
return value;
|
||||
}
|
||||
|
||||
public static double Lerp(double a, double b, double t)
|
||||
{
|
||||
return a + (b - a) * Clamp01(t);
|
||||
}
|
||||
}
|
||||
}
|
||||
11
Runtime/Internal/Utility/MathUtil.cs.meta
Normal file
11
Runtime/Internal/Utility/MathUtil.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 094dc7b90e3a049b48f15f990c050db1
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user