feat: add ChartLegend

This commit is contained in:
hamster1963 2024-10-09 23:16:38 +08:00
parent 3361fa1dff
commit a07113a0bf
2 changed files with 7 additions and 2 deletions

View File

@ -13,6 +13,8 @@ import {
import {
ChartConfig,
ChartContainer,
ChartLegend,
ChartLegendContent,
ChartTooltip,
ChartTooltipContent,
} from "@/components/ui/chart";
@ -228,6 +230,9 @@ export function NetworkChart({
/>
}
/>
{activeChart === defaultChart && (
<ChartLegend content={<ChartLegendContent />} />
)}
{activeChart !== defaultChart && (
<Line
isAnimationActive={false}

View File

@ -280,7 +280,7 @@ const ChartLegendContent = React.forwardRef<
<div
ref={ref}
className={cn(
"flex items-center justify-center gap-4",
"flex flex-wrap items-center justify-center gap-4",
verticalAlign === "top" ? "pb-3" : "pt-3",
className,
)}
@ -306,7 +306,7 @@ const ChartLegendContent = React.forwardRef<
}}
/>
)}
{itemConfig?.label}
{key}
</div>
);
})}