|
| 1 | +import type { Meta, StoryObj } from "@storybook/react"; |
| 2 | +import DonutChart from "./donutchart"; |
| 3 | + |
| 4 | +const meta = { |
| 5 | + title: "Components/DonutChart", |
| 6 | + component: DonutChart, |
| 7 | + parameters: { |
| 8 | + layout: "centered", |
| 9 | + docs: { |
| 10 | + description: { |
| 11 | + component: |
| 12 | + "The `DonutChart` component displays data in a donut-style chart with customizable colors, labels, and tooltip. Useful for visualizing proportions or percentages.", |
| 13 | + }, |
| 14 | + }, |
| 15 | + }, |
| 16 | + argTypes: { |
| 17 | + data: { |
| 18 | + description: |
| 19 | + "The data for the chart, where each item includes `label`, `value`, and optional `displayvalue`.", |
| 20 | + control: { type: "object" }, |
| 21 | + }, |
| 22 | + config: { |
| 23 | + description: "config for the chart", |
| 24 | + control: { type: "object" }, |
| 25 | + }, |
| 26 | + innerLabel: { |
| 27 | + description: "The label displayed inside the donut chart (e.g., percentages).", |
| 28 | + control: { type: "text" }, |
| 29 | + }, |
| 30 | + }, |
| 31 | + decorators: [ |
| 32 | + (Story) => ( |
| 33 | + <div |
| 34 | + style={{ |
| 35 | + width: "200px", |
| 36 | + height: "200px", |
| 37 | + display: "flex", |
| 38 | + justifyContent: "center", |
| 39 | + alignItems: "center", |
| 40 | + border: "1px solid #ddd", |
| 41 | + }} |
| 42 | + > |
| 43 | + <Story /> |
| 44 | + </div> |
| 45 | + ), |
| 46 | + ], |
| 47 | +} satisfies Meta<typeof DonutChart>; |
| 48 | + |
| 49 | +export default meta; |
| 50 | +type Story = StoryObj<typeof DonutChart>; |
| 51 | + |
| 52 | +export const Default: Story = { |
| 53 | + args: { |
| 54 | + config: { |
| 55 | + chrome: { label: "Chrome", color: "#8884d8" }, |
| 56 | + safari: { label: "Safari", color: "#82ca9d" }, |
| 57 | + firefox: { label: "Firefox", color: "#ffc658" }, |
| 58 | + edge: { label: "Edge", color: "#ff8042" }, |
| 59 | + other: { label: "Other", color: "#8dd1e1" }, |
| 60 | + }, |
| 61 | + data: [ |
| 62 | + { label: "chrome", value: 275, fill: "#8884d8" }, // Purple |
| 63 | + { label: "safari", value: 200, fill: "#82ca9d" }, // Green |
| 64 | + { label: "firefox", value: 287, fill: "#ffc658" }, // Yellow |
| 65 | + { label: "edge", value: 173, fill: "#ff8042" }, // Orange |
| 66 | + { label: "other", value: 190, fill: "#8dd1e1" }, // Light Blue |
| 67 | + ], |
| 68 | + innerLabel: "50%", |
| 69 | + innerSubLabel: "50/100", |
| 70 | + dataKey: "value", |
| 71 | + nameKey: "label", |
| 72 | + }, |
| 73 | +}; |
0 commit comments