"use client"; import { cn } from "@/lib/utils"; import { TreemapContext, useTreemapModel, type TreemapProps } from "./treemap/context"; import { TreemapLegend } from "./treemap/legend"; import { TreemapPlot } from "./treemap/plot"; import { TreemapTooltip } from "./treemap/tooltip"; /** Compose Plot, Tooltip and Legend, or omit children for the complete chart. */ export function Treemap({ data, label, formatValue, colors, textColor, activeId, defaultActiveId, onActiveChange, className, children, ...props }: TreemapProps) { const model = useTreemapModel({ data, label, formatValue, colors, textColor, activeId, defaultActiveId, onActiveChange, }); return (
{children === undefined ? ( <> ) : ( children )}
{model.items.map((item) => ( ))}
{model.label} data
Item Value Share of total Details
{item.path.join(" / ")} {model.formatValue(item.value)} {(item.share * 100).toFixed(1)}% {item.description ?? ""}
); } export { useTreemap } from "./treemap/context"; export type { TreemapProps } from "./treemap/context"; export type { TreemapNode, TreemapLeaf, TreemapGroup, TreemapItem, TreemapTile, } from "./treemap/model"; export { TreemapPlot } from "./treemap/plot"; export type { TreemapPlotProps } from "./treemap/plot"; export { TreemapTooltip } from "./treemap/tooltip"; export type { TreemapTooltipProps } from "./treemap/tooltip"; export { TreemapLegend } from "./treemap/legend"; export type { TreemapLegendProps } from "./treemap/legend";