[improve][axis] improve max value and division of y axis

This commit is contained in:
monitor1394
2022-10-18 08:33:12 +08:00
parent a78eed9c5c
commit b1eae7045b
3 changed files with 16 additions and 4 deletions

View File

@@ -233,7 +233,9 @@ namespace XCharts
{
var each = GetTick(range);
tick = each;
if (range / tick > 8)
if (range / 4 % each == 0)
tick = range / 4;
else if (range / tick > 8)
tick = 2 * each;
else if (range / tick < 4)
tick = each / 2;
@@ -273,6 +275,7 @@ namespace XCharts
private static double GetTick(double max)
{
if (max <= 1) return max / 5;
if (max > 1 && max < 10) return 1;
var bigger = Math.Ceiling(Math.Abs(max));
int n = 1;
while (bigger / (Mathf.Pow(10, n)) > 10)