From 60f416470b41f7673a2face8f2513300eb484105 Mon Sep 17 00:00:00 2001 From: Filip Gutica Date: Wed, 11 Dec 2024 13:02:56 -0800 Subject: [PATCH] fix: improve day boundary calculation --- .../analytics-chart/src/composables/useLineChartOptions.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/packages/analytics/analytics-chart/src/composables/useLineChartOptions.ts b/packages/analytics/analytics-chart/src/composables/useLineChartOptions.ts index b5a13bb965..aac041b322 100644 --- a/packages/analytics/analytics-chart/src/composables/useLineChartOptions.ts +++ b/packages/analytics/analytics-chart/src/composables/useLineChartOptions.ts @@ -12,6 +12,7 @@ import { horizontalTooltipPositioning, tooltipBehavior, verticalTooltipPositioni import { isNullOrUndef } from 'chart.js/helpers' import type { ExternalTooltipContext, LineChartOptions } from '../types' import type { GranularityValues } from '@kong-ui-public/analytics-utilities' +import { millisecondsToHours } from 'date-fns' export default function useLinechartOptions(chartOptions: LineChartOptions) { @@ -129,9 +130,10 @@ export default function useLinechartOptions(chartOptions: LineChartOptions) { }) const dayBoundaryCrossed = computed(() => { + const timeRange = Number(chartOptions.timeRangeMs.value) const now = new Date() - const start = new Date(now.getTime() - Number(chartOptions.timeRangeMs.value)) - return start.getDate() !== now.getDate() + const start = new Date(now.getTime() - timeRange) + return millisecondsToHours(timeRange) > 24 || start.getDate() !== now.getDate() }) const options = computed(() => {