Skip to content

:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.

1.1 KB
Raw Blame
import { DefaultTooltip, TooltipConfig, TooltipContext } from '@posthog/quill-charts'

import { SqlChartProps } from './SqlChart'
import { SqlLineSeriesMeta, formatSqlSeriesValue } from './sqlLineGraphAdapter'

export function SqlChartTooltip({
    context,
    config,
    onPointClick,
    hint,
}: {
    context: TooltipContext<SqlLineSeriesMeta>
    config?: TooltipConfig
    onPointClick: NonNullable<SqlChartProps['onPointClick']>
    hint?: string
}): JSX.Element {
    return (
        <DefaultTooltip
            {...context}
            valueFormatter={
                config?.valueFormatter ?? ((value, entry) => formatSqlSeriesValue(value, entry.series.meta?.settings))
            }
            labelFormatter={config?.labelFormatter}
            showTotal={config?.showTotal}
            totalFormatter={config?.totalFormatter}
            sortedByValue
            footer={hint ?? 'Click a series to inspect'}
            onRowClick={(entry) => {
                context.onUnpin?.()
                onPointClick(entry.series.key, context.dataIndex, context.label)
            }}
        />
    )
}