mirror of
https://github.com/fankes/beszel.git
synced 2025-10-19 09:49:28 +08:00
truncate tooltip container name if very long
This commit is contained in:
@@ -157,6 +157,7 @@ export default memo(function ContainerChart({
|
|||||||
<ChartTooltip
|
<ChartTooltip
|
||||||
animationEasing="ease-out"
|
animationEasing="ease-out"
|
||||||
animationDuration={150}
|
animationDuration={150}
|
||||||
|
truncate={true}
|
||||||
labelFormatter={(_, data) => formatShortDate(data[0].payload.created)}
|
labelFormatter={(_, data) => formatShortDate(data[0].payload.created)}
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
itemSorter={(a, b) => b.value - a.value}
|
itemSorter={(a, b) => b.value - a.value}
|
||||||
|
@@ -99,6 +99,7 @@ const ChartTooltipContent = React.forwardRef<
|
|||||||
unit?: string
|
unit?: string
|
||||||
filter?: string
|
filter?: string
|
||||||
contentFormatter?: (item: any, key: string) => React.ReactNode | string
|
contentFormatter?: (item: any, key: string) => React.ReactNode | string
|
||||||
|
truncate?: boolean
|
||||||
}
|
}
|
||||||
>(
|
>(
|
||||||
(
|
(
|
||||||
@@ -119,6 +120,7 @@ const ChartTooltipContent = React.forwardRef<
|
|||||||
filter,
|
filter,
|
||||||
itemSorter,
|
itemSorter,
|
||||||
contentFormatter: content = undefined,
|
contentFormatter: content = undefined,
|
||||||
|
truncate = false,
|
||||||
},
|
},
|
||||||
ref
|
ref
|
||||||
) => {
|
) => {
|
||||||
@@ -214,10 +216,15 @@ const ChartTooltipContent = React.forwardRef<
|
|||||||
nestLabel ? "items-end" : "items-center"
|
nestLabel ? "items-end" : "items-center"
|
||||||
)}
|
)}
|
||||||
>
|
>
|
||||||
<div className="grid gap-1.5">
|
|
||||||
{nestLabel ? tooltipLabel : null}
|
{nestLabel ? tooltipLabel : null}
|
||||||
<span className="text-muted-foreground">{itemConfig?.label || item.name}</span>
|
<span
|
||||||
</div>
|
className={cn(
|
||||||
|
"text-muted-foreground",
|
||||||
|
truncate ? "max-w-40 truncate leading-normal -my-1" : ""
|
||||||
|
)}
|
||||||
|
>
|
||||||
|
{itemConfig?.label || item.name}
|
||||||
|
</span>
|
||||||
{item.value !== undefined && (
|
{item.value !== undefined && (
|
||||||
<span className="font-medium tabular-nums text-foreground">
|
<span className="font-medium tabular-nums text-foreground">
|
||||||
{content && typeof content === "function"
|
{content && typeof content === "function"
|
||||||
|
Reference in New Issue
Block a user