From 71ecebb466df5fbc93d122895252f881b1c3fda8 Mon Sep 17 00:00:00 2001 From: monitor1394 Date: Sat, 20 Jul 2024 22:21:22 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96`Axis`=E4=B8=BA`Time`?= =?UTF-8?q?=E6=97=B6=E9=97=B4=E8=BD=B4=E6=97=B6=E7=9A=84=E5=88=86=E5=89=B2?= =?UTF-8?q?=E6=95=88=E6=9E=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Runtime/Utilities/DateTimeUtil.cs | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) 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) {