增加折线图对数轴Log的支持

This commit is contained in:
monitor1394
2020-01-15 19:41:21 +08:00
parent 4e709ab253
commit f5037dafb1
9 changed files with 198 additions and 34 deletions

View File

@@ -416,7 +416,6 @@ namespace XCharts
}
return list;
}
}
public static List<string> ParseStringFromString(string jsonData)
@@ -504,6 +503,46 @@ namespace XCharts
else return Mathf.FloorToInt(mm);
}
public static float GetMaxLogValue(float value, float logBase, bool isLogBaseE, out int splitNumber)
{
splitNumber = 0;
if (value <= 0) return 0;
float max = 0;
while (max < value)
{
if (isLogBaseE)
{
max = Mathf.Exp(splitNumber);
}
else
{
max = Mathf.Pow(logBase, splitNumber);
}
splitNumber++;
}
return max;
}
public static float GetMinLogValue(float value, float logBase, bool isLogBaseE, out int splitNumber)
{
splitNumber = 0;
if (value > 1) return 1;
float min = 1;
while (splitNumber < 12 && min > value)
{
if (isLogBaseE)
{
min = Mathf.Exp(-splitNumber);
}
else
{
min = Mathf.Pow(logBase, -splitNumber);
}
splitNumber++;
}
return min;
}
public static int GetFloatAccuracy(float value)
{
if (value > 1 || value < -1) return 0;