import dayjs from 'dayjs' import type { TooltipProps } from 'recharts' import { formatDuration } from '../QueryInsightsTable/QueryInsightsTable.utils' import { isTimeMetric } from './QueryInsightsChart.utils' import { guessLocalTimezone } from '@/lib/dayjs' export const QueryInsightsChartTooltip = ({ active, payload }: TooltipProps) => { if (!active || !payload?.length) return null const time = payload[0]?.payload?.time const localTimeZone = guessLocalTimezone() return (

{localTimeZone}

{dayjs(time).format('MMM D, hh:mm:ssa')}

{payload.map((entry, index) => (
{entry.name} {typeof entry.value === 'number' ? isTimeMetric(typeof entry.dataKey === 'string' ? entry.dataKey : '') ? formatDuration(entry.value) : entry.value.toLocaleString() : entry.value}
))}
) }