mirror of
https://github.com/XCharts-Team/XCharts.git
synced 2026-05-23 09:20:08 +00:00
优化Axis的数值Label的默认显示格式
This commit is contained in:
@@ -1,10 +1,5 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.Text.RegularExpressions;
|
||||
using UnityEngine;
|
||||
using UnityEngine.EventSystems;
|
||||
using UnityEngine.UI;
|
||||
|
||||
namespace XCharts.Runtime
|
||||
{
|
||||
@@ -41,5 +36,23 @@ namespace XCharts.Runtime
|
||||
{
|
||||
return a + (b - a) * Clamp01(t);
|
||||
}
|
||||
|
||||
public static bool IsInteger(double value)
|
||||
{
|
||||
return Math.Abs(value % 1) <= (Double.Epsilon * 100);
|
||||
}
|
||||
|
||||
public static int GetPrecision(double value)
|
||||
{
|
||||
if (IsInteger(value)) return 0;
|
||||
int count = 1;
|
||||
double intvalue = value * Mathf.Pow(10, count);
|
||||
while (!IsInteger(intvalue) && count < 38)
|
||||
{
|
||||
count++;
|
||||
intvalue = value * Mathf.Pow(10, count);
|
||||
}
|
||||
return count;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user