{"version":3,"file":"types.cjs","names":[],"sources":["../../src/charts/types.ts"],"sourcesContent":["/**\n * @tempest-limits props-count — these are the recharts wrapper's surface, and each\n * prop maps to one recharts element the wrapper renders: data/index/categories to\n * the series, colors to Cell, showLegend/showGrid/showTooltip to\n * Legend/CartesianGrid/Tooltip, valueFormatter to the tick and tooltip formatters.\n * Cutting the list means the caller drops to raw recharts for whatever was cut,\n * which is the thing the wrapper exists to avoid.\n */\n/**\n * Tabular data consumed by every chart: an array of rows, where each row maps a\n * column key to a string (label) or number (value).\n */\nexport type ChartData = Array<Record<string, string | number>>;\n\nimport type {\n    Formatter,\n    NameType,\n    ValueType,\n} from \"recharts/types/component/DefaultTooltipContent\";\n\n/**\n * Recharts tooltip formatters receive a loosely-typed value. This adapts a\n * friendly `(value: number) => string` formatter into a recharts `Formatter`,\n * coercing the incoming value to a number first.\n *\n * @param valueFormatter - The user-supplied numeric formatter, if any.\n * @returns A recharts-compatible formatter, or undefined when none was given.\n */\nexport function toTooltipFormatter(\n    valueFormatter?: (value: number) => string,\n): Formatter<ValueType, NameType> | undefined {\n    if (!valueFormatter) return undefined;\n    return (value: ValueType | undefined): string => valueFormatter(Number(value));\n}\n\n/**\n * Shared props for the cartesian chart family (Area, Bar, Line) and Radar.\n *\n * Each chart plots one series per entry in `categories`, reading values from the\n * matching key on every row, and uses `index` for the category axis.\n */\nexport interface CartesianChartProps {\n    /** Rows of data to plot. */\n    data: ChartData;\n    /** Row key used for the x-axis (cartesian) or angle axis (radar). */\n    index: string;\n    /** Row keys to plot, one series each. */\n    categories: string[];\n    /** Series colors, cycled per category. Defaults to {@link DEFAULT_CHART_COLORS}. */\n    colors?: string[];\n    /** Chart height in pixels. Defaults to 300. */\n    height?: number;\n    /**\n     * Fixed chart width in pixels. When set, the chart renders at this explicit\n     * width WITHOUT a ResponsiveContainer (useful for tests/SSR). When omitted,\n     * the chart fills its parent via a ResponsiveContainer.\n     */\n    width?: number;\n    /** Stack all series on a shared stackId instead of grouping them. */\n    stack?: boolean;\n    /** Render the legend. Defaults to true. */\n    showLegend?: boolean;\n    /** Render the cartesian grid. Defaults to true. */\n    showGrid?: boolean;\n    /** Render the tooltip. Defaults to true. */\n    showTooltip?: boolean;\n    /** Format numeric values for tooltip/axis display. */\n    valueFormatter?: (value: number) => string;\n    /** Extra class name applied to the chart wrapper. */\n    className?: string;\n}\n\n/**\n * Props for the {@link PieChart} component.\n */\nexport interface PieChartProps {\n    /** Rows of data to plot, one slice each. */\n    data: ChartData;\n    /** Row key holding the numeric slice value. */\n    category: string;\n    /** Row key holding the slice name/label. */\n    index: string;\n    /** Slice colors, cycled per slice. Defaults to {@link DEFAULT_CHART_COLORS}. */\n    colors?: string[];\n    /** Chart height in pixels. Defaults to 300. */\n    height?: number;\n    /**\n     * Fixed chart width in pixels. When set, the chart renders at this explicit\n     * width WITHOUT a ResponsiveContainer (useful for tests/SSR).\n     */\n    width?: number;\n    /** Render as a donut (non-zero inner radius) instead of a full pie. */\n    donut?: boolean;\n    /** Render the legend. Defaults to true. */\n    showLegend?: boolean;\n    /** Render the tooltip. Defaults to true. */\n    showTooltip?: boolean;\n    /** Format numeric values for tooltip display. */\n    valueFormatter?: (value: number) => string;\n    /** Extra class name applied to the chart wrapper. */\n    className?: string;\n}\n"],"mappings":"AA4BA,SAAgB,EACZ,EAC0C,CACrC,KACL,MAAQ,IAAyC,EAAe,OAAO,CAAK,CAAC,CACjF"}