import { useState, type ReactNode } from "react"
import { cn } from "cn"
import {
Badge,
Card,
CardAction,
CardContent,
CardDescription,
CardHeader,
CardTitle,
Select,
SelectContent,
SelectItem,
SelectTrigger,
SelectValue,
} from "@hm-design/ui"
import { HMBarChart, HMDonutChart, HMHorizontalBarChart, HMLineChart, HMSignedBarChart, HMSolidDonutChart } from "../index"
import { sampleBar, sampleDataNotice, sampleDonut, sampleDonutStates, sampleHorizontalBar, sampleLine, sampleLineCompare, sampleLinePointColors, sampleSignedBar } from "./sample-data"
/** Marks a chart as sample data. Use it next to every chart that is fed with `sample-data`. */
export function SampleDataBadge() {
return 예시 데이터
}
export function ExampleCard({ title, description, className, toolbar, children }: { title: string; description?: string; className?: string; toolbar?: ReactNode; children: ReactNode }) {
return (
// h-full lets a card fill its grid cell; the notice sits at the card bottom so cards of one row line up.
{title}
{description ? {description} : null}
{toolbar !== undefined ? {toolbar}
: null}
{children}
{sampleDataNotice}
)
}
export function BarChartExample({ className }: { className?: string }) {
return (
)
}
export function StackedBarChartExample({ className }: { className?: string }) {
return (
)
}
export function HorizontalBarChartExample({ className }: { className?: string }) {
return (
)
}
export function SignedBarChartExample({ className }: { className?: string }) {
return (
)
}
export function LineChartExample({ className }: { className?: string }) {
return (
)
}
export function LineCurveExample({ className }: { className?: string }) {
return (
)
}
export function LineCurveDotLabelExample({ className }: { className?: string }) {
return (
)
}
export function LineStraightExample({ className }: { className?: string }) {
return (
)
}
export function LineStraightColorLabelExample({ className }: { className?: string }) {
return (
)
}
export function LineStepExample({ className }: { className?: string }) {
return (
)
}
export function LineStepDotLabelExample({ className }: { className?: string }) {
return (
)
}
export function DonutChartExample({ className }: { className?: string }) {
return (
)
}
/** Bar, line and donut examples: two per row from 1024px (HM desktop boundary), one per row below. With an odd count the last card keeps one column's width. */
export function ChartExamples() {
return (
)
}
// Four donut states on one data set: plain, center total, active (fixed selection) and interactive (Select + slice click).
// The toolbar row has the Select height in every card, so the donuts of a row start at the same height.
export function DonutPlainExample({ className }: { className?: string }) {
return (
)
}
export function DonutCenterExample({ className }: { className?: string }) {
return (
)
}
export function DonutSolidExample({ className }: { className?: string }) {
return (
)
}
export function DonutActiveExample({ className }: { className?: string }) {
const selected = sampleDonutStates.data.find(item => item.id === sampleDonutStates.activeId)
return (
)
}
export function DonutInteractiveExample({ className }: { className?: string }) {
const [activeId, setActiveId] = useState(sampleDonutStates.activeId)
return (
{sampleDonutStates.data.map(item => (
{item.label}
))}
}
>
)
}