{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "category-distribution-chart",
  "title": "Category Distribution Chart",
  "type": "registry:ui",
  "files": [
    {
      "path": "packages/registry-react/components/charts/category-distribution-chart/CategoryDistributionChart.tsx",
      "content": "'use client'\n\nimport * as React from 'react'\nimport { cn } from '@/lib/utils'\nimport { ChartFrame } from '../shared'\n\n// CategoryDistributionChart — dependency-free KPI + share bar\n// ─────────────────────────────────────────────────────────────────────────\n\nexport interface DistributionSlice {\n  label: string\n  /** Share of the whole; auto-normalised when the sum is not 100. */\n  percentage: number\n  value?: string | number\n  color?: string\n}\n\nexport interface CategoryDistributionChartProps {\n  primaryValue: string | number\n  primaryLabel?: string\n  trend?: { value: string; direction: 'up' | 'down' }\n  categories: DistributionSlice[]\n  height?: number | string\n  showLegend?: boolean\n  colors?: string[]\n  className?: string\n  /** Accessible name announced for the chart image. Defaults to \"Chart\". */\n  ariaLabel?: string\n}\n\nconst DEFAULT_COLORS = ['var(--chart-1)', 'var(--chart-2)', 'var(--chart-3)', 'var(--chart-4)', 'var(--chart-5)']\n\nexport const CategoryDistributionChart = React.forwardRef<HTMLDivElement, CategoryDistributionChartProps>(\n  (\n    {\n      primaryValue,\n      primaryLabel,\n      trend,\n      categories,\n      height = 220,\n      showLegend = true,\n      colors = DEFAULT_COLORS,\n      className,\n      ariaLabel,\n    },\n    ref,\n  ) => {\n    const total = categories.reduce((s, c) => s + c.percentage, 0) || 1\n    const slices = categories.map((c, i) => ({\n      ...c,\n      share: (c.percentage / total) * 100,\n      color: c.color ?? colors[i % colors.length],\n    }))\n\n    return (\n      <ChartFrame ref={ref} height={height} focusable={false} className={cn('flex flex-col justify-center', className)}>\n        <div className=\"flex items-baseline gap-2\">\n          <span className=\"text-foreground text-3xl font-bold tabular-nums\">{primaryValue}</span>\n          {trend && (\n            <span\n              className=\"text-xs font-semibold tabular-nums\"\n              style={{ color: trend.direction === 'up' ? 'var(--chart-2)' : 'var(--destructive)' }}\n            >\n              {trend.direction === 'up' ? '+' : '−'}\n              {trend.value}\n            </span>\n          )}\n          {primaryLabel && <span className=\"text-muted-foreground text-xs\">{primaryLabel}</span>}\n        </div>\n        <div className=\"mt-3 flex h-3 w-full overflow-hidden rounded-full\" role=\"presentation\">\n          {slices.map((s) => (\n            <div\n              key={s.label}\n              className=\"h-full\"\n              style={{ width: `${s.share}%`, background: s.color }}\n              title={`${s.label} — ${Math.round(s.share)}%`}\n            />\n          ))}\n        </div>\n        {showLegend && (\n          <ul className=\"mt-3 grid grid-cols-2 gap-x-4 gap-y-1.5 text-xs\">\n            {slices.map((s) => (\n              <li key={s.label} className=\"flex min-w-0 items-center gap-2\">\n                <span className=\"size-2.5 shrink-0 rounded-[3px]\" style={{ background: s.color }} />\n                <span className=\"text-foreground truncate font-medium\">{s.label}</span>\n                <span className=\"text-muted-foreground ml-auto shrink-0 tabular-nums\">\n                  {s.value ?? `${Math.round(s.share)}%`}\n                </span>\n              </li>\n            ))}\n          </ul>\n        )}\n      </ChartFrame>\n    )\n  },\n)\nCategoryDistributionChart.displayName = 'CategoryDistributionChart'\n",
      "type": "registry:ui",
      "target": "~/components/ui/charts/category-distribution-chart/CategoryDistributionChart.tsx"
    },
    {
      "path": "packages/registry-react/components/charts/category-distribution-chart/index.ts",
      "content": "export {\n  CategoryDistributionChart,\n  type CategoryDistributionChartProps,\n  type DistributionSlice,\n} from './CategoryDistributionChart'\n",
      "type": "registry:ui",
      "target": "~/components/ui/charts/category-distribution-chart/index.ts"
    },
    {
      "path": "packages/registry-react/components/charts/shared.tsx",
      "content": "'use client'\n\nimport * as React from 'react'\nimport * as echartsCore from 'echarts/core'\nimport { use } from 'echarts/core'\nimport { CanvasRenderer } from 'echarts/renderers'\nimport {\n  LineChart as EChartsLineChart,\n  BarChart as EChartsBarChart,\n  PieChart as EChartsPieChart,\n  ScatterChart as EChartsScatterChart,\n  EffectScatterChart as EChartsEffectScatter,\n  PictorialBarChart as EChartsPictorialBar,\n  RadarChart as EChartsRadarChart,\n  GaugeChart as EChartsGaugeChart,\n  HeatmapChart as EChartsHeatmap,\n  TreemapChart as EChartsTreemapChart,\n  FunnelChart as EChartsFunnelChart,\n  BoxplotChart as EChartsBoxplotChart,\n  CandlestickChart as EChartsCandlestickChart,\n  CustomChart as EChartsCustomChart,\n  ChordChart as EChartsChordChart,\n  MapChart as EChartsMapChart,\n  GraphChart as EChartsGraphChart,\n  ParallelChart as EChartsParallelChart,\n  SankeyChart as EChartsSankeyChart,\n  SunburstChart as EChartsSunburstChart,\n  ThemeRiverChart,\n  TreeChart as EChartsTreeChart,\n} from 'echarts/charts'\nimport {\n  GridComponent,\n  PolarComponent,\n  TooltipComponent,\n  LegendComponent,\n  MarkLineComponent,\n  MarkAreaComponent,\n  MarkPointComponent,\n  GraphicComponent,\n  RadarComponent,\n  VisualMapComponent,\n  CalendarComponent,\n  DataZoomComponent,\n  ParallelComponent,\n  SingleAxisComponent,\n  TitleComponent,\n} from 'echarts/components'\nimport ReactECharts from 'echarts-for-react/esm/core'\nimport { cn } from '@/lib/utils'\n\nexport function heightToStyle(height: number | string): string {\n  return /^\\d+$/.test(String(height)) ? `${height}px` : String(height)\n}\n\ninterface ChartFrameProps {\n  height: number | string\n  className?: string\n  /** Apply the accessible role/tabindex/focus-ring chrome. Some chart\n   *  wrappers ship a bare `w-full` frame -- pass `false` for those. */\n  focusable?: boolean\n  /** Accessible name for role=\"img\". Defaults to \"Chart\". */\n  ariaLabel?: string\n}\n\n/** Shared `<div>` wrapper around the ECharts canvas. */\nexport const ChartFrame = React.forwardRef<HTMLDivElement, ChartFrameProps & { children: React.ReactNode }>(\n  ({ height, className, focusable = true, ariaLabel, children }, ref) => (\n    <div\n      ref={ref}\n      role=\"img\"\n      aria-label={ariaLabel || 'Chart'}\n      tabIndex={focusable ? 0 : undefined}\n      style={{ height: heightToStyle(height) }}\n      className={\n        focusable\n          ? cn('focus-visible:ring-ring w-full focus-visible:ring-2 focus-visible:outline-none', className)\n          : cn('w-full', className)\n      }\n    >\n      {children}\n    </div>\n  ),\n)\nChartFrame.displayName = 'ChartFrame'\n\n/** ECharts canvas filling its parent frame. */\nexport function EChart({ option }: { option: any }) {\n  return (\n    <ReactECharts\n      echarts={echartsCore as any}\n      option={option}\n      notMerge\n      lazyUpdate\n      style={{ width: '100%', height: '100%' }}\n    />\n  )\n}\n\nexport const echartsCoreModule = echartsCore\n\n// Register every chart type the wrappers need once at module load.\nuse([\n  CanvasRenderer,\n  EChartsLineChart,\n  EChartsBarChart,\n  EChartsPieChart,\n  EChartsScatterChart,\n  EChartsEffectScatter,\n  EChartsPictorialBar,\n  EChartsRadarChart,\n  EChartsGaugeChart,\n  EChartsHeatmap,\n  EChartsTreemapChart,\n  EChartsFunnelChart,\n  EChartsBoxplotChart,\n  EChartsCandlestickChart,\n  EChartsCustomChart,\n  EChartsChordChart,\n  EChartsMapChart,\n  EChartsGraphChart,\n  EChartsParallelChart,\n  EChartsSankeyChart,\n  EChartsSunburstChart,\n  ThemeRiverChart,\n  EChartsTreeChart,\n  GridComponent,\n  PolarComponent,\n  TooltipComponent,\n  LegendComponent,\n  MarkLineComponent,\n  MarkAreaComponent,\n  MarkPointComponent,\n  GraphicComponent,\n  RadarComponent,\n  VisualMapComponent,\n  CalendarComponent,\n  DataZoomComponent,\n  ParallelComponent,\n  SingleAxisComponent,\n  TitleComponent,\n])\n",
      "type": "registry:ui",
      "target": "~/components/ui/charts/shared.tsx"
    }
  ],
  "dependencies": [
    "echarts",
    "echarts-for-react"
  ],
  "devDependencies": [],
  "registryDependencies": [],
  "description": "React mirror of @uipkge/category-distribution-chart — see the Vue registry item for the canonical description.",
  "categories": [
    "chart"
  ]
}