graph chart引入&骑行结果弹窗
This commit is contained in:
1 parent
40d118cea3
commit
96f3644b5b
2374 files changed
+485161
-2410
No files matched your search
@@ -0,0 +1,71 @@
|
||||
#define Graph_And_Chart_PRO
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using UnityEngine;
|
||||
|
||||
namespace ChartAndGraph
|
||||
{
|
||||
/// <summary>
|
||||
/// advanced settings for charts (currently includes fraction digits)
|
||||
/// </summary>
|
||||
[Serializable]
|
||||
class ChartAdancedSettings
|
||||
{
|
||||
private static ChartAdancedSettings mInstance;
|
||||
public static ChartAdancedSettings Instance
|
||||
{
|
||||
get
|
||||
{
|
||||
if (mInstance == null)
|
||||
mInstance = new ChartAdancedSettings();
|
||||
return mInstance;
|
||||
}
|
||||
}
|
||||
|
||||
private static string[] FractionDigits = new string[]
|
||||
{
|
||||
"{0:0}",
|
||||
"{0:0.#}",
|
||||
"{0:0.##}",
|
||||
"{0:0.###}",
|
||||
"{0:0.####}",
|
||||
"{0:0.#####}",
|
||||
"{0:0.######}",
|
||||
"{0:0.#######}",
|
||||
};
|
||||
|
||||
[Range(0, 7)]
|
||||
public int ValueFractionDigits = 2;
|
||||
[Range(0, 7)]
|
||||
public int AxisFractionDigits = 2;
|
||||
|
||||
private string InnerFormat(string format,double val)
|
||||
{
|
||||
try
|
||||
{
|
||||
return string.Format(format, val);
|
||||
}
|
||||
catch
|
||||
{
|
||||
|
||||
}
|
||||
return " ";
|
||||
}
|
||||
|
||||
string getFormat(int value)
|
||||
{
|
||||
value = Mathf.Clamp(value, 0, 7);
|
||||
return FractionDigits[value];
|
||||
}
|
||||
|
||||
public string FormatFractionDigits(int digits,double val,string format = null)
|
||||
{
|
||||
if(String.IsNullOrEmpty(format))
|
||||
return InnerFormat(getFormat(digits), val);
|
||||
return InnerFormat(format, val);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user