@conscience-technology/ovenn 0.6.7 → 0.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (320) hide show
  1. package/assets/components/AIMessage/AIMessage.module.css +2 -1
  2. package/assets/components/Accordion/Accordion.module.css +3 -0
  3. package/assets/components/AppFrame/AppFrame.module.css +2 -0
  4. package/assets/components/AttachmentItem/AttachmentItem.module.css +9 -3
  5. package/assets/components/AttachmentThumb/AttachmentThumb.module.css +4 -0
  6. package/assets/components/Avatar/Avatar.module.css +26 -11
  7. package/assets/components/Avatar/Avatar.tsx +1 -1
  8. package/assets/components/AvatarUpload/AvatarUpload.module.css +4 -3
  9. package/assets/components/Badge/Badge.module.css +96 -70
  10. package/assets/components/Badge/Badge.tsx +33 -25
  11. package/assets/components/Breadcrumb/Breadcrumb.module.css +8 -4
  12. package/assets/components/Breadcrumb/Breadcrumb.tsx +1 -1
  13. package/assets/components/Bubble/Bubble.module.css +6 -0
  14. package/assets/components/Button/Button.module.css +6 -0
  15. package/assets/components/Calendar/Calendar.module.css +244 -0
  16. package/assets/components/Calendar/Calendar.tsx +419 -0
  17. package/assets/components/Calendar/index.ts +2 -0
  18. package/assets/components/Callout/Callout.module.css +1 -0
  19. package/assets/components/Canvas/Canvas.module.css +75 -0
  20. package/assets/components/Canvas/Canvas.tsx +699 -0
  21. package/assets/components/Canvas/alignment.ts +34 -0
  22. package/assets/components/Canvas/clipboard.ts +30 -0
  23. package/assets/components/Canvas/collision.ts +67 -0
  24. package/assets/components/Canvas/edgeOptions.ts +11 -0
  25. package/assets/components/Canvas/graph.ts +11 -0
  26. package/assets/components/Canvas/history.ts +41 -0
  27. package/assets/components/Canvas/index.ts +4 -0
  28. package/assets/components/Canvas/selection.ts +56 -0
  29. package/assets/components/Canvas/tokens.css +61 -0
  30. package/assets/components/Canvas/types.ts +27 -0
  31. package/assets/components/Canvas/useCanvasSettlement.ts +79 -0
  32. package/assets/components/CanvasEdge/CanvasEdge.module.css +62 -0
  33. package/assets/components/CanvasEdge/CanvasEdge.tsx +121 -0
  34. package/assets/components/CanvasEdge/geometry.ts +350 -0
  35. package/assets/components/CanvasEdge/index.ts +4 -0
  36. package/assets/components/CanvasEdge/interactions.ts +14 -0
  37. package/assets/components/CanvasEdge/tokens.css +29 -0
  38. package/assets/components/CanvasNode/CanvasNode.module.css +234 -30
  39. package/assets/components/CanvasNode/CanvasNode.tsx +95 -28
  40. package/assets/components/CanvasNode/index.ts +1 -1
  41. package/assets/components/CanvasNode/runningOutline.ts +59 -0
  42. package/assets/components/CanvasNode/tokens.css +76 -13
  43. package/assets/components/Card/Card.module.css +5 -0
  44. package/assets/components/Chart/Chart.module.css +278 -0
  45. package/assets/components/Chart/Chart.tsx +385 -0
  46. package/assets/components/Chart/entrance.tsx +57 -0
  47. package/assets/components/Chart/index.ts +14 -0
  48. package/assets/components/ChatInput/ChatInput.module.css +5 -0
  49. package/assets/components/Checkbox/Checkbox.module.css +39 -0
  50. package/assets/components/Checkbox/Checkbox.tsx +99 -14
  51. package/assets/components/Checkbox/index.ts +1 -1
  52. package/assets/components/CheckboxCard/CheckboxCard.module.css +1 -177
  53. package/assets/components/CheckboxCard/CheckboxCard.tsx +6 -72
  54. package/assets/components/Chip/Chip.module.css +20 -30
  55. package/assets/components/Code/Code.module.css +1 -0
  56. package/assets/components/CodeBlock/CodeBlock.module.css +7 -3
  57. package/assets/components/ColorArea/ColorArea.module.css +3 -0
  58. package/assets/components/ColorField/ColorField.module.css +6 -0
  59. package/assets/components/ColorField/ColorField.tsx +3 -1
  60. package/assets/components/ColorPicker/ColorPicker.module.css +310 -0
  61. package/assets/components/ColorPicker/ColorPicker.tsx +387 -0
  62. package/assets/components/ColorPicker/index.ts +16 -0
  63. package/assets/components/ColorSlider/ColorSlider.module.css +15 -12
  64. package/assets/components/ColorSlider/ColorSlider.tsx +3 -3
  65. package/assets/components/ColorSwatch/ColorSwatch.module.css +2 -2
  66. package/assets/components/ColorSwatchPicker/ColorSwatchPicker.module.css +4 -3
  67. package/assets/components/Combobox/Combobox.module.css +1 -1
  68. package/assets/components/Combobox/Combobox.tsx +1 -1
  69. package/assets/components/CommandPalette/CommandPalette.module.css +18 -23
  70. package/assets/components/CommandPalette/CommandPalette.tsx +7 -5
  71. package/assets/components/Comment/Comment.module.css +25 -0
  72. package/assets/components/Comment/Comment.tsx +44 -0
  73. package/assets/components/Comment/CommentComposer.module.css +26 -0
  74. package/assets/components/Comment/CommentComposer.tsx +56 -0
  75. package/assets/components/Comment/CommentEditor.module.css +8 -0
  76. package/assets/components/Comment/CommentEditor.tsx +43 -0
  77. package/assets/components/Comment/CommentMentionInput.module.css +9 -0
  78. package/assets/components/Comment/CommentMentionInput.tsx +150 -0
  79. package/assets/components/Comment/index.ts +9 -0
  80. package/assets/components/Comment/types.ts +1 -0
  81. package/assets/components/ContextMenu/ContextMenu.module.css +5 -2
  82. package/assets/components/ContextMenu/ContextMenu.tsx +5 -0
  83. package/assets/components/ControlGroup/ControlGroup.module.css +7 -1
  84. package/assets/components/DataTable/DataTable.module.css +2 -0
  85. package/assets/components/DatePicker/DatePicker.module.css +36 -3
  86. package/assets/components/DatePicker/DatePicker.tsx +11 -1
  87. package/assets/components/DatePicker/TimeSelector.tsx +1 -1
  88. package/assets/components/Disclosure/Disclosure.module.css +1 -0
  89. package/assets/components/Drawer/Drawer.module.css +11 -4
  90. package/assets/components/Drawer/Drawer.tsx +5 -1
  91. package/assets/components/DropdownMenu/DropdownMenu.tsx +5 -0
  92. package/assets/components/EventChip/EventChip.module.css +120 -53
  93. package/assets/components/EventChip/EventChip.tsx +54 -6
  94. package/assets/components/EventChip/index.ts +1 -1
  95. package/assets/components/EventListItem/EventListItem.module.css +3 -0
  96. package/assets/components/EventListItem/EventListItem.tsx +15 -8
  97. package/assets/components/FileIcon/FileIcon.module.css +2 -0
  98. package/assets/components/FileUpload/FileUpload.module.css +10 -3
  99. package/assets/components/FileUpload/FileUpload.tsx +5 -9
  100. package/assets/components/FileUpload/FileUploadItem.tsx +34 -0
  101. package/assets/components/GalleryItem/GalleryItem.module.css +16 -19
  102. package/assets/components/GeneratedImage/GeneratedImage.module.css +2 -0
  103. package/assets/components/Icon/Icon.tsx +264 -1088
  104. package/assets/components/Icon/LucideFamilyIcon.tsx +434 -0
  105. package/assets/components/Icon/MissingIcon.tsx +25 -0
  106. package/assets/components/Icon/SolarFamilyIcon.tsx +439 -0
  107. package/assets/components/Icon/catalogNames.ts +8 -0
  108. package/assets/components/Icon/context.tsx +1 -1
  109. package/assets/components/Icon/index.ts +2 -0
  110. package/assets/components/Icon/lucideCatalog.ts +11358 -0
  111. package/assets/components/Icon/phosphorCatalog.ts +3052 -0
  112. package/assets/components/Icon/solarCatalog.ts +16064 -0
  113. package/assets/components/IconButton/IconButton.module.css +3 -2
  114. package/assets/components/Input/Input.module.css +30 -12
  115. package/assets/components/Input/Input.tsx +1 -1
  116. package/assets/components/Kanban/Kanban.module.css +6 -0
  117. package/assets/components/ListItem/ListItem.module.css +9 -6
  118. package/assets/components/MenuItem/MenuItem.module.css +24 -22
  119. package/assets/components/MenuItem/MenuItem.tsx +12 -12
  120. package/assets/components/MessageActions/MessageActions.module.css +36 -0
  121. package/assets/components/MessageActions/MessageActions.tsx +53 -28
  122. package/assets/components/MessageQuote/MessageQuote.module.css +1 -0
  123. package/assets/components/MessageSources/MessageSources.module.css +2 -0
  124. package/assets/components/MessageState/MessageState.module.css +1 -1
  125. package/assets/components/MetricCard/MetricCard.module.css +96 -108
  126. package/assets/components/MetricCard/MetricCard.tsx +45 -23
  127. package/assets/components/MetricCard/tokens.css +10 -0
  128. package/assets/components/MiniCalendar/MiniCalendar.module.css +130 -0
  129. package/assets/components/MiniCalendar/MiniCalendar.tsx +161 -0
  130. package/assets/components/MiniCalendar/index.ts +2 -0
  131. package/assets/components/Modal/Modal.module.css +13 -4
  132. package/assets/components/Modal/Modal.tsx +4 -0
  133. package/assets/components/Onboarding/LayoutBuilder.tsx +12 -50
  134. package/assets/components/Onboarding/Onboarding.module.css +211 -278
  135. package/assets/components/Onboarding/OnboardingAxisPanel.tsx +81 -125
  136. package/assets/components/Onboarding/OnboardingPage.tsx +244 -467
  137. package/assets/components/Onboarding/actions.ts +5 -0
  138. package/assets/components/Onboarding/palette.css +8 -0
  139. package/assets/components/Onboarding/wizardData.ts +8 -8
  140. package/assets/components/ProgressBar/ProgressBar.module.css +8 -8
  141. package/assets/components/ProgressBar/ProgressBar.tsx +0 -5
  142. package/assets/components/ProgressBar/index.ts +0 -1
  143. package/assets/components/QuotationBar/QuotationBar.module.css +2 -0
  144. package/assets/components/Radio/Radio.module.css +2 -0
  145. package/assets/components/RadioCard/RadioCard.module.css +78 -3
  146. package/assets/components/RadioCard/RadioCard.tsx +34 -12
  147. package/assets/components/RadioCard/index.ts +1 -1
  148. package/assets/components/SegmentedChart/SegmentedChart.module.css +16 -0
  149. package/assets/components/SegmentedChart/SegmentedChart.tsx +25 -8
  150. package/assets/components/Select/Select.tsx +7 -4
  151. package/assets/components/Shortcut/Shortcut.module.css +2 -0
  152. package/assets/components/Sidebar/Sidebar.module.css +1 -0
  153. package/assets/components/Sidebar/Sidebar.tsx +2 -2
  154. package/assets/components/Skeleton/Skeleton.module.css +33 -0
  155. package/assets/components/Skeleton/Skeleton.tsx +20 -0
  156. package/assets/components/Skeleton/index.ts +2 -0
  157. package/assets/components/Skeleton/tokens.css +11 -0
  158. package/assets/components/Slider/Slider.module.css +3 -0
  159. package/assets/components/Slider/Slider.tsx +7 -2
  160. package/assets/components/Spinner/LottiePlayer.tsx +4 -4
  161. package/assets/components/Spinner/Spinner.module.css +3 -0
  162. package/assets/components/Spinner/lottieManifest.ts +3 -0
  163. package/assets/components/Stepper/Stepper.module.css +56 -8
  164. package/assets/components/Stepper/Stepper.tsx +13 -4
  165. package/assets/components/Switch/Switch.module.css +55 -42
  166. package/assets/components/Switch/Switch.tsx +6 -2
  167. package/assets/components/Switch/index.ts +1 -1
  168. package/assets/components/TabStrip/TabStrip.module.css +5 -1
  169. package/assets/components/TableCell/TableCell.module.css +8 -1
  170. package/assets/components/TableCell/TableCellBadge.tsx +7 -3
  171. package/assets/components/TableCell/TableCellImage.tsx +1 -1
  172. package/assets/components/TableCell/TableCellTag.tsx +23 -0
  173. package/assets/components/TableCell/index.ts +3 -0
  174. package/assets/components/TableHeader/TableHeader.module.css +4 -0
  175. package/assets/components/TableRow/TableRow.module.css +3 -0
  176. package/assets/components/TableRowEdit/TableRowEdit.module.css +2 -0
  177. package/assets/components/TableToolbar/TableToolbar.module.css +1 -0
  178. package/assets/components/Tabs/Tabs.module.css +22 -7
  179. package/assets/components/Tabs/Tabs.tsx +2 -1
  180. package/assets/components/Tag/Tag.module.css +101 -0
  181. package/assets/components/Tag/Tag.tsx +55 -0
  182. package/assets/components/Tag/index.ts +2 -0
  183. package/assets/components/TemplateBoundary/TemplateBoundary.tsx +22 -18
  184. package/assets/components/TemplateBoundary/types.ts +2 -0
  185. package/assets/components/Textarea/Textarea.module.css +7 -0
  186. package/assets/components/ThemeController.tsx +30 -3
  187. package/assets/components/TimePicker/TimePicker.module.css +1 -0
  188. package/assets/components/TimePicker/TimePicker.tsx +37 -16
  189. package/assets/components/TimelineView/TimelineEventBar.tsx +109 -0
  190. package/assets/components/TimelineView/TimelineView.module.css +203 -0
  191. package/assets/components/TimelineView/TimelineView.tsx +137 -0
  192. package/assets/components/TimelineView/axis.ts +62 -0
  193. package/assets/components/TimelineView/index.ts +3 -0
  194. package/assets/components/TimelineView/layout.ts +56 -0
  195. package/assets/components/TimelineView/move.ts +51 -0
  196. package/assets/components/TimelineView/useTimelineDrag.ts +215 -0
  197. package/assets/components/TimelineView/useTimelineZoom.ts +92 -0
  198. package/assets/components/Toast/Toast.module.css +2 -0
  199. package/assets/components/Toolbar/Toolbar.module.css +31 -24
  200. package/assets/components/Toolbar/Toolbar.tsx +4 -3
  201. package/assets/components/Tooltip/Tooltip.module.css +10 -0
  202. package/assets/components/Tooltip/Tooltip.tsx +17 -8
  203. package/assets/components/TopLoader/TopLoader.module.css +1 -0
  204. package/assets/components/TreeNav/TreeNav.module.css +1 -0
  205. package/assets/components/_color.ts +2 -2
  206. package/assets/components/_data.ts +33 -32
  207. package/assets/components/_utils.css +5 -0
  208. package/assets/components/axisOptions.ts +2 -0
  209. package/assets/components/component-registry.json +151 -2
  210. package/assets/components/index.ts +16 -0
  211. package/assets/components/materialScope.tsx +11 -0
  212. package/assets/components/reset.css +1 -0
  213. package/assets/components/themeBootScript.ts +3 -2
  214. package/assets/components/tokens.css +225 -71
  215. package/assets/components/useChartEntrance.ts +119 -0
  216. package/assets/prompts/ASSEMBLY.md +9 -7
  217. package/assets/prompts/CATALOG.md +18 -4
  218. package/assets/prompts/FEEDBACK_PROCESS.md +19 -0
  219. package/assets/prompts/PRINCIPLES.md +14 -0
  220. package/assets/prompts/WORKFLOW_DESIGN.md +46 -70
  221. package/assets/prompts/axes/font.md +6 -1
  222. package/assets/prompts/axes/icon.md +6 -4
  223. package/assets/prompts/axes/material.md +40 -0
  224. package/assets/prompts/axes/palette.md +2 -1
  225. package/assets/prompts/axes/shape.md +8 -0
  226. package/assets/prompts/components/attachment-item.md +2 -1
  227. package/assets/prompts/components/badge.md +32 -97
  228. package/assets/prompts/components/breadcrumb.md +1 -0
  229. package/assets/prompts/components/calendar.md +151 -0
  230. package/assets/prompts/components/canvas-edge.md +67 -0
  231. package/assets/prompts/components/canvas-node.md +25 -8
  232. package/assets/prompts/components/canvas.md +82 -0
  233. package/assets/prompts/components/card.md +10 -10
  234. package/assets/prompts/components/chart-bar.md +77 -0
  235. package/assets/prompts/components/chart-pie.md +63 -0
  236. package/assets/prompts/components/chart-radar.md +56 -0
  237. package/assets/prompts/components/chart-radial.md +56 -0
  238. package/assets/prompts/components/chart.md +129 -0
  239. package/assets/prompts/components/checkbox-card.md +26 -45
  240. package/assets/prompts/components/checkbox.md +23 -0
  241. package/assets/prompts/components/chip.md +6 -6
  242. package/assets/prompts/components/code-block.md +1 -0
  243. package/assets/prompts/components/color-picker.md +173 -0
  244. package/assets/prompts/components/color-slider.md +7 -7
  245. package/assets/prompts/components/command-palette.md +7 -6
  246. package/assets/prompts/components/comment.md +72 -0
  247. package/assets/prompts/components/context-menu.md +6 -3
  248. package/assets/prompts/components/data-table.md +9 -0
  249. package/assets/prompts/components/date-picker.md +10 -0
  250. package/assets/prompts/components/drawer.md +10 -0
  251. package/assets/prompts/components/dropdown-menu.md +3 -1
  252. package/assets/prompts/components/event-chip.md +60 -18
  253. package/assets/prompts/components/event-list-item.md +14 -10
  254. package/assets/prompts/components/file-upload.md +1 -1
  255. package/assets/prompts/components/gallery-item.md +5 -4
  256. package/assets/prompts/components/icon.md +30 -8
  257. package/assets/prompts/components/kanban.md +1 -1
  258. package/assets/prompts/components/list-item.md +11 -2
  259. package/assets/prompts/components/menu-item.md +8 -3
  260. package/assets/prompts/components/message-actions.md +9 -0
  261. package/assets/prompts/components/metric-card.md +57 -109
  262. package/assets/prompts/components/mini-calendar.md +72 -0
  263. package/assets/prompts/components/modal.md +1 -0
  264. package/assets/prompts/components/onboarding.md +11 -7
  265. package/assets/prompts/components/page-header.md +11 -2
  266. package/assets/prompts/components/progress-bar.md +12 -2
  267. package/assets/prompts/components/radio-card.md +33 -117
  268. package/assets/prompts/components/segmented-chart.md +19 -5
  269. package/assets/prompts/components/select.md +1 -0
  270. package/assets/prompts/components/sidebar.md +12 -3
  271. package/assets/prompts/components/skeleton.md +44 -0
  272. package/assets/prompts/components/stepper.md +15 -1
  273. package/assets/prompts/components/switch.md +15 -10
  274. package/assets/prompts/components/tab-strip.md +1 -0
  275. package/assets/prompts/components/table-cell.md +6 -4
  276. package/assets/prompts/components/table-row.md +12 -3
  277. package/assets/prompts/components/table-toolbar.md +9 -0
  278. package/assets/prompts/components/tabs.md +4 -2
  279. package/assets/prompts/components/tag.md +54 -0
  280. package/assets/prompts/components/time-picker.md +1 -0
  281. package/assets/prompts/components/timeline-view.md +129 -0
  282. package/assets/prompts/components/toast.md +1 -1
  283. package/assets/prompts/components/toolbar.md +17 -4
  284. package/assets/prompts/components/tooltip.md +21 -3
  285. package/assets/prompts/components/top-loader.md +1 -1
  286. package/assets/prompts/components/topbar.md +9 -0
  287. package/assets/prompts/components/tree-nav.md +1 -1
  288. package/assets/prompts/templates/ains.md +2 -1
  289. package/assets/prompts/templates/aurora.md +5 -4
  290. package/assets/prompts/templates/glass-button.md +6 -5
  291. package/assets/prompts/templates/minimal.md +8 -6
  292. package/assets/prompts/templates/workspace.md +3 -3
  293. package/assets/prompts/tokens/color.md +4 -2
  294. package/assets/prompts/tokens/material.md +51 -0
  295. package/assets/prompts/tokens/radius.md +12 -0
  296. package/assets/prompts/tokens/typography.md +24 -2
  297. package/assets/prompts/use-cases/chart-chart-area.md +1334 -0
  298. package/assets/prompts/use-cases/chart-chart-bar.md +1886 -0
  299. package/assets/prompts/use-cases/chart-chart-pie.md +1031 -0
  300. package/assets/prompts/use-cases/chart-chart-radar.md +785 -0
  301. package/assets/prompts/use-cases/chart-chart-radial.md +988 -0
  302. package/assets/prompts/use-cases/chart-segmented-chart.md +262 -0
  303. package/assets/prompts/use-cases/data-comment.md +360 -0
  304. package/assets/prompts/use-cases/data-data-table.md +249 -0
  305. package/assets/prompts/use-cases/data-list-item.md +1056 -0
  306. package/assets/prompts/use-cases/data-metric-card.md +673 -0
  307. package/assets/prompts/use-cases/data-table-row.md +966 -0
  308. package/assets/prompts/use-cases/data-table-toolbar.md +481 -0
  309. package/assets/prompts/use-cases/feedback-drawer.md +1163 -0
  310. package/assets/prompts/use-cases/feedback-progress-bar.md +427 -0
  311. package/assets/prompts/use-cases/general-toolbar.md +854 -0
  312. package/assets/prompts/use-cases/general-tooltip.md +652 -0
  313. package/assets/prompts/use-cases/input-checkbox.md +443 -0
  314. package/assets/prompts/use-cases/structure-card.md +603 -0
  315. package/assets/prompts/use-cases/structure-page-header.md +755 -0
  316. package/assets/prompts/use-cases/structure-sidebar.md +1132 -0
  317. package/assets/prompts/use-cases/structure-topbar.md +1200 -0
  318. package/assets/public/ovenn-wordmark.svg +19 -0
  319. package/package.json +6 -2
  320. package/src/commands/info.js +1 -1
@@ -0,0 +1,1886 @@
1
+ # Bar Chart 사용 사례 소스
2
+
3
+ <!-- Generated by scripts/build-use-cases.mjs. Edit original TSX/CSS, then regenerate. -->
4
+
5
+ ### 사례 목록
6
+
7
+ - Sales pipeline
8
+ - Support requests card
9
+
10
+ 문서: /en/components/chart/chart-bar#use-cases
11
+
12
+ 문서 페이지에서 렌더하는 사례입니다.
13
+
14
+ ### 조회 방법
15
+
16
+ get_guide(topic="use-cases/chart-chart-bar", sections=["사례 목록", "파일 목록"])로 먼저 확인하고, 필요한 Section 또는 Source 파일 헤딩만 sections로 조회하세요. 전체 문서는 문서 페이지의 다른 예제도 포함합니다. 공용 컴포넌트 계약은 get_component로 읽고, 예제의 docs 전용 셸·locale·import 경로는 대상 프로젝트에 맞게 조합하세요. 이 연결은 디자인 승인이나 기능 검증을 뜻하지 않습니다.
17
+
18
+ ### 파일 목록
19
+
20
+ - `web/app/[lang]/components/chart/chart-bar/_strings.tsx`
21
+ - `web/app/[lang]/components/chart/chart-bar/page.module.css`
22
+ - `web/app/[lang]/components/chart/chart-bar/page.tsx`
23
+ - `web/examples/ChartCardExamples.module.css`
24
+ - `web/examples/ChartCardExamples.tsx`
25
+ - `web/examples/TrafficComparisonExample.module.css`
26
+ - `web/examples/TrafficComparisonExample.tsx`
27
+
28
+ ### Section: web/app/[lang]/components/chart/chart-bar/page.tsx#use-cases
29
+
30
+ ```tsx
31
+ <section id="use-cases">
32
+ <h2>{t.useCases.heading}</h2>
33
+ <p className="desc">{t.useCases.desc}</p>
34
+
35
+ <h3>{t.useCases.pipeline.title}</h3>
36
+ <ExampleBlock
37
+
38
+ align="column"
39
+ >
40
+ <PipelineUseCase strings={strings.en.useCases.pipeline} />
41
+ </ExampleBlock>
42
+ <h3>{en ? "Support requests card" : "문의 현황 카드"}</h3>
43
+ <ExampleBlock previewWidth="full"><SupportCardExample /></ExampleBlock>
44
+ </section>
45
+ ```
46
+
47
+ ### Source: web/app/[lang]/components/chart/chart-bar/_strings.tsx
48
+
49
+ ````tsx
50
+ import type { ReactNode } from "react";
51
+
52
+ /* Bar Chart docs 페이지 전용 문자열. */
53
+
54
+ type Strings = {
55
+ title: string;
56
+ lead: ReactNode;
57
+
58
+ months: [string, string, string, string, string, string];
59
+ desktopLabel: string;
60
+ mobileLabel: string;
61
+
62
+ dateFmt: (month: number, day: number) => string;
63
+
64
+ usage: { heading: string; desc: ReactNode };
65
+ variants: {
66
+ heading: string;
67
+ desc: ReactNode;
68
+ horizontalDesc: ReactNode;
69
+ multipleDesc: ReactNode;
70
+ };
71
+ stacked: { heading: string; desc: ReactNode; expandDesc: ReactNode };
72
+ interactive: { heading: string; desc: ReactNode };
73
+ useCases: {
74
+ heading: string;
75
+ desc: ReactNode;
76
+ pipeline: {
77
+ title: string;
78
+ totalBadge: string;
79
+ amountLabel: string;
80
+ stages: { label: string; amount: number; amountDisplay: string }[];
81
+ };
82
+ };
83
+ api: {
84
+ heading: string;
85
+ desc: ReactNode;
86
+ officialDocs: string;
87
+ columns: { prop: string; type: string; default: string; desc: string };
88
+ columnsKey: { prop: string; type: string; default: string; desc: string };
89
+ container: { config: string; className: string; children: string };
90
+ tooltip: {
91
+ indicator: string;
92
+ hideLabel: string;
93
+ hideIndicator: string;
94
+ nameKey: string;
95
+ labelKey: string;
96
+ labelFormatter: string;
97
+ formatter: string;
98
+ };
99
+ legend: { hideIcon: string; nameKey: string; verticalAlign: string };
100
+ config: { label: string; icon: string; color: string; theme: string };
101
+ };
102
+ };
103
+
104
+ const en: Strings = {
105
+ title: "Bar Chart",
106
+ lead: "Compares values across categories using bar length. Use for ranking or precise comparisons.",
107
+
108
+ months: ["Jan", "Feb", "Mar", "Apr", "May", "Jun"],
109
+ desktopLabel: "Desktop",
110
+ mobileLabel: "Mobile",
111
+
112
+ dateFmt: (month, day) => `${["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"][month - 1]} ${day}`,
113
+
114
+ usage: {
115
+ heading: "Usage",
116
+ desc: "Use when the difference between category values matters.",
117
+ },
118
+
119
+
120
+ variants: {
121
+ heading: "Variants",
122
+ desc: "Choose the orientation and series layout for the comparison.",
123
+ horizontalDesc: "Use horizontal bars when category names are long.",
124
+ multipleDesc: "Place series side by side to compare values within each category.",
125
+ },
126
+
127
+ stacked: {
128
+ heading: "Stacked",
129
+ desc: "Stack bars to compare totals and their composition.",
130
+ expandDesc: "Use a 100% stack to compare shares across categories.",
131
+ },
132
+
133
+ interactive: {
134
+ heading: "Date Range",
135
+ desc: "Let readers narrow the date range to inspect recent changes.",
136
+ },
137
+
138
+ useCases: {
139
+ heading: "In Use",
140
+ desc: "Keep the existing stage order when comparing a process.",
141
+ pipeline: {
142
+ title: "Sales pipeline",
143
+ totalBadge: "14",
144
+ amountLabel: "Amount",
145
+ stages: [
146
+ { label: "Lead", amount: 33, amountDisplay: "$33k" },
147
+ { label: "Qualification", amount: 52, amountDisplay: "$52k" },
148
+ { label: "Proposal", amount: 110, amountDisplay: "$110k" },
149
+ { label: "Negotiation", amount: 147, amountDisplay: "$147k" },
150
+ { label: "Closed won", amount: 128, amountDisplay: "$128k" },
151
+ ],
152
+ },
153
+ },
154
+
155
+ api: {
156
+ heading: "API Reference",
157
+ desc: "Shared chart options are listed below. For chart-specific options, see the",
158
+ officialDocs: "Recharts documentation",
159
+ columns: { prop: "Prop", type: "Type", default: "Default", desc: "Description" },
160
+ columnsKey: { prop: "Key", type: "Type", default: "Default", desc: "Description" },
161
+ container: {
162
+ config: "Labels, colors, and icons for each series.",
163
+ className: "Additional styles for the chart container.",
164
+ children: "The chart to display.",
165
+ },
166
+ tooltip: {
167
+ indicator: "Shape of the series marker.",
168
+ hideLabel: "Hides the heading above the values.",
169
+ hideIndicator: "Hides the series marker.",
170
+ nameKey: "Data key used to identify the series.",
171
+ labelKey: "Data key used for the tooltip heading.",
172
+ labelFormatter: "Formats the tooltip heading.",
173
+ formatter: "Customizes each tooltip row.",
174
+ },
175
+ legend: {
176
+ hideIcon: "Uses a color marker instead of a custom icon.",
177
+ nameKey: "Data key used to identify each legend item.",
178
+ verticalAlign: "Places the legend above or below the chart.",
179
+ },
180
+ config: {
181
+ label: "Series name shown in tooltips and legends.",
182
+ icon: "Icon shown beside the series name.",
183
+ color: "Fixed series color; cannot be combined with mode-specific colors.",
184
+ theme: "Series colors for light and dark modes; cannot be combined with a fixed color.",
185
+ },
186
+ },
187
+ };
188
+
189
+ const ko: Strings = {
190
+ title: "Bar Chart",
191
+ lead: "항목별 수치를 막대 길이로 비교합니다. 순위를 살피거나 값의 차이를 정확히 비교할 때 사용합니다.",
192
+
193
+ months: ["1월", "2월", "3월", "4월", "5월", "6월"],
194
+ desktopLabel: "데스크톱",
195
+ mobileLabel: "모바일",
196
+
197
+ dateFmt: (month, day) => `${month}월 ${day}일`,
198
+
199
+ usage: {
200
+ heading: "Usage",
201
+ desc: "항목 간 수치 차이를 비교할 때 사용합니다.",
202
+ },
203
+
204
+
205
+ variants: {
206
+ heading: "Variants",
207
+ desc: "비교할 항목에 맞춰 막대 방향과 배치를 선택합니다.",
208
+ horizontalDesc: "항목명이 길면 가로 막대를 사용합니다.",
209
+ multipleDesc: "같은 항목의 수치를 직접 비교할 때는 막대를 나란히 배치합니다.",
210
+ },
211
+
212
+ stacked: {
213
+ heading: "Stacked",
214
+ desc: "합계와 각 항목의 구성을 함께 볼 때 막대를 쌓아 사용합니다.",
215
+ expandDesc: "항목마다 전체에서 차지하는 비중을 비교할 때는 100% 누적을 사용합니다.",
216
+ },
217
+
218
+ interactive: {
219
+ heading: "기간 선택",
220
+ desc: "최근 변화나 특정 구간을 살펴볼 수 있도록 조회 기간을 선택하게 합니다.",
221
+ },
222
+
223
+ useCases: {
224
+ heading: "In Use",
225
+ desc: "단계가 있는 업무에서는 원래 순서를 유지해 비교합니다.",
226
+ pipeline: {
227
+ title: "영업 파이프라인",
228
+ totalBadge: "14",
229
+ amountLabel: "금액",
230
+ stages: [
231
+ { label: "리드 발굴", amount: 3300, amountDisplay: "3,300만" },
232
+ { label: "상담 진행", amount: 5200, amountDisplay: "5,200만" },
233
+ { label: "제안서 발송", amount: 11000, amountDisplay: "1.1억" },
234
+ { label: "협상 진행", amount: 14700, amountDisplay: "1.47억" },
235
+ { label: "계약 완료", amount: 12800, amountDisplay: "1.28억" },
236
+ ],
237
+ },
238
+ },
239
+
240
+ api: {
241
+ heading: "API Reference",
242
+ desc: "공통 차트 옵션은 아래 표에서 확인합니다. 차트별 옵션은",
243
+ officialDocs: "Recharts 문서",
244
+ columns: { prop: "Prop", type: "Type", default: "Default", desc: "Description" },
245
+ columnsKey: { prop: "Key", type: "Type", default: "Default", desc: "Description" },
246
+ container: {
247
+ config: "각 데이터 계열의 이름·색상·아이콘을 지정합니다.",
248
+ className: "차트 컨테이너에 스타일을 추가합니다.",
249
+ children: "표시할 차트를 지정합니다.",
250
+ },
251
+ tooltip: {
252
+ indicator: "데이터 계열을 구분하는 표시의 모양입니다.",
253
+ hideLabel: "수치 위에 표시되는 제목을 숨깁니다.",
254
+ hideIndicator: "데이터 계열의 구분 표시를 숨깁니다.",
255
+ nameKey: "데이터 계열을 식별할 키입니다.",
256
+ labelKey: "툴팁 제목으로 사용할 데이터 키입니다.",
257
+ labelFormatter: "툴팁 제목의 표시 형식을 바꿉니다.",
258
+ formatter: "툴팁의 각 행을 구성합니다.",
259
+ },
260
+ legend: {
261
+ hideIcon: "사용자 지정 아이콘 대신 색상 표시를 사용합니다.",
262
+ nameKey: "범례 항목을 식별할 데이터 키입니다.",
263
+ verticalAlign: "범례를 차트 위나 아래에 배치합니다.",
264
+ },
265
+ config: {
266
+ label: "툴팁과 범례에 표시할 데이터 계열의 이름입니다.",
267
+ icon: "데이터 계열의 이름 옆에 표시할 아이콘입니다.",
268
+ color: "고정 색상이며 모드별 색상과 함께 지정할 수 없습니다.",
269
+ theme: "라이트·다크 모드별 색상이며 고정 색상과 함께 지정할 수 없습니다.",
270
+ },
271
+ },
272
+ };
273
+
274
+ export const strings = { en, ko };
275
+ export type { Strings };
276
+ ````
277
+
278
+ ### Source: web/app/[lang]/components/chart/chart-bar/page.module.css
279
+
280
+ ````css
281
+ /* Playground stage가 justify-content:center로 자식을 가운데에 몰기 때문에
282
+ Legend align이 눈에 안 띈다. ChartContainer가 stage 폭을 꽉 채우도록 강제. */
283
+ .playgroundChart {
284
+ width: 100%;
285
+ }
286
+
287
+ /* Bar spotlight transition — path를 유지한 채 opacity와 채도를 함께 보간한다. */
288
+ .spotlightBar {
289
+ opacity: 1;
290
+ filter: saturate(1);
291
+ transition:
292
+ opacity var(--duration-slow) var(--ease-in-out),
293
+ filter var(--duration-slow) var(--ease-in-out);
294
+ }
295
+
296
+ .spotlightBar[data-dim="true"] {
297
+ opacity: 0.3;
298
+ filter: saturate(0.72);
299
+ }
300
+
301
+ /* 커스텀 말풍선 tooltip — ChartContainer wrapper에 absolute. */
302
+ .chartWrap {
303
+ position: relative;
304
+ width: 100%;
305
+ }
306
+ .bubble {
307
+ position: absolute;
308
+ z-index: var(--z-raised);
309
+ padding: var(--space-2) var(--space-3);
310
+ corner-shape: var(--corner-shape);
311
+ border-radius: var(--radius-md);
312
+ font-size: var(--text-sm);
313
+ line-height: var(--lh-sm);
314
+ pointer-events: none;
315
+ white-space: nowrap;
316
+ box-shadow: var(--shadow-md);
317
+ transition: left var(--duration-slow) var(--ease-emphasized),
318
+ top var(--duration-slow) var(--ease-emphasized),
319
+ opacity var(--duration-base) var(--ease-out);
320
+ opacity: 1;
321
+ }
322
+ /* direction up: bar 위에, 꼬리 아래 가운데 (default) */
323
+ .bubble[data-direction="up"],
324
+ .bubble:not([data-direction]) {
325
+ transform: translate(-50%, calc(-100% - var(--size-2)));
326
+ }
327
+ /* direction right: bar 오른쪽, 꼬리 왼쪽 중앙 */
328
+ .bubble[data-direction="right"] {
329
+ transform: translate(var(--size-2), -50%);
330
+ }
331
+ .bubble[data-size="sm"] {
332
+ padding: var(--space-1) var(--space-2);
333
+ corner-shape: var(--corner-shape);
334
+ border-radius: var(--radius-sm);
335
+ font-size: var(--text-xs);
336
+ line-height: var(--lh-xs);
337
+ }
338
+ .bubble[data-size="sm"] .bubbleLabel {
339
+ font-size: var(--text-xs);
340
+ margin-bottom: 0;
341
+ }
342
+ /* dark 변주: inverse color + backdrop blur로 뒷 그래프 비침. */
343
+ .bubble[data-color="dark"],
344
+ .bubble:not([data-color]) {
345
+ background: color-mix(in oklab, var(--fg-strong) 88%, transparent);
346
+ color: var(--bg);
347
+ backdrop-filter: blur(12px) saturate(1.1);
348
+ -webkit-backdrop-filter: blur(12px) saturate(1.1);
349
+ }
350
+ .bubble[data-color="dark"]::after,
351
+ .bubble:not([data-color])::after {
352
+ border-top-color: color-mix(in oklab, var(--fg-strong) 88%, transparent);
353
+ }
354
+ .bubble[data-color="dark"] .bubbleLabel,
355
+ .bubble:not([data-color]) .bubbleLabel {
356
+ color: var(--bg-muted);
357
+ }
358
+ /* light 변주: 흰 glass. */
359
+ .bubble[data-color="light"] {
360
+ background: color-mix(in oklab, var(--bg) 72%, transparent);
361
+ color: var(--fg-strong);
362
+ backdrop-filter: blur(12px) saturate(1.2);
363
+ -webkit-backdrop-filter: blur(12px) saturate(1.2);
364
+ }
365
+ .bubble[data-color="light"]::after {
366
+ border-top-color: color-mix(in oklab, var(--bg) 72%, transparent);
367
+ }
368
+ .bubble[data-color="light"] .bubbleLabel {
369
+ color: var(--fg-muted);
370
+ }
371
+
372
+ .bubble[data-hidden="true"] {
373
+ opacity: 0;
374
+ }
375
+ .bubble::after {
376
+ content: "";
377
+ position: absolute;
378
+ width: 0;
379
+ height: 0;
380
+ }
381
+ /* up: 아래 가운데 꼬리 */
382
+ .bubble[data-direction="up"]::after,
383
+ .bubble:not([data-direction])::after {
384
+ left: 50%;
385
+ bottom: 0;
386
+ transform: translate(-50%, 100%);
387
+ border-left: var(--size-1) solid transparent;
388
+ border-right: var(--size-1) solid transparent;
389
+ border-top-width: var(--size-1);
390
+ border-top-style: solid;
391
+ }
392
+ /* right: 왼쪽 중앙 꼬리 */
393
+ .bubble[data-direction="right"]::after {
394
+ top: 50%;
395
+ left: 0;
396
+ transform: translate(-100%, -50%);
397
+ border-top: var(--size-1) solid transparent;
398
+ border-bottom: var(--size-1) solid transparent;
399
+ border-right-width: var(--size-1);
400
+ border-right-style: solid;
401
+ }
402
+ .bubble[data-color="dark"][data-direction="right"]::after,
403
+ .bubble:not([data-color])[data-direction="right"]::after {
404
+ border-right-color: color-mix(in oklab, var(--fg-strong) 88%, transparent);
405
+ }
406
+ .bubble[data-color="light"][data-direction="right"]::after {
407
+ border-right-color: color-mix(in oklab, var(--bg) 72%, transparent);
408
+ }
409
+ .bubbleLabel {
410
+ display: block;
411
+ font-size: var(--text-xs);
412
+ line-height: var(--lh-xs);
413
+ margin-bottom: var(--space-0_5);
414
+ }
415
+ .bubbleValue {
416
+ font-weight: var(--font-weight-semibold);
417
+ font-variant-numeric: tabular-nums;
418
+ }
419
+
420
+ /* chart-bar 데모 — Interactive 섹션의 세로 스택 자리. */
421
+ .interactiveStack {
422
+ width: 100%;
423
+ display: flex;
424
+ flex-direction: column;
425
+ gap: var(--space-3);
426
+ }
427
+
428
+ .rangeTabs {
429
+ align-self: flex-end;
430
+ }
431
+
432
+ .rangeTabs :global([role="tablist"]) {
433
+ white-space: nowrap;
434
+ }
435
+ .rangeTabs :global([role="tab"]) {
436
+ white-space: nowrap;
437
+ }
438
+
439
+ /* Use case — Pipeline (horizontal bar list with count + amount)
440
+ 세그먼트 차트와 같은 타이포·간격 스케일을 공유. 타이틀은 text-sm/semibold,
441
+ row 패딩은 space-1_5 space-2, 색점은 space-2 square (radius-xs). */
442
+ .pipelineCard {
443
+ display: grid;
444
+ gap: var(--space-4);
445
+ width: 100%;
446
+ max-width: calc(var(--size-24) * 4);
447
+ min-width: 0;
448
+ }
449
+ .pipelineHeader {
450
+ display: grid;
451
+ gap: var(--space-1);
452
+ }
453
+ .pipelineTitleRow {
454
+ display: flex;
455
+ align-items: center;
456
+ gap: var(--space-2);
457
+ }
458
+ .pipelineTitle {
459
+ margin: 0;
460
+ font-size: var(--text-sm);
461
+ line-height: var(--lh-sm);
462
+ font-weight: var(--font-weight-semibold);
463
+ color: var(--fg-strong);
464
+ }
465
+ .pipelineLead {
466
+ margin: 0;
467
+ font-size: var(--text-xs);
468
+ line-height: var(--lh-xs);
469
+ color: var(--fg-muted);
470
+ }
471
+ /* list — 세그먼트와 동일: 행 내부 여백 유지, 목록 전체를 카드 여백 바깥 한 단계.
472
+ grid-template-columns를 ul에 선언해 모든 .pipelineRow가 subgrid로 공유. */
473
+ .pipelineList {
474
+ display: grid;
475
+ grid-template-columns: max-content 1fr;
476
+ row-gap: var(--space-1);
477
+ list-style: none;
478
+ padding: 0;
479
+ margin-block: 0;
480
+ margin-inline: calc(var(--space-1) * -1);
481
+ }
482
+ /* row — 라벨 폭은 .pipelineList subgrid로 모든 행이 같은 열 폭을 공유.
483
+ 라벨 열은 그 안에서 가장 긴 라벨에 맞춰 자동으로 늘어난다 (max-content). */
484
+ .pipelineRow {
485
+ display: grid;
486
+ grid-template-columns: subgrid;
487
+ grid-column: 1 / -1;
488
+ align-items: center;
489
+ column-gap: var(--space-3);
490
+ padding: var(--space-1_5) var(--space-2);
491
+ min-height: var(--control-h-md);
492
+ font-size: var(--text-sm);
493
+ line-height: var(--lh-sm);
494
+ color: var(--fg);
495
+ }
496
+ .pipelineStage {
497
+ display: flex;
498
+ align-items: center;
499
+ gap: var(--space-2);
500
+ min-width: 0;
501
+ white-space: nowrap;
502
+ overflow: hidden;
503
+ }
504
+ .pipelineStage > :last-child {
505
+ min-width: 0;
506
+ overflow: hidden;
507
+ text-overflow: ellipsis;
508
+ }
509
+ .pipelineDot {
510
+ width: var(--size-2);
511
+ height: var(--size-2);
512
+ corner-shape: var(--corner-shape);
513
+ border-radius: var(--radius-xs);
514
+ flex-shrink: 0;
515
+ }
516
+ .pipelineBarWrap {
517
+ width: 100%;
518
+ height: var(--size-4);
519
+ }
520
+ /* ChartContainer 기본 aspect-ratio 제거 — pipelineBarWrap이 고정 높이를 공급. */
521
+ .pipelineBarWrap > :global([data-slot="chart"]) {
522
+ aspect-ratio: auto;
523
+ height: 100%;
524
+ }
525
+ .pipelineBarLabel {
526
+ fill: var(--fg-strong);
527
+ font-size: var(--text-xs);
528
+ font-weight: var(--font-weight-semibold);
529
+ }
530
+ ````
531
+
532
+ ### Source: web/app/[lang]/components/chart/chart-bar/page.tsx
533
+
534
+ ````tsx
535
+ "use client";
536
+
537
+ import { SupportCardExample } from "@/examples/ChartCardExamples";
538
+ import { useCallback, useEffect, useMemo, useRef, useState, type ReactNode } from "react";
539
+ import { usePathname } from "next/navigation";
540
+ import {
541
+ Bar,
542
+ BarChart,
543
+ CartesianGrid,
544
+ Cell,
545
+ LabelList,
546
+ XAxis,
547
+ YAxis,
548
+ } from "recharts";
549
+ import { Badge } from "@/components/Badge";
550
+ import {
551
+ ChartContainer,
552
+ ChartLegend,
553
+ ChartLegendContent,
554
+ ChartTooltip,
555
+ ChartTooltipContent,
556
+ type ChartConfig,
557
+ } from "@/components/Chart";
558
+ import { Code } from "@/components/Code";
559
+ import { Card } from "@/components/Card";
560
+ import { motionPresets } from "@/components/_data";
561
+ import { useTheme } from "@/components/ThemeController";
562
+ import { Tabs } from "@/components/Tabs";
563
+ import { ExampleBlock } from "../../../../_components/ExampleBlock";
564
+ import { Playground } from "../../../../_components/Playground";
565
+ import { DocsTable } from "../../../../_components/DocsTable";
566
+ import { localeFromPathname } from "../../../../_dict";
567
+ import { strings } from "./_strings";
568
+ import styles from "./page.module.css";
569
+
570
+ const INDICATORS = ["dot", "line"] as const;
571
+ type Indicator = (typeof INDICATORS)[number];
572
+ const TOOLTIP_SIZES = ["md", "sm"] as const;
573
+ type TooltipSize = (typeof TOOLTIP_SIZES)[number];
574
+ const LAYOUTS = ["horizontal", "vertical"] as const;
575
+ type Layout = (typeof LAYOUTS)[number];
576
+ const LEGEND_ALIGNS = ["left", "center", "right"] as const;
577
+ type LegendAlign = (typeof LEGEND_ALIGNS)[number];
578
+ const TOOLTIP_KINDS = ["bubble", "recharts"] as const;
579
+ type TooltipKind = (typeof TOOLTIP_KINDS)[number];
580
+ const BUBBLE_COLORS = ["dark", "light"] as const;
581
+ type BubbleColor = (typeof BUBBLE_COLORS)[number];
582
+ const FATS = ["sm", "md", "lg"] as const;
583
+ type Fat = (typeof FATS)[number];
584
+ type PlaygroundSeries = "mobile" | "desktop";
585
+ type BarAnchor = { x: number; y: number };
586
+ type BarShapeProps = {
587
+ x?: number;
588
+ y?: number;
589
+ width?: number;
590
+ height?: number;
591
+ fill?: string;
592
+ radius?: number | number[];
593
+ index?: number;
594
+ };
595
+ function updateBarSpotlight(root: SVGGraphicsElement, activeIndex: number | null) {
596
+ root.querySelectorAll<SVGPathElement>("[data-spotlight-index]").forEach((bar) => {
597
+ const dim = activeIndex != null && Number(bar.dataset.spotlightIndex) !== activeIndex;
598
+ if (dim) bar.dataset.dim = "true";
599
+ else delete bar.dataset.dim;
600
+ });
601
+ }
602
+ /* fat은 bar의 픽셀 상한이 아니라 category band의 양쪽 여백을 제어한다.
603
+ Recharts는 barCategoryGap을 band 양쪽에 각각 적용하므로 50% 미만이어야 한다.
604
+ 실제 bar 점유율은 sm 24%, md 50%, lg 80%이며 레이아웃 크기에 비례한다. */
605
+ const FAT_CATEGORY_GAP: Record<Fat, string> = {
606
+ sm: "38%",
607
+ md: "25%",
608
+ lg: "10%",
609
+ };
610
+ const RADII = ["none", "md", "pill"] as const;
611
+ type Radii = (typeof RADII)[number];
612
+ const RADIUS_PX: Record<Radii, number> = { none: 0, md: 6, pill: 999 };
613
+
614
+ export default function ChartBarPage() {
615
+ const pathname = usePathname() ?? "/";
616
+ const en = localeFromPathname(pathname) === "en";
617
+ const t = strings[en ? "en" : "ko"];
618
+
619
+ /* Shared data with locale-aware month labels. */
620
+ const monthData = useMemo(
621
+ () => [
622
+ { month: strings.en.months[0], desktop: 186, mobile: 80 },
623
+ { month: strings.en.months[1], desktop: 305, mobile: 200 },
624
+ { month: strings.en.months[2], desktop: 237, mobile: 120 },
625
+ { month: strings.en.months[3], desktop: 73, mobile: 190 },
626
+ { month: strings.en.months[4], desktop: 209, mobile: 130 },
627
+ { month: strings.en.months[5], desktop: 214, mobile: 140 },
628
+ ],
629
+ [strings.en.months],
630
+ );
631
+
632
+ const monthConfig2 = useMemo(
633
+ () =>
634
+ ({
635
+ desktop: { label: strings.en.desktopLabel, color: "var(--chart-1)" },
636
+ mobile: { label: strings.en.mobileLabel, color: "var(--chart-2)" },
637
+ }) satisfies ChartConfig,
638
+ [strings.en.desktopLabel, strings.en.mobileLabel],
639
+ );
640
+
641
+ const monthConfig1 = useMemo(
642
+ () =>
643
+ ({
644
+ desktop: { label: strings.en.desktopLabel, color: "var(--chart-1)" },
645
+ }) satisfies ChartConfig,
646
+ [strings.en.desktopLabel],
647
+ );
648
+
649
+ /* 90일치 데일리 데이터 — Interactive 데모용. index 고정. */
650
+ const dailyData = useMemo(() => {
651
+ const out: { date: string; desktop: number; mobile: number }[] = [];
652
+ const start = new Date(2024, 3, 1);
653
+ let seed = 42;
654
+ const rand = () => {
655
+ seed = (seed * 9301 + 49297) % 233280;
656
+ return seed / 233280;
657
+ };
658
+ for (let i = 0; i < 90; i++) {
659
+ const d = new Date(start);
660
+ d.setDate(d.getDate() + i);
661
+ out.push({
662
+ date: d.toISOString().slice(0, 10),
663
+ desktop: Math.round(100 + rand() * 400),
664
+ mobile: Math.round(80 + rand() * 320),
665
+ });
666
+ }
667
+ return out;
668
+ }, []);
669
+ const dailyWithIndex = useMemo(
670
+ () => dailyData.map((row, i) => ({ ...row, i })),
671
+ [dailyData],
672
+ );
673
+
674
+ const dailyConfig = useMemo(
675
+ () =>
676
+ ({
677
+ desktop: { label: strings.en.desktopLabel, color: "var(--chart-1)" },
678
+ mobile: { label: strings.en.mobileLabel, color: "var(--chart-2)" },
679
+ }) satisfies ChartConfig,
680
+ [strings.en.desktopLabel, strings.en.mobileLabel],
681
+ );
682
+
683
+ /* hover 중인 카테고리 index — spotlight + tooltip 고정 위치용 (Usage 전용). */
684
+ const [activeIdx, setActiveIdx] = useState<number | null>(null);
685
+ const [activePos, setActivePos] = useState<{ x: number; y: number } | null>(null);
686
+ /* Usage BarChart 전용 bar 좌표 캐시. 다른 섹션은 공유 안 함(index 충돌 회피). */
687
+ const barTopY = useRef<Map<number, number>>(new Map());
688
+ const barCenterX = useRef<Map<number, number>>(new Map());
689
+
690
+ /* Playground BarChart 전용 bar 좌표 캐시 — Usage와 분리해 index 충돌 방지. */
691
+ const [pgLayout, setPgLayoutState] = useState<Layout>("horizontal");
692
+ const setPgLayout = setPgLayoutState;
693
+ const [pgActiveIdx, setPgActiveIdx] = useState<number | null>(null);
694
+ const [pgActivePos, setPgActivePos] = useState<{ x: number; y: number } | null>(null);
695
+ const pgBarAnchors = useRef<Map<number, Partial<Record<PlaygroundSeries, BarAnchor>>>>(new Map());
696
+ const pgBarShape = useCallback(
697
+ (series: PlaygroundSeries, props: BarShapeProps) => {
698
+ const { x = 0, y = 0, width = 0, height = 0, fill, index } = props;
699
+ if (typeof index === "number") {
700
+ const anchors = pgBarAnchors.current.get(index) ?? {};
701
+ anchors[series] = pgLayout === "horizontal"
702
+ ? { x: x + width / 2, y }
703
+ : { x: x + width, y: y + height / 2 };
704
+ pgBarAnchors.current.set(index, anchors);
705
+ }
706
+ const rRaw = Array.isArray(props.radius) ? props.radius : [props.radius ?? 0, props.radius ?? 0, 0, 0];
707
+ const w = Math.max(0, width);
708
+ const h = Math.max(0, height);
709
+ // radius는 bar 폭·높이 절반을 넘지 못하게 clamp (vertical 가로 bar에서 꺾임 방지).
710
+ const cap = Math.max(0, Math.min(w, h) / 2);
711
+ const tl = Math.min(rRaw[0] ?? 0, cap);
712
+ const tr = Math.min(rRaw[1] ?? 0, cap);
713
+ const br = Math.min(rRaw[2] ?? 0, cap);
714
+ const bl = Math.min(rRaw[3] ?? 0, cap);
715
+ const d = `M ${x + tl} ${y}
716
+ H ${x + w - tr}
717
+ A ${tr} ${tr} 0 0 1 ${x + w} ${y + tr}
718
+ V ${y + h - br}
719
+ A ${br} ${br} 0 0 1 ${x + w - br} ${y + h}
720
+ H ${x + bl}
721
+ A ${bl} ${bl} 0 0 1 ${x} ${y + h - bl}
722
+ V ${y + tl}
723
+ A ${tl} ${tl} 0 0 1 ${x + tl} ${y} Z`;
724
+ return (
725
+ <path
726
+ d={d}
727
+ fill={fill}
728
+ className={styles.spotlightBar}
729
+ data-spotlight-index={index}
730
+ />
731
+ );
732
+ },
733
+ [pgLayout]
734
+ );
735
+ const pgMobileBarShape = useCallback(
736
+ (props: BarShapeProps) => pgBarShape("mobile", props),
737
+ [pgBarShape],
738
+ );
739
+ const pgDesktopBarShape = useCallback(
740
+ (props: BarShapeProps) => pgBarShape("desktop", props),
741
+ [pgBarShape],
742
+ );
743
+ const usageBarShape = useCallback(
744
+ (props: { x?: number; y?: number; width?: number; height?: number; fill?: string; radius?: number | number[]; index?: number }) => {
745
+ const { x = 0, y = 0, width = 0, height = 0, fill, index } = props;
746
+ if (typeof index === "number") {
747
+ barTopY.current.set(index, y);
748
+ barCenterX.current.set(index, x + width / 2);
749
+ }
750
+ const rRaw = Array.isArray(props.radius) ? props.radius : [props.radius ?? 0, props.radius ?? 0, 0, 0];
751
+ const w = Math.max(0, width);
752
+ const h = Math.max(0, height);
753
+ // radius는 bar 폭·높이 절반을 넘지 못하게 clamp (vertical 가로 bar에서 꺾임 방지).
754
+ const cap = Math.max(0, Math.min(w, h) / 2);
755
+ const tl = Math.min(rRaw[0] ?? 0, cap);
756
+ const tr = Math.min(rRaw[1] ?? 0, cap);
757
+ const br = Math.min(rRaw[2] ?? 0, cap);
758
+ const bl = Math.min(rRaw[3] ?? 0, cap);
759
+ const d = `M ${x + tl} ${y}
760
+ H ${x + w - tr}
761
+ A ${tr} ${tr} 0 0 1 ${x + w} ${y + tr}
762
+ V ${y + h - br}
763
+ A ${br} ${br} 0 0 1 ${x + w - br} ${y + h}
764
+ H ${x + bl}
765
+ A ${bl} ${bl} 0 0 1 ${x} ${y + h - bl}
766
+ V ${y + tl}
767
+ A ${tl} ${tl} 0 0 1 ${x + tl} ${y} Z`;
768
+ return (
769
+ <path
770
+ d={d}
771
+ fill={fill}
772
+ className={styles.spotlightBar}
773
+ data-spotlight-index={index}
774
+ />
775
+ );
776
+ },
777
+ []
778
+ );
779
+
780
+ /* 다른 섹션용 — ref 안 건드리는 spotlight shape (활성 bar만 강조). */
781
+ const barShape = useCallback(
782
+ (props: { x?: number; y?: number; width?: number; height?: number; fill?: string; radius?: number | number[]; index?: number }) => {
783
+ const { x = 0, y = 0, width = 0, height = 0, fill, index } = props;
784
+ const rRaw = Array.isArray(props.radius) ? props.radius : [props.radius ?? 0, props.radius ?? 0, 0, 0];
785
+ const w = Math.max(0, width);
786
+ const h = Math.max(0, height);
787
+ // radius는 bar 폭·높이 절반을 넘지 못하게 clamp (vertical 가로 bar에서 꺾임 방지).
788
+ const cap = Math.max(0, Math.min(w, h) / 2);
789
+ const tl = Math.min(rRaw[0] ?? 0, cap);
790
+ const tr = Math.min(rRaw[1] ?? 0, cap);
791
+ const br = Math.min(rRaw[2] ?? 0, cap);
792
+ const bl = Math.min(rRaw[3] ?? 0, cap);
793
+ const d = `M ${x + tl} ${y}
794
+ H ${x + w - tr}
795
+ A ${tr} ${tr} 0 0 1 ${x + w} ${y + tr}
796
+ V ${y + h - br}
797
+ A ${br} ${br} 0 0 1 ${x + w - br} ${y + h}
798
+ H ${x + bl}
799
+ A ${bl} ${bl} 0 0 1 ${x} ${y + h - bl}
800
+ V ${y + tl}
801
+ A ${tl} ${tl} 0 0 1 ${x + tl} ${y} Z`;
802
+ return (
803
+ <path
804
+ d={d}
805
+ fill={fill}
806
+ className={styles.spotlightBar}
807
+ data-spotlight-index={index}
808
+ />
809
+ );
810
+ },
811
+ []
812
+ );
813
+ const tooltipPosition = useMemo(
814
+ () => (activePos ? { x: activePos.x, y: Math.max(0, activePos.y - 8) } : undefined),
815
+ [activePos]
816
+ );
817
+
818
+ /* Playground 상태 */
819
+ const [pgFat, setPgFat] = useState<Fat>("md");
820
+ const { shape: themeShape, motionMode } = useTheme();
821
+ const shapeRadius: Radii =
822
+ themeShape === "soft" || themeShape === "pill" ? "pill" :
823
+ themeShape === "crisp" ? "none" : "md";
824
+ const [pgRadius, setPgRadiusState] = useState<Radii>(shapeRadius);
825
+ const radiusTouched = useRef(false);
826
+ const setPgRadius = (v: Radii) => { radiusTouched.current = true; setPgRadiusState(v); };
827
+ useEffect(() => {
828
+ if (!radiusTouched.current) setPgRadiusState(shapeRadius);
829
+ }, [shapeRadius]);
830
+ const [pgTooltipKind, setPgTooltipKind] = useState<TooltipKind>("bubble");
831
+ const [pgBubbleColor, setPgBubbleColor] = useState<BubbleColor>("dark");
832
+ const [pgIndicator, setPgIndicator] = useState<Indicator>("dot");
833
+ const [pgTooltipSize, setPgTooltipSize] = useState<TooltipSize>("md");
834
+ const [pgLegendAlign, setPgLegendAlign] = useState<LegendAlign>("center");
835
+ const [pgStacked, setPgStacked] = useState(false);
836
+ const [pgLegend, setPgLegend] = useState(true);
837
+ const [pgGrid, setPgGrid] = useState(true);
838
+
839
+ /* Legend 클릭 = 그것만 남김 (exclusive solo).
840
+ 먼저 숨길 series의 값을 0까지 보간하고, animation end 뒤 layout 계산에서 제외한다. */
841
+ const [solo, setSolo] = useState<string | null>(null);
842
+ const [layoutHiddenKey, setLayoutHiddenKey] = useState<string | null>(null);
843
+ const [prefersReducedMotion, setPrefersReducedMotion] = useState(false);
844
+ useEffect(() => {
845
+ const media = window.matchMedia("(prefers-reduced-motion: reduce)");
846
+ const sync = () => setPrefersReducedMotion(media.matches);
847
+ sync();
848
+ media.addEventListener("change", sync);
849
+ return () => media.removeEventListener("change", sync);
850
+ }, []);
851
+ const legendAnimationDuration = useMemo(
852
+ () => motionPresets.find((preset) => preset.id === motionMode)?.duration ?? 0,
853
+ [motionMode],
854
+ );
855
+ const legendAnimationActive = legendAnimationDuration > 0 && !prefersReducedMotion;
856
+ const seriesKeys = useMemo(() => Object.keys(monthConfig2), [monthConfig2]);
857
+ const desiredHiddenKey = solo ? seriesKeys.find((key) => key !== solo) ?? null : null;
858
+ const toggleSeries = (key: string) => {
859
+ const nextSolo = solo === key ? null : key;
860
+ const nextHiddenKey = nextSolo ? seriesKeys.find((series) => series !== nextSolo) ?? null : null;
861
+ setLayoutHiddenKey(legendAnimationActive ? null : nextHiddenKey);
862
+ setSolo(nextSolo);
863
+ };
864
+ const finishLegendTransition = useCallback(() => {
865
+ setLayoutHiddenKey((current) => current === desiredHiddenKey ? current : desiredHiddenKey);
866
+ }, [desiredHiddenKey]);
867
+ const hidden = useMemo(() => {
868
+ if (!solo) return new Set<string>();
869
+ return new Set(seriesKeys.filter((key) => key !== solo));
870
+ }, [solo, seriesKeys]);
871
+ const pgData = useMemo(() => {
872
+ if (hidden.size === 0) return monthData;
873
+ return monthData.map((row) => {
874
+ const next: Record<string, number | string> = { ...row };
875
+ for (const k of hidden) if (k in next) next[k] = 0;
876
+ return next;
877
+ });
878
+ }, [hidden, monthData]);
879
+
880
+ /* Interactive demo: xStart 보간. */
881
+ const [range, setRange] = useState<"90d" | "30d" | "7d">("90d");
882
+ const [xStart, setXStart] = useState(0);
883
+ const lastDailyIndex = dailyWithIndex.length - 1;
884
+ const visibleDayCount = range === "7d" ? 7 : range === "30d" ? 30 : 90;
885
+ const targetStart = lastDailyIndex - visibleDayCount + 1;
886
+ useEffect(() => {
887
+ let raf = 0;
888
+ const from = xStart;
889
+ const to = targetStart;
890
+ const start = performance.now();
891
+ const duration = 480;
892
+ const ease = (p: number) => 1 - Math.pow(1 - p, 4);
893
+ const step = (now: number) => {
894
+ const p = Math.min(1, (now - start) / duration);
895
+ setXStart(from + (to - from) * ease(p));
896
+ if (p < 1) raf = requestAnimationFrame(step);
897
+ };
898
+ raf = requestAnimationFrame(step);
899
+ return () => cancelAnimationFrame(raf);
900
+ // eslint-disable-next-line react-hooks/exhaustive-deps
901
+ }, [targetStart]);
902
+ const xDomain = useMemo<[number, number]>(
903
+ () => [xStart - 0.5, lastDailyIndex + 0.5],
904
+ [lastDailyIndex, xStart],
905
+ );
906
+ const tickFmt = useCallback((idx: number) => {
907
+ const row = dailyData[Math.round(idx)];
908
+ if (!row) return "";
909
+ const d = new Date(row.date);
910
+ return strings.en.dateFmt(d.getMonth() + 1, d.getDate());
911
+ }, [t, dailyData]);
912
+ const tooltipLabelFmt = useCallback((v: ReactNode) => {
913
+ const row = dailyData[Math.round(Number(v))];
914
+ if (!row) return "";
915
+ const d = new Date(row.date);
916
+ return strings.en.dateFmt(d.getMonth() + 1, d.getDate());
917
+ }, [t, dailyData]);
918
+
919
+ return (
920
+ <>
921
+ <h1 className="page-title">{t.title}</h1>
922
+ <p className="page-lead">{t.lead}</p>
923
+
924
+ <section id="usage" className="section-first">
925
+ <h2>{t.usage.heading}</h2>
926
+ <p className="desc">{t.usage.desc}</p>
927
+ <ExampleBlock
928
+ code={`import { Bar, BarChart } from "recharts";
929
+ import { ChartContainer } from "@/components/Chart";
930
+
931
+ <ChartContainer config={config}>
932
+ <BarChart data={data} accessibilityLayer>
933
+ <Bar dataKey="desktop" fill="var(--color-desktop)" />
934
+ </BarChart>
935
+ </ChartContainer>`}
936
+ >
937
+ <div className={styles.chartWrap}>
938
+ {activePos && activeIdx != null && monthData[activeIdx] && (
939
+ <div
940
+ className={styles.bubble}
941
+ style={{ left: activePos.x, top: activePos.y }}
942
+ >
943
+ <span className={styles.bubbleLabel}>{monthData[activeIdx].month}</span>
944
+ <span className={styles.bubbleValue}>{monthData[activeIdx].desktop.toLocaleString()}</span>
945
+ </div>
946
+ )}
947
+ <ChartContainer config={monthConfig1}>
948
+ <BarChart maxBarSize={32} barCategoryGap="25%" data={monthData}
949
+ accessibilityLayer
950
+ margin={{ left: 12, right: 12, top: 32 }}
951
+ onMouseMove={(state, event) => {
952
+ const idx = state?.activeTooltipIndex;
953
+ const nextIdx = typeof idx === "number" ? idx : idx != null ? Number(idx) : null;
954
+ updateBarSpotlight(event.currentTarget, nextIdx);
955
+ setActiveIdx(nextIdx);
956
+ if (nextIdx != null) {
957
+ const topY = barTopY.current.get(nextIdx);
958
+ const cx = barCenterX.current.get(nextIdx) ?? state?.activeCoordinate?.x;
959
+ if (typeof cx === "number" && typeof topY === "number") {
960
+ setActivePos({ x: cx, y: topY });
961
+ }
962
+ }
963
+ }}
964
+ onMouseLeave={(_, event) => {
965
+ updateBarSpotlight(event.currentTarget, null);
966
+ setActiveIdx(null);
967
+ setActivePos(null);
968
+ }}
969
+ >
970
+ <CartesianGrid vertical={false} />
971
+ <XAxis dataKey="month" tickLine={false} axisLine={false} tickMargin={8} />
972
+ <Bar
973
+ dataKey="desktop"
974
+ fill="var(--color-desktop)"
975
+ radius={8}
976
+ isAnimationActive={false}
977
+ shape={usageBarShape}
978
+ />
979
+ </BarChart>
980
+ </ChartContainer>
981
+ </div>
982
+ </ExampleBlock>
983
+ </section>
984
+
985
+ <Playground
986
+ axes={[
987
+ { label: "layout", value: pgLayout, onChange: (v) => setPgLayout(v as Layout), options: LAYOUTS },
988
+ { label: "fat", value: pgFat, onChange: (v) => setPgFat(v as Fat), options: FATS },
989
+ { label: "radius", value: pgRadius, onChange: (v) => setPgRadius(v as Radii), options: RADII },
990
+ { label: "tooltip", value: pgTooltipKind, onChange: (v) => setPgTooltipKind(v as TooltipKind), options: TOOLTIP_KINDS },
991
+ { label: "bubble color", value: pgBubbleColor, onChange: (v) => setPgBubbleColor(v as BubbleColor), options: BUBBLE_COLORS },
992
+ { label: "indicator", value: pgIndicator, onChange: (v) => setPgIndicator(v as Indicator), options: INDICATORS },
993
+ { label: "tooltip size", value: pgTooltipSize, onChange: (v) => setPgTooltipSize(v as TooltipSize), options: TOOLTIP_SIZES },
994
+ { label: "legend align", value: pgLegendAlign, onChange: (v) => setPgLegendAlign(v as LegendAlign), options: LEGEND_ALIGNS },
995
+ ]}
996
+ toggles={[
997
+ { label: "stacked", value: pgStacked, onChange: setPgStacked },
998
+ { label: "legend", value: pgLegend, onChange: setPgLegend },
999
+ { label: "grid", value: pgGrid, onChange: setPgGrid },
1000
+ ]}
1001
+ >
1002
+ <div className={styles.chartWrap}>
1003
+ {pgTooltipKind === "bubble" && pgActivePos && pgActiveIdx != null && pgData[pgActiveIdx] && (
1004
+ <div
1005
+ className={styles.bubble}
1006
+ data-color={pgBubbleColor}
1007
+ data-size={pgTooltipSize}
1008
+ data-direction={pgLayout === "vertical" ? "right" : "up"}
1009
+ style={{ left: pgActivePos.x, top: pgActivePos.y }}
1010
+ >
1011
+ <span className={styles.bubbleLabel}>{String(pgData[pgActiveIdx].month)}</span>
1012
+ <span className={styles.bubbleValue}>
1013
+ {Number(pgData[pgActiveIdx].desktop ?? 0).toLocaleString()}
1014
+ {pgData[pgActiveIdx].mobile != null
1015
+ ? ` · ${Number(pgData[pgActiveIdx].mobile).toLocaleString()}`
1016
+ : ""}
1017
+ </span>
1018
+ </div>
1019
+ )}
1020
+ <ChartContainer
1021
+ config={monthConfig2}
1022
+ className={styles.playgroundChart}
1023
+ key={`${pgLayout}-${pgStacked}-${pgLegend}-${pgGrid}-${pgIndicator}-${pgTooltipSize}-${pgLegendAlign}-${pgRadius}-${pgTooltipKind}-${pgFat}`}
1024
+ >
1025
+ <BarChart barCategoryGap={FAT_CATEGORY_GAP[pgFat]} data={pgData}
1026
+ layout={pgLayout}
1027
+ accessibilityLayer
1028
+ margin={{ left: 12, right: 12, top: 32 }}
1029
+ onMouseMove={(state, event) => {
1030
+ const idx = state?.activeTooltipIndex;
1031
+ const nextIdx = typeof idx === "number" ? idx : idx != null ? Number(idx) : null;
1032
+ updateBarSpotlight(event.currentTarget, nextIdx);
1033
+ setPgActiveIdx(nextIdx);
1034
+ if (nextIdx != null) {
1035
+ const anchors = Object.entries(pgBarAnchors.current.get(nextIdx) ?? {})
1036
+ .filter(([series]) => !hidden.has(series))
1037
+ .map(([, anchor]) => anchor);
1038
+ if (anchors.length > 0) {
1039
+ const x = pgLayout === "horizontal"
1040
+ ? anchors.reduce((sum, anchor) => sum + anchor.x, 0) / anchors.length
1041
+ : Math.max(...anchors.map((anchor) => anchor.x));
1042
+ const y = pgLayout === "horizontal"
1043
+ ? Math.min(...anchors.map((anchor) => anchor.y))
1044
+ : anchors.reduce((sum, anchor) => sum + anchor.y, 0) / anchors.length;
1045
+ setPgActivePos({ x, y });
1046
+ }
1047
+ }
1048
+ }}
1049
+ onMouseLeave={(_, event) => {
1050
+ updateBarSpotlight(event.currentTarget, null);
1051
+ setPgActiveIdx(null);
1052
+ setPgActivePos(null);
1053
+ }}
1054
+ >
1055
+ {pgGrid && <CartesianGrid vertical={pgLayout === "vertical"} horizontal={pgLayout === "horizontal"} />}
1056
+ {pgLayout === "horizontal" ? (
1057
+ <>
1058
+ <XAxis dataKey="month" tickLine={false} axisLine={false} tickMargin={8} />
1059
+ <YAxis tickLine={false} axisLine={false} tickMargin={4} width={32} />
1060
+ </>
1061
+ ) : (
1062
+ <>
1063
+ <XAxis type="number" tickLine={false} axisLine={false} tickMargin={8} />
1064
+ <YAxis dataKey="month" type="category" tickLine={false} axisLine={false} tickMargin={4} width={40} />
1065
+ </>
1066
+ )}
1067
+ {pgTooltipKind === "recharts" && (
1068
+ <ChartTooltip cursor={false} content={<ChartTooltipContent indicator={pgIndicator} size={pgTooltipSize} />} />
1069
+ )}
1070
+ {pgLegend && (
1071
+ <ChartLegend
1072
+ verticalAlign="bottom"
1073
+ wrapperStyle={{
1074
+ width: "100%",
1075
+ left: 0,
1076
+ display: "flex",
1077
+ justifyContent:
1078
+ pgLegendAlign === "left" ? "flex-start" :
1079
+ pgLegendAlign === "right" ? "flex-end" : "center",
1080
+ }}
1081
+ content={
1082
+ <ChartLegendContent
1083
+ align={pgLegendAlign}
1084
+ hidden={hidden}
1085
+ onItemClick={toggleSeries}
1086
+ />
1087
+ }
1088
+ />
1089
+ )}
1090
+ <Bar
1091
+ dataKey="mobile"
1092
+ fill="var(--color-mobile)"
1093
+ hide={layoutHiddenKey === "mobile"}
1094
+ radius={
1095
+ pgStacked
1096
+ ? (pgLayout === "horizontal"
1097
+ ? [0, 0, RADIUS_PX[pgRadius], RADIUS_PX[pgRadius]]
1098
+ : [RADIUS_PX[pgRadius], 0, 0, RADIUS_PX[pgRadius]])
1099
+ : (pgLayout === "horizontal"
1100
+ ? [RADIUS_PX[pgRadius], RADIUS_PX[pgRadius], 0, 0]
1101
+ : [0, RADIUS_PX[pgRadius], RADIUS_PX[pgRadius], 0])
1102
+ }
1103
+ stackId={pgStacked ? "a" : undefined}
1104
+ isAnimationActive={legendAnimationActive}
1105
+ animationDuration={legendAnimationDuration}
1106
+ animationEasing="ease-out"
1107
+ onAnimationEnd={finishLegendTransition}
1108
+ shape={pgMobileBarShape}
1109
+ />
1110
+ <Bar
1111
+ dataKey="desktop"
1112
+ fill="var(--color-desktop)"
1113
+ hide={layoutHiddenKey === "desktop"}
1114
+ radius={
1115
+ pgLayout === "horizontal"
1116
+ ? [RADIUS_PX[pgRadius], RADIUS_PX[pgRadius], 0, 0]
1117
+ : [0, RADIUS_PX[pgRadius], RADIUS_PX[pgRadius], 0]
1118
+ }
1119
+ stackId={pgStacked ? "a" : undefined}
1120
+ isAnimationActive={legendAnimationActive}
1121
+ animationDuration={legendAnimationDuration}
1122
+ animationEasing="ease-out"
1123
+ onAnimationEnd={finishLegendTransition}
1124
+ shape={pgDesktopBarShape}
1125
+ />
1126
+ </BarChart>
1127
+ </ChartContainer>
1128
+ </div>
1129
+ </Playground>
1130
+
1131
+ <section id="variants">
1132
+ <h2>{t.variants.heading}</h2>
1133
+ <p className="desc">{t.variants.desc}</p>
1134
+
1135
+ <p className="desc">{t.variants.horizontalDesc}</p>
1136
+ <ExampleBlock
1137
+ code={`<BarChart maxBarSize={32} barCategoryGap="25%" data={data} layout="vertical">
1138
+ <XAxis type="number" ... />
1139
+ <YAxis dataKey="month" type="category" ... />
1140
+ <Bar dataKey="desktop" fill="var(--color-desktop)" radius={[0, 6, 6, 0]} />
1141
+ </BarChart>`}
1142
+ >
1143
+ <ChartContainer config={monthConfig1}>
1144
+ <BarChart maxBarSize={32} barCategoryGap="25%" data={monthData} layout="vertical" accessibilityLayer margin={{ left: 12, right: 12, top: 32 }}
1145
+ onMouseMove={(state, event) => {
1146
+ const idx = state?.activeTooltipIndex;
1147
+ const nextIdx = typeof idx === "number" ? idx : idx != null ? Number(idx) : null;
1148
+ updateBarSpotlight(event.currentTarget, nextIdx);
1149
+ setActiveIdx(nextIdx);
1150
+ }}
1151
+ onMouseLeave={(_, event) => {
1152
+ updateBarSpotlight(event.currentTarget, null);
1153
+ setActiveIdx(null);
1154
+ }}
1155
+ >
1156
+ <CartesianGrid horizontal={false} />
1157
+ <XAxis type="number" tickLine={false} axisLine={false} tickMargin={8} />
1158
+ <YAxis dataKey="month" type="category" tickLine={false} axisLine={false} tickMargin={4} width={40} />
1159
+ <ChartTooltip position={tooltipPosition} cursor={false} content={<ChartTooltipContent indicator="line" />} />
1160
+ <Bar
1161
+ dataKey="desktop"
1162
+ fill="var(--color-desktop)"
1163
+ radius={[0, RADIUS_PX.md, RADIUS_PX.md, 0]}
1164
+ isAnimationActive={false}
1165
+ shape={barShape}
1166
+ />
1167
+ </BarChart>
1168
+ </ChartContainer>
1169
+ </ExampleBlock>
1170
+
1171
+ <p className="desc">{t.variants.multipleDesc}</p>
1172
+ <ExampleBlock
1173
+ code={`<Bar dataKey="desktop" fill="var(--color-desktop)" radius={4} />
1174
+ <Bar dataKey="mobile" fill="var(--color-mobile)" radius={4} />`}
1175
+ >
1176
+ <ChartContainer config={monthConfig2}>
1177
+ <BarChart maxBarSize={32} barCategoryGap="25%" data={monthData} accessibilityLayer margin={{ left: 12, right: 12, top: 32 }}
1178
+ onMouseMove={(state, event) => {
1179
+ const idx = state?.activeTooltipIndex;
1180
+ const nextIdx = typeof idx === "number" ? idx : idx != null ? Number(idx) : null;
1181
+ updateBarSpotlight(event.currentTarget, nextIdx);
1182
+ setActiveIdx(nextIdx);
1183
+ }}
1184
+ onMouseLeave={(_, event) => {
1185
+ updateBarSpotlight(event.currentTarget, null);
1186
+ setActiveIdx(null);
1187
+ }}
1188
+ >
1189
+ <CartesianGrid vertical={false} />
1190
+ <XAxis dataKey="month" tickLine={false} axisLine={false} tickMargin={8} />
1191
+ <ChartTooltip position={tooltipPosition} cursor={false} content={<ChartTooltipContent indicator="dot" />} />
1192
+ <ChartLegend content={<ChartLegendContent />} />
1193
+ <Bar dataKey="desktop" fill="var(--color-desktop)" radius={4} isAnimationActive={false} shape={barShape} />
1194
+ <Bar dataKey="mobile" fill="var(--color-mobile)" radius={4} isAnimationActive={false} shape={barShape} />
1195
+ </BarChart>
1196
+ </ChartContainer>
1197
+ </ExampleBlock>
1198
+ </section>
1199
+
1200
+ <section id="stacked">
1201
+ <h2>{t.stacked.heading}</h2>
1202
+ <p className="desc">{t.stacked.desc}</p>
1203
+ <ExampleBlock
1204
+ code={`<Bar dataKey="mobile" stackId="a" fill="var(--color-mobile)" radius={[0,0,4,4]} />
1205
+ <Bar dataKey="desktop" stackId="a" fill="var(--color-desktop)" radius={[4,4,0,0]} />`}
1206
+ >
1207
+ <ChartContainer config={monthConfig2}>
1208
+ <BarChart maxBarSize={32} barCategoryGap="25%" data={monthData} accessibilityLayer margin={{ left: 12, right: 12, top: 32 }}
1209
+ onMouseMove={(state, event) => {
1210
+ const idx = state?.activeTooltipIndex;
1211
+ const nextIdx = typeof idx === "number" ? idx : idx != null ? Number(idx) : null;
1212
+ updateBarSpotlight(event.currentTarget, nextIdx);
1213
+ setActiveIdx(nextIdx);
1214
+ }}
1215
+ onMouseLeave={(_, event) => {
1216
+ updateBarSpotlight(event.currentTarget, null);
1217
+ setActiveIdx(null);
1218
+ }}
1219
+ >
1220
+ <CartesianGrid vertical={false} />
1221
+ <XAxis dataKey="month" tickLine={false} axisLine={false} tickMargin={8} />
1222
+ <ChartTooltip position={tooltipPosition} cursor={false} content={<ChartTooltipContent indicator="dot" />} />
1223
+ <ChartLegend content={<ChartLegendContent />} />
1224
+ <Bar dataKey="mobile" stackId="a" fill="var(--color-mobile)" radius={[0, 0, 4, 4]} isAnimationActive={false} shape={barShape} />
1225
+ <Bar dataKey="desktop" stackId="a" fill="var(--color-desktop)" radius={[4, 4, 0, 0]} isAnimationActive={false} shape={barShape} />
1226
+ </BarChart>
1227
+ </ChartContainer>
1228
+ </ExampleBlock>
1229
+
1230
+ <p className="desc">{t.stacked.expandDesc}</p>
1231
+ <ExampleBlock code={`<BarChart maxBarSize={32} barCategoryGap="25%" data={data} stackOffset="expand" ...>`}>
1232
+ <ChartContainer config={monthConfig2}>
1233
+ <BarChart maxBarSize={32} barCategoryGap="25%" data={monthData} stackOffset="expand" accessibilityLayer margin={{ left: 12, right: 12, top: 32 }}
1234
+ onMouseMove={(state, event) => {
1235
+ const idx = state?.activeTooltipIndex;
1236
+ const nextIdx = typeof idx === "number" ? idx : idx != null ? Number(idx) : null;
1237
+ updateBarSpotlight(event.currentTarget, nextIdx);
1238
+ setActiveIdx(nextIdx);
1239
+ }}
1240
+ onMouseLeave={(_, event) => {
1241
+ updateBarSpotlight(event.currentTarget, null);
1242
+ setActiveIdx(null);
1243
+ }}
1244
+ >
1245
+ <CartesianGrid vertical={false} />
1246
+ <XAxis dataKey="month" tickLine={false} axisLine={false} tickMargin={8} />
1247
+ <ChartTooltip position={tooltipPosition} cursor={false} content={<ChartTooltipContent indicator="dot" />} />
1248
+ <ChartLegend content={<ChartLegendContent />} />
1249
+ <Bar dataKey="mobile" stackId="a" fill="var(--color-mobile)" radius={[0, 0, 4, 4]} isAnimationActive={false} shape={barShape} />
1250
+ <Bar dataKey="desktop" stackId="a" fill="var(--color-desktop)" radius={[4, 4, 0, 0]} isAnimationActive={false} shape={barShape} />
1251
+ </BarChart>
1252
+ </ChartContainer>
1253
+ </ExampleBlock>
1254
+ </section>
1255
+
1256
+ <section id="interactive">
1257
+ <h2>{t.interactive.heading}</h2>
1258
+ <p className="desc">{t.interactive.desc}</p>
1259
+ <ExampleBlock
1260
+ code={`const [range, setRange] = useState("90d");
1261
+ const lastIndex = dailyWithIndex.length - 1;
1262
+ // Add half a category at each end to prevent clipping.
1263
+ <BarChart maxBarSize={32} barCategoryGap="25%" data={dailyWithIndex}>
1264
+ <XAxis dataKey="i" type="number" domain={[xStart - 0.5, lastIndex + 0.5]} allowDataOverflow />
1265
+ ...
1266
+ </BarChart>`}
1267
+ >
1268
+ <div className={styles.interactiveStack}>
1269
+ <div className={styles.rangeTabs}>
1270
+ <Tabs
1271
+ variant="segmented"
1272
+ size="md"
1273
+ value={range}
1274
+ onValueChange={(v) => setRange(v as "90d" | "30d" | "7d")}
1275
+ >
1276
+ <Tabs.List>
1277
+ <Tabs.Trigger value="7d">Last 7 days</Tabs.Trigger>
1278
+ <Tabs.Trigger value="30d">Last 30 days</Tabs.Trigger>
1279
+ <Tabs.Trigger value="90d">Last 90 days</Tabs.Trigger>
1280
+ </Tabs.List>
1281
+ </Tabs>
1282
+ </div>
1283
+ <ChartContainer config={dailyConfig}>
1284
+ <BarChart maxBarSize={10} barCategoryGap="20%" data={dailyWithIndex} accessibilityLayer margin={{ left: 12, right: 12, top: 32 }}
1285
+ onMouseMove={(state, event) => {
1286
+ const idx = state?.activeTooltipIndex;
1287
+ const nextIdx = typeof idx === "number" ? idx : idx != null ? Number(idx) : null;
1288
+ updateBarSpotlight(event.currentTarget, nextIdx);
1289
+ setActiveIdx(nextIdx);
1290
+ }}
1291
+ onMouseLeave={(_, event) => {
1292
+ updateBarSpotlight(event.currentTarget, null);
1293
+ setActiveIdx(null);
1294
+ }}
1295
+ >
1296
+ <CartesianGrid vertical={false} />
1297
+ <XAxis
1298
+ dataKey="i"
1299
+ tickLine={false}
1300
+ axisLine={false}
1301
+ tickMargin={8}
1302
+ type="number"
1303
+ domain={xDomain}
1304
+ allowDataOverflow
1305
+ minTickGap={32}
1306
+ tickFormatter={tickFmt}
1307
+ />
1308
+ <ChartTooltip
1309
+ cursor={false}
1310
+ content={<ChartTooltipContent indicator="dot" labelFormatter={tooltipLabelFmt} />}
1311
+ />
1312
+ <Bar
1313
+ shape={barShape}
1314
+ dataKey="mobile"
1315
+ fill="var(--color-mobile)"
1316
+ stackId="a"
1317
+ radius={[0, 0, 2, 2]}
1318
+ isAnimationActive={false}
1319
+ />
1320
+ <Bar
1321
+ shape={barShape}
1322
+ dataKey="desktop"
1323
+ fill="var(--color-desktop)"
1324
+ stackId="a"
1325
+ radius={[2, 2, 0, 0]}
1326
+ isAnimationActive={false}
1327
+ />
1328
+ <ChartLegend content={<ChartLegendContent />} />
1329
+ </BarChart>
1330
+ </ChartContainer>
1331
+ </div>
1332
+ </ExampleBlock>
1333
+ </section>
1334
+
1335
+ <section id="use-cases">
1336
+ <h2>{t.useCases.heading}</h2>
1337
+ <p className="desc">{t.useCases.desc}</p>
1338
+
1339
+ <h3>{t.useCases.pipeline.title}</h3>
1340
+ <ExampleBlock
1341
+
1342
+ align="column"
1343
+ >
1344
+ <PipelineUseCase strings={strings.en.useCases.pipeline} />
1345
+ </ExampleBlock>
1346
+ <h3>{en ? "Support requests card" : "문의 현황 카드"}</h3>
1347
+ <ExampleBlock previewWidth="full"><SupportCardExample /></ExampleBlock>
1348
+ </section>
1349
+
1350
+ <section id="api">
1351
+ <h2>{t.api.heading}</h2>
1352
+ <p className="desc">
1353
+ {t.api.desc}{" "}
1354
+ <a href="https://recharts.org" target="_blank" rel="noreferrer">
1355
+ {t.api.officialDocs}
1356
+ </a>{en ? "." : "에서 확인하세요."}
1357
+ </p>
1358
+
1359
+ <h3>ChartContainer</h3>
1360
+ <DocsTable
1361
+ columns={[
1362
+ { key: "prop", label: t.api.columns.prop, width: 160 },
1363
+ { key: "type", label: t.api.columns.type, flex: true, minWidth: 200 },
1364
+ { key: "default", label: t.api.columns.default, width: 120 },
1365
+ { key: "desc", label: t.api.columns.desc, flex: true, minWidth: 240 },
1366
+ ]}
1367
+ rows={[
1368
+ { prop: "animateIn", type: "boolean", default: "true", desc: en ? "Draws the chart once when it first enters the viewport." : "화면에 처음 나타날 때 차트를 한 번 그립니다." },
1369
+ { prop: "config", type: "ChartConfig", default: "-", desc: t.api.container.config },
1370
+ { prop: "className", type: "string", default: "-", desc: t.api.container.className },
1371
+ { prop: "children", type: "ReactElement", default: "-", desc: t.api.container.children },
1372
+ ]}
1373
+ />
1374
+
1375
+ <h3>ChartTooltipContent</h3>
1376
+ <DocsTable
1377
+ columns={[
1378
+ { key: "prop", label: t.api.columns.prop, width: 160 },
1379
+ { key: "type", label: t.api.columns.type, flex: true, minWidth: 200 },
1380
+ { key: "default", label: t.api.columns.default, width: 120 },
1381
+ { key: "desc", label: t.api.columns.desc, flex: true, minWidth: 240 },
1382
+ ]}
1383
+ rows={[
1384
+ { prop: "indicator", type: `"dot" | "line"`, default: `"dot"`, desc: t.api.tooltip.indicator },
1385
+ { prop: "hideLabel", type: "boolean", default: "false", desc: t.api.tooltip.hideLabel },
1386
+ { prop: "hideIndicator", type: "boolean", default: "false", desc: t.api.tooltip.hideIndicator },
1387
+ { prop: "nameKey", type: "string", default: "-", desc: t.api.tooltip.nameKey },
1388
+ { prop: "labelKey", type: "string", default: "-", desc: t.api.tooltip.labelKey },
1389
+ { prop: "labelFormatter", type: "(value, payload) => ReactNode", default: "-", desc: t.api.tooltip.labelFormatter },
1390
+ { prop: "formatter", type: "(value, name, item, index, payload) => ReactNode", default: "-", desc: t.api.tooltip.formatter },
1391
+ ]}
1392
+ />
1393
+
1394
+ <h3>ChartLegendContent</h3>
1395
+ <DocsTable
1396
+ columns={[
1397
+ { key: "prop", label: t.api.columns.prop, width: 160 },
1398
+ { key: "type", label: t.api.columns.type, flex: true, minWidth: 200 },
1399
+ { key: "default", label: t.api.columns.default, width: 120 },
1400
+ { key: "desc", label: t.api.columns.desc, flex: true, minWidth: 240 },
1401
+ ]}
1402
+ rows={[
1403
+ { prop: "hideIcon", type: "boolean", default: "false", desc: t.api.legend.hideIcon },
1404
+ { prop: "nameKey", type: "string", default: "-", desc: t.api.legend.nameKey },
1405
+ { prop: "verticalAlign", type: `"top" | "bottom"`, default: `"bottom"`, desc: t.api.legend.verticalAlign },
1406
+ ]}
1407
+ />
1408
+
1409
+ <h3>ChartConfig</h3>
1410
+ <DocsTable
1411
+ columns={[
1412
+ { key: "prop", label: t.api.columnsKey.prop, width: 160 },
1413
+ { key: "type", label: t.api.columnsKey.type, flex: true, minWidth: 200 },
1414
+ { key: "default", label: t.api.columnsKey.default, width: 120 },
1415
+ { key: "desc", label: t.api.columnsKey.desc, flex: true, minWidth: 240 },
1416
+ ]}
1417
+ rows={[
1418
+ { prop: "label", type: "ReactNode", default: "-", desc: t.api.config.label },
1419
+ { prop: "icon", type: "ComponentType", default: "-", desc: t.api.config.icon },
1420
+ { prop: "color", type: "string", default: "-", desc: t.api.config.color },
1421
+ { prop: "theme", type: `{ light: string; dark: string }`, default: "-", desc: t.api.config.theme },
1422
+ ]}
1423
+ />
1424
+ </section>
1425
+ </>
1426
+ );
1427
+ }
1428
+
1429
+ /* Pipeline use case — 가로 바 리스트 (각 행이 독립 색). 벤더 BarChart를
1430
+ layout="vertical"로 단일 bar로 돌리고, 외부 CSS Grid 3열(stage · bar · amount)로
1431
+ 세로 정렬을 맞춘다. count=0 데이터도 안쪽에 "0건" 라벨은 그리지 않는다. */
1432
+ const PIPELINE_COLORS = [
1433
+ "var(--chart-5)",
1434
+ "var(--chart-4)",
1435
+ "var(--chart-3)",
1436
+ "var(--chart-2)",
1437
+ "var(--chart-1)",
1438
+ ];
1439
+
1440
+ type PipelineStrings = {
1441
+ title: string;
1442
+ totalBadge: string;
1443
+ amountLabel: string;
1444
+ stages: { label: string; amount: number; amountDisplay: string }[];
1445
+ };
1446
+
1447
+ function PipelineUseCase({ strings: s }: { strings: PipelineStrings }) {
1448
+ const config = useMemo<ChartConfig>(
1449
+ () => ({ amount: { label: s.amountLabel, color: "var(--chart-1)" } }),
1450
+ [s.amountLabel],
1451
+ );
1452
+ const maxAmount = Math.max(...s.stages.map((row) => row.amount), 1);
1453
+ const displayByAmount = useMemo(() => {
1454
+ const map = new Map<number, string>();
1455
+ for (const row of s.stages) map.set(row.amount, row.amountDisplay);
1456
+ return map;
1457
+ }, [s.stages]);
1458
+
1459
+ return (
1460
+ <Card variant="line" className={styles.pipelineCard}>
1461
+ <header className={styles.pipelineHeader}>
1462
+ <div className={styles.pipelineTitleRow}>
1463
+ <h3 className={styles.pipelineTitle}>{s.title}</h3>
1464
+ <Badge variant="soft" size="sm">{s.totalBadge}</Badge>
1465
+ </div>
1466
+ </header>
1467
+
1468
+ <ul className={styles.pipelineList}>
1469
+ {s.stages.map((row, i) => (
1470
+ <li key={row.label} className={styles.pipelineRow}>
1471
+ <span className={styles.pipelineStage}>
1472
+ <span
1473
+ className={styles.pipelineDot}
1474
+ style={{ background: PIPELINE_COLORS[i % PIPELINE_COLORS.length] }}
1475
+ aria-hidden
1476
+ />
1477
+ {row.label}
1478
+ </span>
1479
+ <div className={styles.pipelineBarWrap}>
1480
+ <ChartContainer config={config}>
1481
+ <BarChart
1482
+ data={[{ name: row.label, amount: row.amount }]}
1483
+ layout="vertical"
1484
+ margin={{ left: 0, right: 56, top: 0, bottom: 0 }}
1485
+ barCategoryGap={0}
1486
+ >
1487
+ <XAxis type="number" domain={[0, maxAmount]} hide />
1488
+ <YAxis type="category" dataKey="name" hide />
1489
+ <Bar dataKey="amount" radius={2} isAnimationActive={false}>
1490
+ <Cell fill={PIPELINE_COLORS[i % PIPELINE_COLORS.length]} />
1491
+ {row.amount > 0 && (
1492
+ <LabelList
1493
+ dataKey="amount"
1494
+ position="right"
1495
+ offset={8}
1496
+ className={styles.pipelineBarLabel}
1497
+ formatter={(value) => displayByAmount.get(Number(value)) ?? String(value)}
1498
+ />
1499
+ )}
1500
+ </Bar>
1501
+ </BarChart>
1502
+ </ChartContainer>
1503
+ </div>
1504
+ </li>
1505
+ ))}
1506
+ </ul>
1507
+ </Card>
1508
+ );
1509
+ }
1510
+ ````
1511
+
1512
+ ### Source: web/examples/ChartCardExamples.module.css
1513
+
1514
+ ````css
1515
+ .card {
1516
+ --chart-card-width: 384px; /* lint-hardcoded: ignore */
1517
+ --chart-card-wide: 560px; /* lint-hardcoded: ignore */
1518
+ --chart-card-plot-height: 208px; /* lint-hardcoded: ignore */
1519
+ --chart-card-round-size: 208px; /* lint-hardcoded: ignore */
1520
+ display: flex;
1521
+ flex-direction: column;
1522
+ gap: var(--space-4);
1523
+ width: 100%;
1524
+ max-width: var(--chart-card-width);
1525
+ min-width: 0;
1526
+ padding-top: var(--space-6);
1527
+ }
1528
+
1529
+ .wide {
1530
+ max-width: var(--chart-card-wide);
1531
+ --comparison-chart-height: 248px; /* lint-hardcoded: ignore */
1532
+ }
1533
+
1534
+ .header {
1535
+ display: flex;
1536
+ flex-direction: column;
1537
+ gap: var(--space-1);
1538
+ }
1539
+
1540
+ .header h3 {
1541
+ margin: 0;
1542
+ font-size: var(--text-base);
1543
+ font-weight: var(--font-weight-semibold);
1544
+ line-height: var(--lh-tight);
1545
+ }
1546
+
1547
+ .header > span,
1548
+ .center > span,
1549
+ .goalCaption {
1550
+ color: var(--fg-muted);
1551
+ font-size: var(--text-sm);
1552
+ line-height: var(--lh-base);
1553
+ }
1554
+
1555
+ .metric {
1556
+ display: flex;
1557
+ align-items: baseline;
1558
+ gap: var(--space-2);
1559
+ font-size: var(--text-3xl);
1560
+ font-weight: var(--font-weight-book);
1561
+ line-height: var(--lh-tight);
1562
+ font-variant-numeric: tabular-nums;
1563
+ }
1564
+
1565
+ .metric > span {
1566
+ font-size: var(--text-sm);
1567
+ color: var(--fg-muted);
1568
+ }
1569
+
1570
+ .cartesian {
1571
+ height: var(--chart-card-plot-height);
1572
+ aspect-ratio: auto;
1573
+ min-width: 0;
1574
+ }
1575
+
1576
+ .donutWrap {
1577
+ position: relative;
1578
+ display: grid;
1579
+ place-items: center;
1580
+ }
1581
+
1582
+ .donut,
1583
+ .radial {
1584
+ width: var(--chart-card-round-size);
1585
+ max-width: 100%;
1586
+ height: var(--chart-card-round-size);
1587
+ aspect-ratio: 1;
1588
+ align-self: center;
1589
+ }
1590
+
1591
+ .center {
1592
+ position: absolute;
1593
+ display: flex;
1594
+ flex-direction: column;
1595
+ align-items: center;
1596
+ gap: 0;
1597
+ pointer-events: none;
1598
+ }
1599
+
1600
+ .center strong {
1601
+ font-size: var(--text-3xl);
1602
+ font-weight: var(--font-weight-book);
1603
+ line-height: var(--lh-tight);
1604
+ font-variant-numeric: tabular-nums;
1605
+ }
1606
+
1607
+ .center > span {
1608
+ font-size: var(--text-xs);
1609
+ line-height: var(--lh-tight);
1610
+ }
1611
+
1612
+ .radar {
1613
+ height: auto;
1614
+ aspect-ratio: 1.3;
1615
+ }
1616
+
1617
+ .goalValue {
1618
+ fill: var(--fg);
1619
+ font-size: var(--text-4xl);
1620
+ font-weight: var(--font-weight-book);
1621
+ }
1622
+
1623
+ .percent {
1624
+ fill: var(--fg-muted);
1625
+ font-size: var(--text-base);
1626
+ }
1627
+
1628
+ .goalCaption {
1629
+ margin: 0;
1630
+ text-align: center;
1631
+ }
1632
+
1633
+ .goalCaption strong {
1634
+ color: var(--fg);
1635
+ font-weight: var(--font-weight-medium);
1636
+ }
1637
+
1638
+ /* Keep Button padding and hover area; align its content with the card heading. */
1639
+ .breakdown {
1640
+ margin-inline: calc((var(--space-3) + var(--hairline)) * -1);
1641
+ }
1642
+
1643
+ .breakdown > ul {
1644
+ width: 100%;
1645
+ max-width: none;
1646
+ }
1647
+
1648
+ @media (max-width: 360px) {
1649
+ .radar {
1650
+ aspect-ratio: 1.4;
1651
+ }
1652
+ }
1653
+ ````
1654
+
1655
+ ### Source: web/examples/ChartCardExamples.tsx
1656
+
1657
+ ````tsx
1658
+ "use client";
1659
+
1660
+ import { useId, useState, type ReactNode } from "react";
1661
+ import {
1662
+ Area, AreaChart, Bar, BarChart, CartesianGrid, Cell, Label, Pie, PieChart,
1663
+ PolarAngleAxis, PolarGrid, PolarRadiusAxis, Radar, RadarChart,
1664
+ RadialBar, RadialBarChart, XAxis,
1665
+ } from "recharts";
1666
+ import { Card } from "@/components/Card";
1667
+ import { ChartContainer, ChartTooltip, ChartTooltipContent, type ChartConfig } from "@/components/Chart";
1668
+ import { ChartItemLegend } from "@/app/_components/ChartItemLegend";
1669
+ import { TrafficComparisonExample } from "./TrafficComparisonExample";
1670
+ import styles from "./ChartCardExamples.module.css";
1671
+
1672
+ function ChartCard({ title, period, children, wide = false }: {
1673
+ title: string; period: string; children: ReactNode; wide?: boolean;
1674
+ }) {
1675
+ return <Card variant="framed" className={`${styles.card} ${wide ? styles.wide : ""}`}>
1676
+ <div className={styles.header}><h3>{title}</h3><span>{period}</span></div>
1677
+ {children}
1678
+ </Card>;
1679
+ }
1680
+
1681
+ export function TrafficCardExample() {
1682
+ return <ChartCard title="Website traffic" period="Today · 10:30 AM" wide>
1683
+ <TrafficComparisonExample />
1684
+ </ChartCard>;
1685
+ }
1686
+
1687
+ const revenue = [
1688
+ { day: "Mon", revenue: 2400 }, { day: "Tue", revenue: 3200 },
1689
+ { day: "Wed", revenue: 2800 }, { day: "Thu", revenue: 4100 },
1690
+ { day: "Fri", revenue: 3600 }, { day: "Sat", revenue: 4800 }, { day: "Sun", revenue: 4200 },
1691
+ ];
1692
+ const revenueConfig = { revenue: { label: "Revenue", color: "var(--chart-1)" } } satisfies ChartConfig;
1693
+
1694
+ export function RevenueCardExample() {
1695
+ const gradient = `revenue-${useId().replace(/:/g, "")}`;
1696
+ const total = revenue.reduce((sum, row) => sum + row.revenue, 0);
1697
+ return <ChartCard title="Weekly revenue" period="Oct 26 – Nov 1">
1698
+ <div className={styles.metric}>{total.toLocaleString("en-US", { style: "currency", currency: "USD", maximumFractionDigits: 0 })}</div>
1699
+ <ChartContainer config={revenueConfig} className={styles.cartesian} aria-label="Daily revenue for October 26 to November 1">
1700
+ <AreaChart data={revenue} accessibilityLayer margin={{ left: 12, right: 12, top: 16, bottom: 0 }}>
1701
+ <defs><linearGradient id={gradient} x1="0" y1="0" x2="0" y2="1">
1702
+ <stop offset="0%" stopColor="var(--color-revenue)" stopOpacity={0.24} />
1703
+ <stop offset="100%" stopColor="var(--color-revenue)" stopOpacity={0} />
1704
+ </linearGradient></defs>
1705
+ <CartesianGrid vertical={false} />
1706
+ <XAxis dataKey="day" tickLine={false} axisLine={false} tickMargin={10} interval="preserveStartEnd" />
1707
+ <ChartTooltip content={<ChartTooltipContent indicator="line" />} />
1708
+ <Area dataKey="revenue" type="monotone" fill={`url(#${gradient})`} stroke="var(--color-revenue)" isAnimationActive={false} />
1709
+ </AreaChart>
1710
+ </ChartContainer>
1711
+ </ChartCard>;
1712
+ }
1713
+
1714
+ const support = [
1715
+ { day: "Mon", tickets: 42 }, { day: "Tue", tickets: 58 }, { day: "Wed", tickets: 35 },
1716
+ { day: "Thu", tickets: 47 }, { day: "Fri", tickets: 64 },
1717
+ ];
1718
+ const supportConfig = { tickets: { label: "Tickets", color: "var(--chart-1)" } } satisfies ChartConfig;
1719
+
1720
+ export function SupportCardExample() {
1721
+ return <ChartCard title="Support requests" period="Oct 26–30">
1722
+ <div className={styles.metric}>{support.reduce((sum, row) => sum + row.tickets, 0)}<span>tickets</span></div>
1723
+ <ChartContainer config={supportConfig} className={styles.cartesian} aria-label="Support requests by weekday">
1724
+ <BarChart data={support} accessibilityLayer maxBarSize={32} margin={{ top: 16, right: 0, bottom: 0, left: 0 }}>
1725
+ <CartesianGrid vertical={false} />
1726
+ <XAxis dataKey="day" tickLine={false} axisLine={false} tickMargin={10} interval="preserveStartEnd" />
1727
+ <ChartTooltip cursor={false} content={<ChartTooltipContent />} />
1728
+ <Bar dataKey="tickets" fill="var(--color-tickets)" radius={[6, 6, 0, 0]} isAnimationActive={false} />
1729
+ </BarChart>
1730
+ </ChartContainer>
1731
+ </ChartCard>;
1732
+ }
1733
+
1734
+ const acquisition = [
1735
+ { id: "organic", label: "Organic search", value: 1820, color: "var(--chart-1)" },
1736
+ { id: "direct", label: "Direct", value: 1140, color: "var(--chart-2)" },
1737
+ { id: "referral", label: "Referral", value: 680, color: "var(--chart-3)" },
1738
+ { id: "social", label: "Social", value: 360, color: "var(--chart-4)" },
1739
+ ];
1740
+ const acquisitionConfig = Object.fromEntries(acquisition.map(row => [row.id, { label: row.label, color: row.color }])) satisfies ChartConfig;
1741
+
1742
+ export function AcquisitionCardExample() {
1743
+ const [selected, setSelected] = useState<string | null>(null);
1744
+ const current = acquisition.find(row => row.id === selected);
1745
+ const value = current?.value ?? acquisition.reduce((sum, row) => sum + row.value, 0);
1746
+ return <ChartCard title="Acquisition sources" period="October 2026">
1747
+ <div className={styles.donutWrap}>
1748
+ <ChartContainer config={acquisitionConfig} className={styles.donut} aria-label="October visitors by acquisition source">
1749
+ <PieChart accessibilityLayer>
1750
+ <ChartTooltip content={<ChartTooltipContent nameKey="id" hideLabel />} />
1751
+ <Pie data={acquisition} dataKey="value" nameKey="id" innerRadius="72%" outerRadius="92%" paddingAngle={3} stroke="var(--bg)" isAnimationActive={false}>
1752
+ {acquisition.map(row => <Cell key={row.id} fill={`var(--color-${row.id})`} opacity={selected && selected !== row.id ? 0.18 : 1} />)}
1753
+ </Pie>
1754
+ </PieChart>
1755
+ </ChartContainer>
1756
+ <div className={styles.center} aria-live="polite"><strong>{value.toLocaleString("en-US")}</strong><span>{current?.label ?? "Visitors"}</span></div>
1757
+ </div>
1758
+ <div className={styles.breakdown}><ChartItemLegend items={acquisition} selected={selected} onSelect={key => setSelected(value => value === key ? null : key)} /></div>
1759
+ </ChartCard>;
1760
+ }
1761
+
1762
+ const quality = [
1763
+ { axis: "Speed", current: 86, previous: 62 }, { axis: "Reliability", current: 92, previous: 78 },
1764
+ { axis: "Ease of use", current: 78, previous: 65 }, { axis: "Features", current: 84, previous: 72 },
1765
+ { axis: "Support", current: 90, previous: 80 },
1766
+ ];
1767
+ const qualityConfig = {
1768
+ current: { label: "Current release", color: "var(--chart-1)" },
1769
+ previous: { label: "Previous release", color: "var(--chart-3)" },
1770
+ } satisfies ChartConfig;
1771
+
1772
+ export function QualityCardExample() {
1773
+ const [selected, setSelected] = useState<string | null>(null);
1774
+ return <ChartCard title="Product quality" period="Score out of 100">
1775
+ <ChartContainer config={qualityConfig} className={styles.radar} aria-label="Current and previous release quality scores out of 100">
1776
+ <RadarChart data={quality} accessibilityLayer outerRadius="60%">
1777
+ <PolarGrid radialLines={false} />
1778
+ <PolarAngleAxis dataKey="axis" tickLine={false} tickSize={4} />
1779
+ <PolarRadiusAxis domain={[0, 100]} tick={false} axisLine={false} />
1780
+ <ChartTooltip content={<ChartTooltipContent />} />
1781
+ <Radar dataKey="previous" hide={selected === "current"} stroke="var(--color-previous)" fill="var(--color-previous)" fillOpacity={0.08} isAnimationActive={false} />
1782
+ <Radar dataKey="current" hide={selected === "previous"} stroke="var(--color-current)" fill="var(--color-current)" fillOpacity={0.16} isAnimationActive={false} />
1783
+ </RadarChart>
1784
+ </ChartContainer>
1785
+ <ChartItemLegend compact items={Object.entries(qualityConfig).map(([id, row]) => ({ id, label: row.label, color: row.color, value: 0 }))}
1786
+ selected={selected} onSelect={key => setSelected(value => value === key ? null : key)} />
1787
+ </ChartCard>;
1788
+ }
1789
+
1790
+ const goal = { completed: 72, target: 100 };
1791
+ const goalConfig = { completed: { label: "Completed", color: "var(--chart-1)" } } satisfies ChartConfig;
1792
+
1793
+ export function GoalCardExample() {
1794
+ const percentage = Math.round(goal.completed / goal.target * 100);
1795
+ return <ChartCard title="Monthly goal" period="November 2026">
1796
+ <ChartContainer config={goalConfig} className={styles.radial} aria-label={`${goal.completed} of ${goal.target} reports completed, ${percentage}%`}>
1797
+ <RadialBarChart data={[goal]} accessibilityLayer startAngle={90} endAngle={-270} innerRadius="78%" outerRadius="100%" barSize={14}>
1798
+ <PolarAngleAxis type="number" domain={[0, goal.target]} tick={false} />
1799
+ <RadialBar dataKey="completed" fill="var(--color-completed)" background={{ fill: "var(--bg-muted)" }} cornerRadius={8} isAnimationActive={false} />
1800
+ <PolarRadiusAxis tick={false} tickLine={false} axisLine={false}>
1801
+ <Label position="center" content={({ x, y }) => {
1802
+ if (x == null || y == null) return null;
1803
+ return <text x={x} y={y} textAnchor="middle" dominantBaseline="central" className={styles.goalValue}>{percentage}<tspan className={styles.percent}>%</tspan></text>;
1804
+ }} />
1805
+ </PolarRadiusAxis>
1806
+ </RadialBarChart>
1807
+ </ChartContainer>
1808
+ <p className={styles.goalCaption}><strong>{goal.completed}</strong> of {goal.target} reports completed</p>
1809
+ </ChartCard>;
1810
+ }
1811
+ ````
1812
+
1813
+ ### Source: web/examples/TrafficComparisonExample.module.css
1814
+
1815
+ ````css
1816
+ .chart {
1817
+ width: 100%;
1818
+ min-width: 0;
1819
+ height: var(--comparison-chart-height, 320px); /* lint-hardcoded: ignore */
1820
+ aspect-ratio: auto;
1821
+ }
1822
+
1823
+ .currentLine,
1824
+ .previousLine {
1825
+ display: inline-block;
1826
+ width: var(--space-3);
1827
+ height: 0;
1828
+ flex-shrink: 0;
1829
+ border-top: 2px solid var(--color-today); /* lint-hardcoded: ignore */
1830
+ }
1831
+
1832
+ .previousLine {
1833
+ border-top-style: dotted;
1834
+ border-top-color: var(--color-yesterday);
1835
+ }
1836
+ ````
1837
+
1838
+ ### Source: web/examples/TrafficComparisonExample.tsx
1839
+
1840
+ ````tsx
1841
+ "use client";
1842
+
1843
+ import { CartesianGrid, Line, LineChart, XAxis, YAxis } from "recharts";
1844
+ import { ChartContainer, ChartLegend, ChartLegendContent, ChartTooltip, ChartTooltipContent, type ChartConfig } from "@/components/Chart";
1845
+ import styles from "./TrafficComparisonExample.module.css";
1846
+
1847
+ const today = [0, 0, 1720, 2100, 2280, 1950, 2800, 2200, 2480, 2890, 3300, 3250, 3905];
1848
+ const yesterday = [0, 430, 260, 450, 510, 780, 520, 760, 470, 790, 1260, 1430, 2545];
1849
+ const minutes = [0, 30, 60, 120, 180, 240, 300, 360, 420, 480, 540, 600, 630];
1850
+ const data = today.map((value, index) => ({ minute: minutes[index], today: value as number | null, yesterday: yesterday[index] as number | null }));
1851
+ data.push({ minute: 1439, today: null, yesterday: null });
1852
+
1853
+ function CurrentLine() { return <span className={styles.currentLine} />; }
1854
+ function PreviousLine() { return <span className={styles.previousLine} />; }
1855
+ const config = {
1856
+ today: { label: "Today", color: "var(--chart-1)", icon: CurrentLine },
1857
+ yesterday: { label: "Yesterday", color: "var(--fg-muted)", icon: PreviousLine },
1858
+ } satisfies ChartConfig;
1859
+
1860
+ function formatTime(value: number) {
1861
+ const hour = Math.floor(value / 60);
1862
+ const minute = Math.floor(value % 60);
1863
+ return `${hour % 12 || 12}:${String(minute).padStart(2, "0")}${hour < 12 ? "AM" : "PM"}`;
1864
+ }
1865
+
1866
+ export function TrafficComparisonExample() {
1867
+ return <ChartContainer config={config} className={styles.chart} role="group"
1868
+ aria-label="Website visitors by time. At 10:30AM, today has 3,905 visitors and yesterday had 2,545.">
1869
+ <LineChart data={data} accessibilityLayer margin={{ top: 12, right: 16, bottom: 8, left: 0 }}>
1870
+ <CartesianGrid vertical={false} strokeOpacity={0.45} />
1871
+ <XAxis dataKey="minute" type="number" domain={[0, 1439]} ticks={[0, 720, 1439]}
1872
+ tickFormatter={formatTime} tickLine={false} axisLine={false} tickMargin={12} minTickGap={32} />
1873
+ <YAxis domain={[0, 5000]} ticks={[0, 1000, 2000, 3000, 4000, 5000]} interval={0} width={40}
1874
+ tickFormatter={(value: number) => value === 0 ? "0" : `${value / 1000}K`}
1875
+ tickLine={false} axisLine={false} tickMargin={8} />
1876
+ <ChartTooltip cursor={{ stroke: "var(--fg-muted)", strokeWidth: 1 }}
1877
+ content={<ChartTooltipContent indicator="line" labelFormatter={(value) => `Today at ${formatTime(Number(value))}`} />} />
1878
+ <ChartLegend align="left" content={<ChartLegendContent />} />
1879
+ <Line dataKey="today" type="monotone" stroke="var(--color-today)" strokeWidth={1.75}
1880
+ dot={false} activeDot={{ r: 4, fill: "var(--bg)", stroke: "var(--color-today)", strokeWidth: 1.75 }} isAnimationActive={false} />
1881
+ <Line dataKey="yesterday" type="linear" stroke="var(--color-yesterday)" strokeWidth={1.5}
1882
+ strokeDasharray="2 4" strokeLinecap="round" dot={false} activeDot={false} isAnimationActive={false} />
1883
+ </LineChart>
1884
+ </ChartContainer>;
1885
+ }
1886
+ ````