({
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
})
| 105 | const ChartTooltip = RechartsPrimitive.Tooltip |
| 106 | |
| 107 | function ChartTooltipContent({ |
| 108 | active, |
| 109 | payload, |
| 110 | className, |
| 111 | indicator = "dot", |
| 112 | hideLabel = false, |
| 113 | hideIndicator = false, |
| 114 | label, |
| 115 | labelFormatter, |
| 116 | labelClassName, |
| 117 | formatter, |
| 118 | color, |
| 119 | nameKey, |
| 120 | labelKey, |
| 121 | }: React.ComponentProps<typeof RechartsPrimitive.Tooltip> & |
| 122 | React.ComponentProps<"div"> & { |
| 123 | hideLabel?: boolean |
| 124 | hideIndicator?: boolean |
| 125 | indicator?: "line" | "dot" | "dashed" |
| 126 | nameKey?: string |
| 127 | labelKey?: string |
| 128 | }) { |
| 129 | const { config } = useChart() |
| 130 | |
| 131 | const tooltipLabel = React.useMemo(() => { |
| 132 | if (hideLabel || !payload?.length) { |
| 133 | return null |
| 134 | } |
| 135 | |
| 136 | const [item] = payload |
| 137 | const key = `${labelKey || item?.dataKey || item?.name || "value"}` |
| 138 | const itemConfig = getPayloadConfigFromPayload(config, item, key) |
| 139 | const value = |
| 140 | !labelKey && typeof label === "string" |
| 141 | ? config[label as keyof typeof config]?.label || label |
| 142 | : itemConfig?.label |
| 143 | |
| 144 | if (labelFormatter) { |
| 145 | return ( |
| 146 | <div className={cn("font-medium", labelClassName)}> |
| 147 | {labelFormatter(value, payload)} |
| 148 | </div> |
| 149 | ) |
| 150 | } |
| 151 | |
| 152 | if (!value) { |
| 153 | return null |
| 154 | } |
| 155 | |
| 156 | return <div className={cn("font-medium", labelClassName)}>{value}</div> |
| 157 | }, [ |
| 158 | label, |
| 159 | labelFormatter, |
| 160 | payload, |
| 161 | hideLabel, |
| 162 | labelClassName, |
| 163 | config, |
| 164 | labelKey, |
nothing calls this directly
no test coverage detected