"use client" import * as React from "react" import { Label, Pie, PieChart, Sector } from "recharts" import type { PieSectorDataItem } from "recharts/types/polar/Pie" import { Card, CardContent, CardDescription, CardHeader, CardTitle } from "@/components/ui/card" import { ChartContainer, ChartStyle, ChartTooltip, ChartTooltipContent } from "@/components/ui/chart" import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from "@/components/ui/select" import { Button } from "@/components/ui/button" const revenueData = [ { category: "subscriptions", value: 45, amount: 24500, fill: "var(--color-subscriptions)" }, { category: "sales", value: 30, amount: 16300, fill: "var(--color-sales)" }, { category: "services", value: 15, amount: 8150, fill: "var(--color-services)" }, { category: "partnerships", value: 10, amount: 5430, fill: "var(--color-partnerships)" }, ] const chartConfig = { revenue: { label: "Revenue", }, amount: { label: "Amount", }, subscriptions: { label: "Subscriptions", color: "var(--chart-1)", }, sales: { label: "One-time Sales", color: "var(--chart-2)", }, services: { label: "Services", color: "var(--chart-3)", }, partnerships: { label: "Partnerships", color: "var(--chart-4)", }, } export function RevenueBreakdown() { const id = "revenue-breakdown" const [activeCategory, setActiveCategory] = React.useState("sales") const activeIndex = React.useMemo( () => revenueData.findIndex((item) => item.category === activeCategory), [activeCategory] ) const categories = React.useMemo(() => revenueData.map((item) => item.category), []) return (
Revenue Breakdown Revenue distribution by source
} /> ( )} >
{revenueData.map((item, index) => { const config = chartConfig[item.category as keyof typeof chartConfig] const isActive = index === activeIndex return (
setActiveCategory(item.category)} >
{config?.label}
${(item.amount / 1000).toFixed(1)}K
{item.value}%
) })}
) }