"use client" import * as React from "react" import { Bar, BarChart, CartesianGrid, XAxis } from "recharts" import { Button } from "@/registry/bases/radix/ui/button" import { Card, CardContent, CardDescription, CardFooter, CardHeader, CardTitle, } from "@/registry/bases/radix/ui/card" import { ChartContainer, ChartLegend, ChartLegendContent, ChartTooltip, ChartTooltipContent, type ChartConfig, } from "@/registry/bases/radix/ui/chart" import { useDesignSystemSearchParams } from "@/app/(app)/create/lib/search-params" const barChartData = [ { month: "January", desktop: 186, mobile: 80 }, { month: "February", desktop: 305, mobile: 200 }, { month: "March", desktop: 237, mobile: 120 }, { month: "April", desktop: 73, mobile: 190 }, { month: "May", desktop: 209, mobile: 130 }, { month: "June", desktop: 214, mobile: 140 }, ] const barChartConfig = { desktop: { label: "Desktop", color: "var(--chart-1)", }, mobile: { label: "Mobile", color: "var(--chart-2)", }, } satisfies ChartConfig const desktopTotal = barChartData.reduce((sum, item) => sum + item.desktop, 0) const mobileTotal = barChartData.reduce((sum, item) => sum + item.mobile, 0) const desktopDelta = Math.round( ((desktopTotal - mobileTotal) / mobileTotal) * 100 ) const desktopDeltaPrefix = desktopDelta > 0 ? "+" : "" export function BarChartCard() { const [params] = useDesignSystemSearchParams() const isRounded = !["lyra", "sera"].includes(params.style) return ( Traffic channels Monthly desktop and mobile traffic for the last six months—compare volume and mix across platforms and devices at a glance. String(value).slice(0, 3)} /> } /> } />
Desktop
{desktopTotal.toLocaleString()}
Mobile
{mobileTotal.toLocaleString()}
Mix Delta
{desktopDeltaPrefix} {desktopDelta}%
) }