Skip to content

Commit

Permalink
fix: improve day boundary calculation
Browse files Browse the repository at this point in the history
  • Loading branch information
filipgutica committed Dec 11, 2024
1 parent 21d468e commit 60f4164
Showing 1 changed file with 4 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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) {

Expand Down Expand Up @@ -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(() => {
Expand Down

0 comments on commit 60f4164

Please sign in to comment.