diff --git a/Runtime/Utilities/DateTimeUtil.cs b/Runtime/Utilities/DateTimeUtil.cs index 8d569f01..77b27def 100644 --- a/Runtime/Utilities/DateTimeUtil.cs +++ b/Runtime/Utilities/DateTimeUtil.cs @@ -128,8 +128,9 @@ namespace XCharts.Runtime if (range >= ONE_YEAR * MIN_TIME_SPLIT_NUMBER) { var num = splitNumber <= 0 ? GetSplitNumber(range, ONE_YEAR) : Math.Max(range / (splitNumber * ONE_YEAR), 1); - var dtStart = (firstValue == 0 || secondValue == 0) ? new DateTime(dtMin.Year + 1, 1, 1) : - (minTimestamp > firstValue ? DateTimeUtil.GetDateTime(secondValue) : DateTimeUtil.GetDateTime(firstValue)); + var dtStart = (firstValue == 0 || secondValue == 0 || (minTimestamp > firstValue && minTimestamp > secondValue)) + ? (new DateTime(dtMin.Year, dtMin.Month, 1).AddMonths(1)) + : (minTimestamp > firstValue ? DateTimeUtil.GetDateTime(secondValue) : DateTimeUtil.GetDateTime(firstValue)); tick = num * 365 * 24 * 3600; while (dtStart.Ticks < dtMax.Ticks) { @@ -140,8 +141,9 @@ namespace XCharts.Runtime else if (range >= ONE_MONTH * MIN_TIME_SPLIT_NUMBER) { var num = splitNumber <= 0 ? GetSplitNumber(range, ONE_MONTH) : Math.Max(range / (splitNumber * ONE_MONTH), 1); - var dtStart = (firstValue == 0 || secondValue == 0) ? (new DateTime(dtMin.Year, dtMin.Month, 1).AddMonths(1)) : - (minTimestamp > firstValue ? DateTimeUtil.GetDateTime(secondValue) : DateTimeUtil.GetDateTime(firstValue)); + var dtStart = (firstValue == 0 || secondValue == 0 || (minTimestamp > firstValue && minTimestamp > secondValue)) + ? (new DateTime(dtMin.Year, dtMin.Month, 1).AddMonths(1)) + : (minTimestamp > firstValue ? DateTimeUtil.GetDateTime(secondValue) : DateTimeUtil.GetDateTime(firstValue)); tick = num * 30 * 24 * 3600; while (dtStart.Ticks < dtMax.Ticks) {