import type { CellRange } from '../../types/grid.types'; import type { ChartPanelType } from '../chart-panel'; /** * How multiple grid rows sharing a category value are collapsed into a single * chart data point. * * - `sum` / `avg` / `count` / `min` / `max` — standard reductions. * - `none` — no aggregation: every selected data row becomes its own category * (matches AG Grid's "Aggregate" toggle in the off position). */ export type ChartAggregation = 'sum' | 'avg' | 'count' | 'min' | 'max' | 'none'; /** Placement of the series legend relative to the plot area. */ export type LegendPosition = 'top' | 'bottom' | 'left' | 'right'; /** Horizontal text alignment used by titles and subtitles. */ export type TextAlign = 'left' | 'center' | 'right'; /** * Title / subtitle configuration. All fields are optional; an empty or absent * {@link TitleOptions.text} suppresses the band entirely and reclaims its space. */ export interface TitleOptions { readonly text?: string; readonly color?: string; readonly fontSize?: number; readonly align?: TextAlign; } /** Legend visibility and placement. */ export interface LegendOptions { readonly enabled: boolean; readonly position: LegendPosition; } /** Per-axis presentation. Colors are optional so they can fall back to theme tokens. */ export interface AxisOptions { readonly title?: string; readonly titleColor?: string; readonly labelColor?: string; readonly lineColor?: string; readonly showGridLines?: boolean; readonly showTicks?: boolean; readonly showLabels?: boolean; } /** * Series styling. {@link SeriesStyle.colorByKey} maps a series' column id (or * label) to an explicit color override; unmapped series fall back to the theme * palette. Stroke / fill apply to line and area series. */ export interface SeriesStyle { readonly colorByKey: Readonly>; readonly strokeWidth?: number; readonly fillOpacity?: number; } /** Chart-wide presentation not tied to a specific axis or series. */ export interface ChartStyleOptions { readonly backgroundColor?: string; readonly fontFamily?: string; readonly fontSize?: number; } /** * The complete, serializable definition of a range chart. This is the single * source of truth a {@link RangeChartController} renders from — it can be read * via `api.getChartModels()` and re-applied via `api.restoreChart(model)`. * * The model is treated as immutable: mutations go through {@link applyModelChange}, * which returns a new frozen instance rather than editing in place. */ export interface ChartModel { /** Stable identifier, unique within a grid. */ readonly chartId: string; /** Concrete chart type drawn by the renderer. */ readonly chartType: ChartPanelType; /** The grid cell range the chart was created from. */ readonly cellRange: CellRange; /** * Column ids that form the chart's candidate pool — the union of every source * cell range's columns, in visible order. Drives which columns the Set Up tab * offers for the category and series roles, so non-contiguous multi-range * selections are represented faithfully (not just the bounding {@link cellRange}). */ readonly chartColIds: readonly string[]; /** Column id whose values form the category (x) axis. */ readonly categoryColId: string; /** Column ids plotted as series (one dataset each). */ readonly seriesColIds: readonly string[]; /** Aggregation applied when rows share a category value. */ readonly aggregation: ChartAggregation; /** When `true`, categories and series are transposed. */ readonly switchCategorySeries: boolean; /** * When `true` the chart is detached from the grid: it no longer re-renders on * data / sort / filter changes and keeps its last-built snapshot. */ readonly unlinked: boolean; readonly title: TitleOptions; readonly subtitle: TitleOptions; readonly legend: LegendOptions; readonly xAxis: AxisOptions; readonly yAxis: AxisOptions; readonly series: SeriesStyle; readonly style: ChartStyleOptions; } /** The subset of {@link ChartModel} a caller must supply to build a default. */ export interface ChartModelSeed { readonly chartId: string; readonly chartType: ChartPanelType; readonly cellRange: CellRange; readonly categoryColId: string; readonly seriesColIds: readonly string[]; /** Candidate column pool. Defaults to the category plus every series column. */ readonly chartColIds?: readonly string[]; readonly aggregation?: ChartAggregation; readonly title?: string; } /** * Builds a fully-populated {@link ChartModel} from the minimal information * available at creation time, filling every optional section with sensible * defaults. The returned model is deep-frozen. * * @param seed - Identity, type, range and column roles for the new chart. * @returns A frozen, ready-to-render chart model. */ export declare function createDefaultChartModel(seed: ChartModelSeed): ChartModel; /** * Produces a new {@link ChartModel} with `patch` applied over `model`. Nested * object sections (title, legend, axes, series, style) are shallow-merged so a * caller can patch a single field without restating the whole section. The * result is deep-frozen; the input is never mutated. * * @param model - The current model. * @param patch - Partial fields to overlay. Nested sections merge; scalars replace. * @returns A new frozen model. */ export declare function applyModelChange(model: ChartModel, patch: ChartModelPatch): ChartModel; /** * A partial chart model used by {@link applyModelChange}. Every top-level field * and nested section is optional and independently patchable. */ export interface ChartModelPatch { readonly chartType?: ChartPanelType; readonly cellRange?: CellRange; readonly chartColIds?: readonly string[]; readonly categoryColId?: string; readonly seriesColIds?: readonly string[]; readonly aggregation?: ChartAggregation; readonly switchCategorySeries?: boolean; readonly unlinked?: boolean; readonly title?: Partial; readonly subtitle?: Partial; readonly legend?: Partial; readonly xAxis?: Partial; readonly yAxis?: Partial; readonly series?: Partial; readonly style?: Partial; } //# sourceMappingURL=chart-model.d.ts.map