"use client"; import { Bar, BarChart, CartesianGrid, LabelList, ReferenceLine, XAxis, YAxis } from "recharts"; import Image from "@/components/ui/resilient-image"; import { Badge } from "@/components/ui/badge"; import { Card, CardContent, CardDescription, CardHeader, CardTitle } from "@/components/ui/card"; import { ChartContainer, ChartLegend, ChartLegendContent, ChartTooltip, ChartTooltipContent, type ChartConfig, } from "@/components/ui/chart"; import type { PublicGuide } from "@/lib/guides/queries"; const chartConfig = { overall: { label: "ดาเมจทั้งทีม", color: "var(--chart-1)" }, personal: { label: "ดาเมจส่วนตัว", color: "var(--chart-2)" }, } satisfies ChartConfig; function percentage(value: string | null) { if (!value?.trim()) return null; const number = Number(value); return Number.isFinite(number) && number !== 0 ? number : null; } export function WeaponChart({ rows }: { rows: PublicGuide["weaponGroups"][number]["rows"] }) { const data = rows.map((row, index) => ({ name: `${index + 1}. ${row.weapon.name} R${row.refinement}`, weapon: row.weapon, refinement: row.refinement, overall: percentage(row.overallPercent), personal: percentage(row.personalPercent), })); const hasOverall = data.some((row) => row.overall !== null); const hasPersonal = data.some((row) => row.personal !== null); const singleMetric = !hasOverall || !hasPersonal; if (!hasOverall && !hasPersonal) return
ไม่มีข้อมูลเปรียบเทียบสำหรับกราฟนี้
; return