import { CosmographData } from './data'; export interface BasicConfig { /** * Controls whether to enable force-directed layout simulation. If `undefined`, the simulation will be automatically enabled if there are no links or points have layout coordinates provided. * * When disabled (`false`): * - Uses x/y values from data for point positions. If positions not provided, random positions will be used. * * @default `undefined` */ enableSimulation?: boolean; /** * Specifies the CSS class to use for the rectangular selector. */ rectangularSelectorClassName?: string; /** * Stroke color for the lasso selection * @default '#ffffff' */ polygonalSelectorStrokeColor?: string; /** * Line width for the lasso selection * @default 2 */ polygonalSelectorLineWidth?: number; /** * Controls whether to select a clicked point with the connected points. * * - When `true`: Selects the clicked point and all connected points to it * - When `'single'`: Selects only the clicked point * - Will also focus (render ring around) the clicked point if {@link focusPointOnClick} is `undefined` */ selectPointOnClick?: boolean | 'single'; /** * Controls whether to select a point with the connected points when the point's label is clicked. * * - When `true`: Selects the clicked point and all connected points to it * - When `'single'`: Selects only the clicked point * - Will also focus (render ring around) the clicked point if {@link focusPointOnClick} is `undefined` */ selectPointOnLabelClick?: boolean | 'single'; /** * Controls whether to select points of a cluster when its label is clicked. */ selectClusterOnLabelClick?: boolean; /** * Controls whether to focus on a point when the point itself is clicked. */ focusPointOnClick?: boolean; /** * Controls whether to focus on a point when the point's label is clicked. */ focusPointOnLabelClick?: boolean; /** * Controls display state messages behavior for all Cosmograph components. * * - When `undefined`: Show all state messages (loading, no data) * - When `'loading'`: Show only loading state message, hide no data message * - When `false`: Disable all state messages * * This will be applied to all components unless explicitly overridden in component-specific configuration. * * @default `undefined` */ componentsDisplayStateMode?: 'loading' | false; /** * Chooses which kind of status indicator to show during loading or errors. * * - `'spinner'` (default): show a spinner during loading, falling back to text on errors. * - `'text'`: always show descriptive messages. * - `false`: hide the status indicator entirely. * * @default 'spinner' */ statusIndicatorMode?: 'spinner' | 'text' | false; /** * Disables logging of Cosmograph messages in the console. * * @default false */ disableLogging?: boolean; /** * Preserve positions for points with same ids ({@link CosmographConfig.pointIdBy pointIdBy} during point data update * * When `true`: * - Points with same ids will stay where they were instead of generating new positions * - New points get new positions (or positions from {@link CosmographConfig.pointXBy pointXBy}/{@link CosmographConfig.pointYBy pointYBy} if set) * - Preserved positions take priority over new coordinates from {@link CosmographConfig.pointXBy pointXBy}/{@link CosmographConfig.pointYBy pointYBy} for existing points * * @default false */ preservePointPositionsOnDataUpdate?: boolean; /** * Reset selection on empty canvas click * * When `true`: * - Resets the selection when the canvas is clicked and there are some points selected * * @default true */ resetSelectionOnEmptyCanvasClick?: boolean; /** * The color to use for points and links when their data is unknown and current coloring strategy can't resolve it`. * @default 'rgba(205, 207, 213, 0.9)' */ unknownColor?: string; /** * The key of the library license. * @default undefined */ licenseKey?: string; /** @deprecated Use `pointDefaultColor` instead */ pointColor?: string; /** @deprecated Use `pointDefaultSize` instead */ pointSize?: number; /** @deprecated Use `linkDefaultColor` instead */ linkColor?: string; /** @deprecated Use `linkDefaultWidth` instead */ linkWidth?: number; /** @deprecated Use `linkDefaultArrows` instead */ linkArrows?: boolean; } export interface CallbackConfig { /** * Callback function that will be called when the points was filtered by point crossfilter. * * @param {CosmographData} filteredPoints - A `Table` of filtered points. * @param {number[]} selectedPointIndices - Array of selected point indices related to the indices in the internal points table. * @param {number[]} selectedLinkIndices - Array of selected link indices related to the indices in the internal links table. */ onPointsFiltered?: (filteredPoints: CosmographData, selectedPointIndices: number[] | null | undefined, selectedLinkIndices: number[] | undefined) => void; /** * Callback function that will be called when the links was filtered by link crossfilter. * * @param {CosmographData} filteredLinks - A `Table` of filtered links. * @param {number[]} selectedLinkIndices - Array of selected link indices related to the indices in the internal links table. * @param {number[]} selectedPointIndices - Array of selected point indices related to the indices in the internal points table. */ onLinksFiltered?: (filteredLinks: CosmographData, selectedPointIndices: number[] | null | undefined, selectedLinkIndices: number[] | undefined) => void; /** * Callback function that will be called when clicked on a label. * * @param index - Point index for this label. * @param id - Point id for this label. * @param event - Corresponding mouse event. */ onLabelClick?: (index: number, id: string, event: MouseEvent) => void; /** * Callback function that will be called when clicked on a cluster label. * * @param index - Cluster index for this label. * @param id - Cluster id for this label. * @param event - Corresponding mouse event. */ onClusterLabelClick?: (index: number, id: string, event: MouseEvent) => void; /** * Callback function that executes after the graph completes rebuilding with new data. * @param stats Graph statistics after rebuilding * @param stats.pointsCount Number of rendered points in the graph * @param stats.linksCount Number of rendered links in the graph * @param [stats.pointsSummary] Summary information for the rendered points * @param [stats.linksSummary] Summary information for the rendered links */ onGraphRebuilt?: (stats: { pointsCount: number; linksCount: number; pointsSummary?: Record[]; linksSummary?: Record[]; }) => void; /** * Callback function that will be called when points or links data is replaced or modified at the local database. */ onGraphDataUpdated?: () => void; /** * Callback function that will be called after the config was updated. */ onConfigUpdated?: () => void; /** * Callback function that will be called when area selection was performed. * * @param selection — The selected area or `null` if the selection was cleared. * @param pointIndices — Indices of points inside the rect (available synchronously; same as `getSelectedPointIndices()` after crossfilter applies). */ onRectSelected?: (selection: [[number, number], [number, number]] | null, pointIndices?: number[]) => void; /** * Callback function that will be called when polygonal selection was performed. * * @param polygonPoints - The points of the polygon. */ onPolygonSelected?: (polygonPoints: [number, number][]) => void; }