/** * @file chart.reducer.ts * @description * Core chart state management using the Composable Architecture pattern. * This reducer handles all chart state transitions including data updates, * selections, zoom/pan, and dimension changes. */ import type { Reducer } from '@composable-svelte/core'; import type { ChartState, ChartAction } from '../types/chart.types'; /** * @function chartReducer * @description * Pure reducer function that manages all chart state transitions. * Follows the (state, action, deps) => [newState, effect] pattern. * * **Supported Actions:** * - `setData` - Replace entire dataset * - `filterData` - Filter data by predicate * - `clearFilters` - Reset to original dataset * - `selectPoint` - Select single data point * - `selectRange` - Select range of indices * - `brushStart/Move/End` - Brush selection workflow * - `clearSelection` - Clear all selections * - `zoom` - Update zoom transform * - `zoomAnimated` - Initiate animated zoom * - `zoomProgress` - Update transform during animation * - `zoomComplete` - Complete animation * - `resetZoom` - Reset to identity transform * - `resize` - Update chart dimensions * - `updateSpec` - Update Observable Plot specification * * @example * ```typescript * import { createStore } from '@composable-svelte/core'; * import { chartReducer, createInitialChartState } from '@composable-svelte/charts'; * * const store = createStore({ * initialState: createInitialChartState({ data: myData }), * reducer: chartReducer, * dependencies: {} * }); * * // Dispatch actions * store.dispatch({ type: 'filterData', predicate: d => d.value > 100 }); * store.dispatch({ type: 'zoom', transform: { x: 0, y: 0, k: 2 } }); * ``` * * @param {ChartState} state - Current chart state * @param {ChartAction} action - Action to process * @param {{}} _deps - Dependencies (unused) * @returns {[ChartState, Effect]} Tuple of new state and effect * * @see {@link ChartState} for state structure * @see {@link ChartAction} for action types * @see {@link createInitialChartState} for state initialization */ export declare const chartReducer: Reducer; /** * @function createInitialChartState * @description * Factory function that creates the initial state for a chart store. * Provides sensible defaults for all state fields while allowing * customization via the config parameter. * * **Default Values:** * - `data`: Empty array * - `filteredData`: Same as data * - `dimensions`: 600x400px * - `selection`: No selection (type: 'none') * - `transform`: Identity transform {x: 0, y: 0, k: 1} * - `isAnimating`: false * - `transitionDuration`: 0.3s * - `spec`: Empty object (Observable Plot will use defaults) * * @example * ```typescript * import { createInitialChartState } from '@composable-svelte/charts'; * * // With data * const state = createInitialChartState({ * data: [{ x: 1, y: 10 }, { x: 2, y: 20 }] * }); * * // With custom dimensions * const state = createInitialChartState({ * data: myData, * dimensions: { width: 800, height: 600 } * }); * * // With Observable Plot spec customization * const state = createInitialChartState({ * data: myData, * spec: { * marginLeft: 60, * marginBottom: 40, * grid: true * } * }); * ``` * * @template T - Type of data items in the dataset * @param {Object} config - Configuration object * @param {T[]} [config.data=[]] - Initial dataset * @param {Partial} [config.spec={}] - Observable Plot specification overrides * @param {{width: number, height: number}} [config.dimensions] - Chart dimensions (default: 600x400) * @returns {ChartState} Initial chart state * * @see {@link ChartState} for full state structure * @see {@link chartReducer} for state transitions */ export declare function createInitialChartState(config: { data?: T[]; spec?: Partial; dimensions?: { width: number; height: number; }; }): ChartState; //# sourceMappingURL=chart.reducer.d.ts.map