ChartTooltipContent() — ui Function Reference
Architecture documentation for the ChartTooltipContent() function in chart.tsx from the ui codebase.
Entity Profile
Dependency Diagram
graph TD 64c0b62c_bd1a_bff6_2b94_155d8bab5d19["ChartTooltipContent()"] bca50faa_8d6b_703f_dfd2_c4cbfa71c486["chart.tsx"] 64c0b62c_bd1a_bff6_2b94_155d8bab5d19 -->|defined in| bca50faa_8d6b_703f_dfd2_c4cbfa71c486 0c80dc08_73ee_e661_7de0_f8ea1e4e6156["useChart()"] 64c0b62c_bd1a_bff6_2b94_155d8bab5d19 -->|calls| 0c80dc08_73ee_e661_7de0_f8ea1e4e6156 422aa192_5d49_751c_ba2c_7d8886325ec4["getPayloadConfigFromPayload()"] 64c0b62c_bd1a_bff6_2b94_155d8bab5d19 -->|calls| 422aa192_5d49_751c_ba2c_7d8886325ec4 style 64c0b62c_bd1a_bff6_2b94_155d8bab5d19 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
apps/v4/registry/bases/radix/ui/chart.tsx lines 107–248
function ChartTooltipContent({
active,
payload,
className,
indicator = "dot",
hideLabel = false,
hideIndicator = false,
label,
labelFormatter,
labelClassName,
formatter,
color,
nameKey,
labelKey,
}: React.ComponentProps<typeof RechartsPrimitive.Tooltip> &
React.ComponentProps<"div"> & {
hideLabel?: boolean
hideIndicator?: boolean
indicator?: "line" | "dot" | "dashed"
nameKey?: string
labelKey?: string
}) {
const { config } = useChart()
const tooltipLabel = React.useMemo(() => {
if (hideLabel || !payload?.length) {
return null
}
const [item] = payload
const key = `${labelKey || item?.dataKey || item?.name || "value"}`
const itemConfig = getPayloadConfigFromPayload(config, item, key)
const value =
!labelKey && typeof label === "string"
? config[label as keyof typeof config]?.label || label
: itemConfig?.label
if (labelFormatter) {
return (
<div className={cn("font-medium", labelClassName)}>
{labelFormatter(value, payload)}
</div>
)
}
if (!value) {
return null
}
return <div className={cn("font-medium", labelClassName)}>{value}</div>
}, [
label,
labelFormatter,
payload,
hideLabel,
labelClassName,
config,
labelKey,
])
if (!active || !payload?.length) {
return null
}
const nestLabel = payload.length === 1 && indicator !== "dot"
return (
<div
className={cn("cn-chart-tooltip grid min-w-32 items-start", className)}
>
{!nestLabel ? tooltipLabel : null}
<div className="grid gap-1.5">
{payload
.filter((item) => item.type !== "none")
.map((item, index) => {
const key = `${nameKey || item.name || item.dataKey || "value"}`
const itemConfig = getPayloadConfigFromPayload(config, item, key)
const indicatorColor = color || item.payload.fill || item.color
return (
<div
Domain
Subdomains
Defined In
Source
Frequently Asked Questions
What does ChartTooltipContent() do?
ChartTooltipContent() is a function in the ui codebase, defined in apps/v4/registry/bases/radix/ui/chart.tsx.
Where is ChartTooltipContent() defined?
ChartTooltipContent() is defined in apps/v4/registry/bases/radix/ui/chart.tsx at line 107.
What does ChartTooltipContent() call?
ChartTooltipContent() calls 2 function(s): getPayloadConfigFromPayload, useChart.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free