| 1 | "use client" |
| 2 | |
| 3 | import { useChartPart } from "./chart-context" |
| 4 | |
| 5 | export function XAxis({ |
| 6 | dataKey, |
| 7 | tickFormatter, |
| 8 | tickMargin = 8, |
| 9 | maxTicks = 8, |
| 10 | }: { |
| 11 | dataKey?: string |
| 12 | tickFormatter?: ( |
| 13 | tickMargin?: number |
| 14 | maxTicks?: number |
| 15 | }) { |
| 16 | const ctx = |
| 17 | if (!ctx.ready |
| 18 | |
| 19 | const step = |
| 20 | const y = |
| 21 | |
| 22 | return ( |
| 23 | <g className="fill-current font-mono text-[10px] text-muted-foreground |
| 24 | {ctx.data.map |
| 25 | if (i % step |
| 26 | const raw = |
| 27 | const label = |
| 28 | return ( |
| 29 | <text |
| 30 | // biome-ignore lint/suspicious/noArrayIndexKey: index is the stable x position |
| 31 | key={i} |
| 32 | x={ctx.xCenter |
| 33 | y={y} |
| 34 | textAnchor="middle" |
| 35 | dominantBaseline="hanging" |
| 36 | fill="currentColor" |
| 37 | > |
| 38 | {label} |
| 39 | </text> |
| 40 | ) |
| 41 | })} |
| 42 | </g> |
| 43 | ) |
| 44 | } |