From c4bd7e32824081e1443f47c5180e78283440073d Mon Sep 17 00:00:00 2001 From: Matthias Date: Wed, 8 Apr 2026 12:19:15 +0200 Subject: [PATCH] chore(deps): add recharts version 3.8.0 to package.json and update pnpm-lock.yaml --- .worktree/dashboard-credits-chart | 1 + components/ui/chart.tsx | 373 ++++++++++++++++++++++++++++++ package.json | 1 + pnpm-lock.yaml | 11 +- 4 files changed, 382 insertions(+), 4 deletions(-) create mode 160000 .worktree/dashboard-credits-chart create mode 100644 components/ui/chart.tsx diff --git a/.worktree/dashboard-credits-chart b/.worktree/dashboard-credits-chart new file mode 160000 index 0000000..96d9c89 --- /dev/null +++ b/.worktree/dashboard-credits-chart @@ -0,0 +1 @@ +Subproject commit 96d9c895ad20672ef4f75f9b93c730836196ed80 diff --git a/components/ui/chart.tsx b/components/ui/chart.tsx new file mode 100644 index 0000000..7c2dc84 --- /dev/null +++ b/components/ui/chart.tsx @@ -0,0 +1,373 @@ +"use client" + +import * as React from "react" +import * as RechartsPrimitive from "recharts" +import type { TooltipValueType } from "recharts" + +import { cn } from "@/lib/utils" + +// Format: { THEME_NAME: CSS_SELECTOR } +const THEMES = { light: "", dark: ".dark" } as const + +const INITIAL_DIMENSION = { width: 320, height: 200 } as const +type TooltipNameType = number | string + +export type ChartConfig = Record< + string, + { + label?: React.ReactNode + icon?: React.ComponentType + } & ( + | { color?: string; theme?: never } + | { color?: never; theme: Record } + ) +> + +type ChartContextProps = { + config: ChartConfig +} + +const ChartContext = React.createContext(null) + +function useChart() { + const context = React.useContext(ChartContext) + + if (!context) { + throw new Error("useChart must be used within a ") + } + + return context +} + +function ChartContainer({ + id, + className, + children, + config, + initialDimension = INITIAL_DIMENSION, + ...props +}: React.ComponentProps<"div"> & { + config: ChartConfig + children: React.ComponentProps< + typeof RechartsPrimitive.ResponsiveContainer + >["children"] + initialDimension?: { + width: number + height: number + } +}) { + const uniqueId = React.useId() + const chartId = `chart-${id ?? uniqueId.replace(/:/g, "")}` + + return ( + +
+ + + {children} + +
+
+ ) +} + +const ChartStyle = ({ id, config }: { id: string; config: ChartConfig }) => { + const colorConfig = Object.entries(config).filter( + ([, config]) => config.theme ?? config.color + ) + + if (!colorConfig.length) { + return null + } + + return ( +