{ "$schema": "https://ui.shadcn.com/schema/registry-item.json", "name": "chart", "title": "Chart", "description": "Polaris-styled Chart component.", "dependencies": [ "recharts" ], "devDependencies": [ "@shopify/polaris-types" ], "registryDependencies": [ "@polaris-shadcn/theme", "@polaris-shadcn/utils" ], "files": [ { "path": "registry/templates/components/ui/chart.tsx", "content": "import * as React from \"react\";\nimport { Legend, ResponsiveContainer, Tooltip } from \"recharts\";\nimport { cn } from \"../../lib/utils\";\n\nexport interface ChartConfigTheme {\n light?: string;\n dark?: string;\n}\n\nexport interface ChartConfigEntry {\n label?: React.ReactNode;\n icon?: React.ComponentType<{\n className?: string;\n style?: React.CSSProperties;\n }>;\n color?: string;\n theme?: ChartConfigTheme;\n}\n\nexport type ChartConfig = Record;\n\nexport type ChartDataRow = Record;\n\ninterface ChartContextValue {\n config: ChartConfig | undefined;\n}\n\nconst ChartContext = React.createContext(null);\n\nfunction useChart() {\n const context = React.useContext(ChartContext);\n if (!context) {\n throw new Error(\"Chart components must be used within \");\n }\n return context;\n}\n\ninterface ChartStyleProps {\n id: string;\n config: ChartConfig | undefined;\n}\n\nfunction ChartStyle({ id, config }: ChartStyleProps) {\n const entries = Object.entries(config ?? {});\n const colorEntries = entries.filter(([, value]) => value?.color || value?.theme);\n\n if (!colorEntries.length) return null;\n\n const lightVariables = colorEntries\n .map(([key, value]) => {\n if (value?.color) return `--color-${key}: ${value.color}`;\n if (value?.theme?.light) return `--color-${key}: ${value.theme.light}`;\n return null;\n })\n .filter(Boolean)\n .join(\";\");\n\n const darkVariables = colorEntries\n .map(([key, value]) => {\n if (value?.theme?.dark) return `--color-${key}: ${value.theme.dark}`;\n return null;\n })\n .filter(Boolean)\n .join(\";\");\n\n const css = [\n `[data-chart=${id}] { ${lightVariables}; }`,\n darkVariables ? `.dark [data-chart=${id}] { ${darkVariables}; }` : null,\n ]\n .filter(Boolean)\n .join(\"\\n\");\n\n return