{!nestLabel ? tooltipLabel : null}
@@ -293,20 +293,25 @@ function ChartTooltipContent({
{sortedPayload.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
- const seriesLabel = itemConfig?.label ?? item.name
+ const key = `${nameKey || item.name || item.dataKey || "value"}`;
+ const itemConfig = getPayloadConfigFromPayload(config, item, key);
+ const indicatorColor = color || item.payload?.fill || item.color;
+ const seriesLabel = itemConfig?.label ?? item.name;
// Back-compat path: legacy `formatter` prop replaces the whole row.
// Only honored when no new-shape props were passed.
- if (formatter && !usingNewRow && item?.value !== undefined && item.name) {
+ if (
+ formatter &&
+ !usingNewRow &&
+ item?.value !== undefined &&
+ item.name
+ ) {
return (
svg]:h-2.5 [&>svg]:w-2.5 [&>svg]:text-muted-foreground",
- indicator === "dot" && "items-center"
+ indicator === "dot" && "items-center",
)}
>
{(formatter as unknown as LegacyFormatter)(
@@ -317,7 +322,7 @@ function ChartTooltipContent({
item.payload,
)}
- )
+ );
}
return (
@@ -325,7 +330,7 @@ function ChartTooltipContent({
key={item.dataKey}
className={cn(
"flex w-full flex-wrap items-stretch gap-2 [&>svg]:h-2.5 [&>svg]:w-2.5 [&>svg]:text-muted-foreground",
- indicator === "dot" && "items-center"
+ indicator === "dot" && "items-center",
)}
>
{itemConfig?.icon ? (
@@ -341,7 +346,7 @@ function ChartTooltipContent({
"w-0 border-[1.5px] border-dashed bg-transparent":
indicator === "dashed",
"my-0.5": nestLabel && indicator === "dashed",
- }
+ },
)}
style={
{
@@ -355,33 +360,35 @@ function ChartTooltipContent({
{nestLabel ? tooltipLabel : null}
{seriesLabel}
- {item.value !== undefined && item.value !== null && (() => {
- const secondary = secondaryFormatter
- ? secondaryFormatter(item.value, item, numericTotal)
- : null
- return (
-
-
- {renderValue(item)}
-
- {secondary != null && (
-
- {secondary}
+ {item.value !== undefined &&
+ item.value !== null &&
+ (() => {
+ const secondary = secondaryFormatter
+ ? secondaryFormatter(item.value, item, numericTotal)
+ : null;
+ return (
+
+
+ {renderValue(item)}
- )}
-
- )
- })()}
+ {secondary != null && (
+
+ {secondary}
+
+ )}
+
+ );
+ })()}