"use client"; import { cn } from "@/lib/utils"; import { useVolumeProfileModel, VolumeProfileContext, type VolumeProfileProps, } from "./volume-profile/context"; import { VolumeProfilePlot } from "./volume-profile/plot"; import { VolumeProfileSummary } from "./volume-profile/summary"; import { VolumeProfileTooltip } from "./volume-profile/tooltip"; /** Compose Plot, Tooltip and Summary, or omit children for the complete chart. */ export function VolumeProfile({ data, label, unit, formatPrice, formatVolume, valueArea, color, pocColor, activeId, defaultActiveId, onActiveChange, labels, className, children, ...props }: VolumeProfileProps) { const model = useVolumeProfileModel({ data, label, unit, formatPrice, formatVolume, valueArea, color, pocColor, activeId, defaultActiveId, onActiveChange, labels, }); return (
{children === undefined ? ( <> ) : ( children )}
{model.rows.map((row) => ( ))}
{model.t("caption", { label: model.label })}
{model.t("priceRange")} {model.t("volume", { unit: model.unit })} {model.t("share")} {model.t("level")}
{model.t("range", { low: model.formatPrice(row.priceLow), high: model.formatPrice(row.priceHigh), })} {model.formatVolume(row.volume)} {(row.share * 100).toFixed(1)}% {row.isPoc ? model.t("poc") : row.inValueArea ? model.t("inside") : model.valueArea ? model.t("outside") : "—"}
); } export type { VolumeProfileProps } from "./volume-profile/context"; export { useVolumeProfile } from "./volume-profile/context"; export { type VolumeProfileMessages, volumeProfileMessages } from "./volume-profile/messages"; export type { VolumeProfileBin, VolumeProfileRow } from "./volume-profile/model"; export type { VolumeProfilePlotProps } from "./volume-profile/plot"; export { VolumeProfilePlot } from "./volume-profile/plot"; export { VolumeProfileSummary } from "./volume-profile/summary"; export type { VolumeProfileTooltipProps } from "./volume-profile/tooltip"; export { VolumeProfileTooltip } from "./volume-profile/tooltip";