JavaScript & React libraryAPI Generated Docs

Interface: ICosmograph

Public Cosmograph API interface.

Properties

stats

readonly stats: CosmographStats

Statistical information about current points and links in the graph.

Returns

An object containing the count of points and links and summaries of points and links data.

Summaries include:

  • Column names and types
  • Aggregates for each column (count, min, max, approx_unique, avg, std, q25, q50, q75)
  • Percentage of NULL values

focusedPointIndex

readonly focusedPointIndex: number | undefined

Gets the index of the currently focused point.

Returns

The index of the focused point, or undefined if no point is focused.


clusterMapping

readonly clusterMapping: Map<string, { index: number; count: number; }>

Gets the mapping of cluster values to their auto-generated indices and counts of items in each cluster.

Remarks

If pointClusterByFn is provided, keys of map will be values of pointClusterBy after applying pointClusterByFn.


activePointColorStrategy

readonly activePointColorStrategy: "map" | "categorical" | "continuous" | "degree" | "preciseDegree" | "linkDirection" | "direct" | "single"

Provides the active point color strategy for the Cosmograph instance.

Returns

The active point color strategy.


activePointSizeStrategy

readonly activePointSizeStrategy: "auto" | "degree" | "preciseDegree" | "direct" | "single"

Provides the active point size strategy for the Cosmograph instance.

Returns

The active point size strategy.


activeLinkColorStrategy

readonly activeLinkColorStrategy: "count" | "categorical" | "direct" | "single" | "sum" | "average"

Provides the active link color strategy for the Cosmograph instance.

Returns

The active link color strategy.


activeLinkWidthStrategy

readonly activeLinkWidthStrategy: "count" | "direct" | "single" | "sum" | "average"

Provides the active link width strategy for the Cosmograph instance.

Returns

The active link width strategy.


linksTableName

readonly linksTableName: string

Provides the name of the links table used by the Cosmograph instance.

Returns

The name of the links table.


pointsTableName

readonly pointsTableName: string

Provides the name of the points table used by the Cosmograph instance.

Returns

The name of the points table.


progress

readonly progress: number | undefined

A value that gives information about the running simulation progress.

Returns

The current progress of the simulation, where 0 represents the start of the simulation and 1 represents the end, or undefined if not available.


isSimulationRunning

readonly isSimulationRunning: boolean | undefined

Gets a boolean indicating whether the simulation is currently running.

Returns

true if the simulation is running, false if it is not running, or undefined if the information is not available.


isSimulationAvailable

readonly isSimulationAvailable: boolean

Gets a boolean indicating if a simulation can run for the current graph configuration and data.

Remarks

Determined on graph init/rebuild. Based on enableSimulation config (if set), or defaults to true if links exist or points lack layout (pointXBy/pointYBy).

The value updates upon graph initialization or rebuild (e.g., after setConfig or data loading).

Returns

true if a simulation can run, false otherwise.


is3D

readonly is3D: boolean | undefined

Whether Cosmograph is currently rendering in 3D mode.


pointDegrees

readonly pointDegrees: number[] | undefined

Gets the point degrees for the current graph.

Returns

The point degrees as an array of their degree values in the order they were sent to Cosmograph, or undefined if not available.


pointDirections

readonly pointDirections: number[] | undefined

Gets the point directions for the current graph.

Remarks

The point directions are calculated based on the in-degree and out-degree of the points. The value is 0 if the point has only an outgoing link (source), 1 if it has both incoming and outgoing links (source+target), 2 if it has only an incoming link (target), and 3 if it has no links (not linked).

Returns

The point directions as an array of their direction values in the order they were sent to Cosmograph, or undefined if not available.


maxPointSize

readonly maxPointSize: number

Gets the maximum point size. This value is the maximum size of the gl.POINTS primitive that WebGL can render on the user’s hardware.

Returns

The maximum point size, or 0 if not available.


dataUploaded()

dataUploaded: () => Promise<void>

Waits for the data upload promise to resolve, if it exists. This method is used to ensure that any necessary data has been uploaded before proceeding with other operations.

Returns

Promise<void>

A promise that resolves when the data is ready.


rescaleXFn

readonly rescaleXFn: (x) => number | undefined

Gets the callback function for rescaling the x-axis.

Returns

The callback function for rescaling the x-axis, or undefined if not set.


rescaleYFn

readonly rescaleYFn: (y) => number | undefined

Gets the callback function for rescaling the y-axis.

Returns

The callback function for rescaling the y-axis, or undefined if not set.


pointsSelection

pointsSelection: Selection

The Mosaic selection for the points side — filter widgets, vgplot interactors, and any custom Mosaic clause source publish their clauses here. Exposes Mosaic’s standard clause/active API.


linksSelection

linksSelection: Selection

The Mosaic selection for the links side — filter widgets, vgplot interactors, and any custom Mosaic clause source publish their clauses here. Exposes Mosaic’s standard clause/active API.

Methods

setConfig()

setConfig(config?): void

Sets the config for the Cosmograph.

Parameters

ParameterTypeDescription
config?CosmographConfigConfig to be applied to the Cosmograph.

Returns

void


getConfig()

getConfig(): Promise<CosmographConfig>

Retrieves the current configuration of the Cosmograph.

Returns

Promise<CosmographConfig>

A promise that resolves with the current Cosmograph configuration.


getActivePointColorFn()

getActivePointColorFn(): Promise<ColorAccessorFn | undefined>

Gets the current coloring function.

Returns

Promise<ColorAccessorFn | undefined>

The point coloring function, or undefined if not available.


getActivePointSizeFn()

getActivePointSizeFn(): Promise<SizeAccessorFn | undefined>

Gets the current point sizing function.

Returns

Promise<SizeAccessorFn | undefined>

The point sizing function, or undefined if not available.


getActiveLinkColorFn()

getActiveLinkColorFn(): Promise<ColorAccessorFn | undefined>

Gets the current link coloring function.

Returns

Promise<ColorAccessorFn | undefined>

The link coloring function, or undefined if not available.


getActiveLinkWidthFn()

getActiveLinkWidthFn(): Promise<SizeAccessorFn | undefined>

Gets the current link width function.

Returns

Promise<SizeAccessorFn | undefined>

The link width function, or undefined if not available.


getPointsSummary()

getPointsSummary(force?): Promise<Record<string, unknown>[] | undefined>

Parameters

ParameterType
force?boolean

Returns

Promise<Record<string, unknown>[] | undefined>


getLinksSummary()

getLinksSummary(force?): Promise<Record<string, unknown>[] | undefined>

Parameters

ParameterType
force?boolean

Returns

Promise<Record<string, unknown>[] | undefined>


getSummary()

getSummary(force?): Promise<CosmographSummary>

Parameters

ParameterType
force?boolean

Returns

Promise<CosmographSummary>


captureScreenshot()

captureScreenshot(fileName?, scale?): void

Captures a screenshot of the current graph view.

Parameters

ParameterTypeDescription
fileName?stringOptional name for the downloaded file (default: ‘cosmograph-screenshot.png’).
scale?number-

Returns

void


getCanvas()

getCanvas(): HTMLCanvasElement | null

Gets the graph canvas element.

Returns

HTMLCanvasElement | null

The canvas element, or null if it is not available.


activateRectSelection()

activateRectSelection(): void

Activates the rectangular selection element.

Returns

void


deactivateRectSelection()

deactivateRectSelection(): void

Deactivates the rectangular selection element.

Returns

void


activatePolygonalSelection()

activatePolygonalSelection(): void

Activates the polygonal selection element.

Returns

void


deactivatePolygonalSelection()

deactivatePolygonalSelection(): void

Deactivates the polygonal selection element.

Returns

void


selectPointsInRect()

selectPointsInRect(rect, addToSelection?): void

Selects points inside a rectangular area, plus links between them. The link selection always also picks up edges that bridge the new region to the prior selection.

Parameters

ParameterTypeDescription
rect[[number, number], [number, number]] | nullTwo opposite corners [[left, top], [right, bottom]], or null.
addToSelection?boolean-

Returns

void


selectPointsInPolygon()

selectPointsInPolygon(polygonPoints, addToSelection?): void

Selects points inside a polygonal area. Same rule as selectPointsInRect.

Parameters

ParameterType
polygonPoints[number, number][]
addToSelection?boolean

Returns

void


unselectPointsInRect()

unselectPointsInRect(rect): void

Removes the region’s points (and their connected links) from the current user selection.

Parameters

ParameterType
rect[[number, number], [number, number]] | null

Returns

void


unselectPointsInPolygon()

unselectPointsInPolygon(polygonPoints): void

Removes the region’s points (and their connected links) from the current user selection.

Parameters

ParameterType
polygonPoints[number, number][]

Returns

void


selectPoints()

selectPoints(pointIndices, addToSelection?, selectConnectedPoints?): void

Replace, or with addToSelection: true extend, the user point selection.

addToSelection: false (replace) clears BOTH user-selection Sets first, then applies the new point contribution — a clean restart. addToSelection: true only adds to the point side, leaving the link side as-is.

With selectConnectedPoints: true, also extends the link selection additively with edges-within(input) ∪ edges-between(input, S_p_after) — links among the new region and links bridging the new region to whatever is already selected on the point side.

  • selectPoints([1, 2, 3]) — replace: clears both sides, then sets point side to {1, 2, 3}.
  • selectPoints([4, 5], true) — additive: extends point selection, link side untouched.
  • selectPoints([1, 2, 3], false, true) — replace + internal links: clears both, sets points, adds internal edges.
  • selectPoints(null) / selectPoints([]) — clears both user-selection Sets (default). Alias for unselectAll. addToSelection is ignored for null; selectPoints([], true, _) is a no-op.
  • selectPoints(null, _, false) / selectPoints([], _, false) — clears the point user selection only. Alias for unselectAllPoints(false).

Parameters

ParameterType
pointIndicesnumber[] | null
addToSelection?boolean
selectConnectedPoints?boolean

Returns

void


selectPoint()

selectPoint(pointIndexBy, addToSelection?, selectConnectedPoints?): void

Selects a single point. Delegates to selectPoints after expanding to {P} ∪ N(P) when selectConnectedPoints is true. addToSelection: false clears both user-selection Sets first (clean restart); addToSelection: true adds to current. selectConnectedPoints defaults to true (smart mode). Pass false for single-point / point-only selection. Canvas click handlers pass the config-driven value explicitly.

Pass null to reset user selection — delegates to selectPoints(null, …). For a full reset including Mosaic widget clauses, use resetSelection instead.

Parameters

ParameterType
pointIndexBynumber | null
addToSelection?boolean
selectConnectedPoints?boolean

Returns

void


unselectPoint()

unselectPoint(pointIndexBy?, unselectConnectedPoints?): void

Unselects a point. With unselectConnectedPoints: true (default), also removes incident links from the link selection when that side is user-active. Pass false for single mode. Canvas click handlers pass the config-driven value explicitly.

Parameters

ParameterType
pointIndexBy?number
unselectConnectedPoints?boolean

Returns

void


unselectPoints()

unselectPoints(indicesToRemove, unselectConnectedPoints?): void

Removes the given points from the current user point selection. With unselectConnectedPoints: true, also removes the points’ incident links from the link selection. Symmetric naming with selectPoints.

Parameters

ParameterType
indicesToRemovenumber[]
unselectConnectedPoints?boolean

Returns

void


unselectPointsByIndices()

unselectPointsByIndices(indicesToRemove, unselectConnectedPoints?): void

Parameters

ParameterType
indicesToRemovenumber[]
unselectConnectedPoints?boolean

Returns

void

Deprecated

Use unselectPoints instead.


unselectAllPoints()

unselectAllPoints(alsoUnselectLinks?): void

Clears the point user selection and drops the focused point. Default (true) also clears the link user selection — alias for unselectAll. Pass false for point side only. Does NOT touch Mosaic clauses or filter widgets.

Parameters

ParameterType
alsoUnselectLinks?boolean

Returns

void


selectLinks(linkIndices, addToSelection?, selectEndpoints?): void

Replace, or with addToSelection: true extend, the user link selection.

addToSelection: false (replace) clears BOTH user-selection Sets first — same clean-restart semantics as selectPoints. addToSelection: true only adds to the link side. With selectEndpoints: true, also extends the point selection with each link’s endpoints.

Pass null for a user-selection reset. For a full reset including Mosaic widget clauses, use resetSelection instead:

  • selectLinks(null) / selectLinks([]) — clears both user-selection Sets (default). Alias for unselectAll. addToSelection is ignored for null; selectLinks([], true, _) is a no-op.
  • selectLinks(null, _, false) / selectLinks([], _, false) — clears the link user selection only. Alias for unselectAllLinks(false).

Parameters

ParameterType
linkIndicesnumber[] | null
addToSelection?boolean
selectEndpoints?boolean

Returns

void


selectLink(linkIndex, addToSelection?, selectEndpoints?): void

Selects a single link. Delegates to selectLinks. addToSelection: false clears both user-selection Sets first (clean restart); addToSelection: true adds to current. With selectEndpoints: true, also adds the link’s two endpoint points additively. Pass null to reset user selection — same semantics as selectLinks(null, …).

Parameters

ParameterType
linkIndexnumber | null
addToSelection?boolean
selectEndpoints?boolean

Returns

void


unselectLink(linkIndex?, unselectEndpoints?): void

Removes a single link from the link selection. Default (true) also removes the link’s endpoints AND every other link incident to those endpoints. Pass false for single mode. Canvas click handlers pass the config-driven value explicitly.

Parameters

ParameterType
linkIndex?number
unselectEndpoints?boolean

Returns

void


unselectLinks(indicesToRemove, unselectEndpoints?): void

Removes the given links from the current user link selection. With unselectEndpoints: true, also removes each link’s endpoints AND every other link incident to those endpoints (no danglers left behind). Symmetric naming with selectLinks.

Parameters

ParameterType
indicesToRemovenumber[]
unselectEndpoints?boolean

Returns

void


unselectAllLinks(alsoUnselectPoints?): void

Clears the link user selection. Default (true) also clears the point user selection and drops the focused point — alias for unselectAll. Pass false for link side only. Does NOT touch Mosaic clauses or filter widgets.

Parameters

ParameterType
alsoUnselectPoints?boolean

Returns

void


unselectAll()

unselectAll(): void

Clears both user-selection Sets and drops the focused point. Does NOT touch Mosaic clauses — filter widgets (histograms, bars, search, timeline) stay active. For a full reset across both selection channels, use resetSelection.

Returns

void


resetSelection()

resetSelection(): void

Full reset across both selection channels: clears user-selection Sets, drops the focused point, AND dispatches resetSelections so filter widgets drop their Mosaic clauses. Use when you want the canvas to return to the default “no input active” state.

Returns

void


getSelectedPointIndices()

getSelectedPointIndices(): number[] | undefined

Get the resolved point highlight — the indices currently selected on the canvas, combining user selection, clauses on pointsSelection, and graph consistency driven by clauses on linksSelection.

Returns

number[] | undefined

A copy of the highlighted point indices, or undefined when the points side is inactive.


getSelectedLinkIndices()

getSelectedLinkIndices(): number[] | undefined

Get the resolved link highlight — the indices currently selected on the canvas, combining user selection, clauses on linksSelection, and graph consistency driven by clauses on pointsSelection.

Returns

number[] | undefined

A copy of the highlighted link indices, or undefined when the links side is inactive.


isPointHighlighted()

isPointHighlighted(pointIndex): boolean

Returns whether the point is currently highlighted. The highlight set is the resolved combination of Mosaic clauses, user selection, and graph consistency from the link side. When the points side is inactive, every point is treated as highlighted.

Parameters

ParameterTypeDescription
pointIndexnumberPoint index to check.

Returns

boolean


start()

start(alpha?): void

Starts the simulation.

Parameters

ParameterTypeDescription
alpha?numberValue between 0 and 1. The higher the value, the more energy the simulation gets.

Returns

void


pause()

pause(): void

Pauses the simulation.

Returns

void


unpause()

unpause(): void

Unpauses the simulation.

Returns

void


stop()

stop(): void

Stops the simulation.

Returns

void


step()

step(): void

Renders only one frame of the simulation (stops the simulation if it was running).

Returns

void


destroy()

destroy(): Promise<void>

Destroys the Cosmograph instance and cleans up associated resources.

Returns

Promise<void>

A promise that resolves when the destroy operation is complete.


reset()

reset(total?): Promise<void>

Resets the Cosmograph instance to its initial state.

Parameters

ParameterTypeDescription
total?booleanIf true, resets configuration and displays the message div.

Returns

Promise<void>

A promise that resolves when the reset operation is complete.


setZoomLevel()

setZoomLevel(value, duration?): void

Zooms the view in or out to the specified zoom level.

Parameters

ParameterTypeDescription
valuenumberZoom level.
duration?numberDuration of the zoom transition.

Returns

void


getZoomLevel()

getZoomLevel(): number | undefined

Gets the zoom level of the view.

Returns

number | undefined

Zoom level value.


setZoomTransformByPointPositions()

setZoomTransformByPointPositions(pointPositions, duration?, scale?, padding?): void

Sets the zoom transform so that the given point positions fit in the viewport, with optional animation.

Parameters

ParameterTypeDescription
pointPositionsFloat32Array-
duration?numberAnimation duration in milliseconds. Default 250.
scale?numberOptional scale factor; if omitted, scale is chosen to fit the positions.
padding?numberPadding around the viewport as a fraction (e.g. 0.1 = 10%). Default 0.1.

Returns

void


zoomToPoint()

zoomToPoint(index, duration?, scale?, canZoomOut?): void

Centers the view and zooms in to a point by its index.

Parameters

ParameterTypeDescription
indexnumberPoint index to be zoomed in.
duration?numberOptional duration in milliseconds.
scale?numberOptional zoom level.
canZoomOut?booleanOptional parameter determining whether the view can zoom out.

Returns

void


getPointPositions()

getPointPositions(options?): Float32Array<ArrayBufferLike> | undefined

Gets the current point coordinates.

Parameters

ParameterType
options?PositionDimensionsOptions

Returns

Float32Array<ArrayBufferLike> | undefined

Float32Array of point positions ([x, y, ...] or [x, y, z, ...]).


getPointPositionByIndex()

Call Signature

getPointPositionByIndex(index, options?): [number, number] | undefined

Gets the current X and Y coordinates of a point by its index.

Parameters
ParameterTypeDescription
indexnumberPoint index.
options?PositionDimensionsOptions & object-
Returns

[number, number] | undefined

Array with X and Y coordinates of the point, or undefined if the point index is invalid.

Call Signature

getPointPositionByIndex(index, options): [number, number, number] | undefined

Parameters
ParameterType
indexnumber
optionsPositionDimensionsOptions & object
Returns

[number, number, number] | undefined


getClusterPositions()

getClusterPositions(options?): number[] | undefined

Gets the current X and Y coordinates of the clusters.

Parameters

ParameterType
options?PositionDimensionsOptions

Returns

number[] | undefined

Array of point cluster positions.


getPointColors()

getPointColors(): Float32Array<ArrayBufferLike> | undefined

Gets the current colors for each point.

Returns

Float32Array<ArrayBufferLike> | undefined

A Float32Array containing RGBA color values for each point, or undefined if not available.


getPointSizes()

getPointSizes(): Float32Array<ArrayBufferLike> | undefined

Gets the current sizes for each point.

Returns

Float32Array<ArrayBufferLike> | undefined

A Float32Array containing size values for each point, or undefined if not available.


getLinkColors()

getLinkColors(): Float32Array<ArrayBufferLike> | undefined

Gets the current colors for each link.

Returns

Float32Array<ArrayBufferLike> | undefined

A Float32Array containing RGBA color values for each link, or undefined if not available.


getLinkWidths()

getLinkWidths(): Float32Array<ArrayBufferLike> | undefined

Gets the current widths for each link.

Returns

Float32Array<ArrayBufferLike> | undefined

A Float32Array containing width values for each link, or undefined if not available.


getSampledPoints()

getSampledPoints(options?): { indices: number[]; positions: number[]; } | undefined

Retrieves sampled point data as arrays with indices and positions.

Parameters

ParameterType
options?PositionDimensionsOptions

Returns

{ indices: number[]; positions: number[]; } | undefined

An object containing separate arrays for point indices and their corresponding positions, or undefined if not available. The indices array contains point indices, and the positions array contains flattened coordinates [x0, y0, x1, y1, ...].


getSampledLinks(options?): { indices: number[]; positions: number[]; angles: number[]; } | undefined

For the links that are currently visible on the screen, get a sample of link indices, midpoint positions, and angles. The resulting number of links will depend on the linkSamplingDistance configuration property, and the sampled links will be evenly distributed. Positions are in data space; angles are in radians for screen-space rotation (0 = right, positive = clockwise, e.g. for CSS rotation).

Parameters

ParameterType
options?PositionDimensionsOptions

Returns

{ indices: number[]; positions: number[]; angles: number[]; } | undefined


getTrackedPointPositionsArray()

getTrackedPointPositionsArray(options?): number[] | undefined

Gets an array of point positions that are currently tracked by the renderer. Use trackPointPositionsByIndices to specify which points to track.

Parameters

ParameterType
options?PositionDimensionsOptions

Returns

number[] | undefined

A flattened array of point positions [x0, y0, x1, y1, ...] for tracked points, or undefined if not available.

See


getTrackedPointPositionsMap()

Call Signature

getTrackedPointPositionsMap(options?): ReadonlyMap<number, [number, number]> | undefined

Gets a Map of point positions that are currently tracked by the renderer. Use trackPointPositionsByIndices to specify which points to track.

Parameters
ParameterType
options?PositionDimensionsOptions & object
Returns

ReadonlyMap<number, [number, number]> | undefined

A Map where keys are point indices and values are their corresponding X, Y coordinates, or undefined if not available.

See

Call Signature

getTrackedPointPositionsMap(options): ReadonlyMap<number, [number, number, number]> | undefined

Parameters
ParameterType
optionsPositionDimensionsOptions & object
Returns

ReadonlyMap<number, [number, number, number]> | undefined


trackPointPositionsByIndices()

trackPointPositionsByIndices(indices): void

Tracks point positions by indices on each simulation tick. Once tracking is enabled, use getTrackedPointPositionsArray or getTrackedPointPositionsMap to retrieve the current positions.

Parameters

ParameterTypeDescription
indicesnumber[]Array of point indices.

Returns

void

See


fitView()

fitView(duration?, padding?): void

Centers and zooms the view to fit all points in the scene.

Parameters

ParameterTypeDescription
duration?numberDuration of the animation (default: 250ms).
padding?numberPadding around the viewport (0 to 1 as 100% of the viewport, default 0.1.

Returns

void

Remarks

During an active position transition the camera fits the target layout, not the interpolated positions currently on screen.


fitViewByIndices()

fitViewByIndices(indices, duration?, padding?): void

Centers and zooms the viewport to fit points based on their indices.

Parameters

ParameterTypeDescription
indicesnumber[]Array of point indices.
duration?numberDuration of the animation (default: 250ms).
padding?numberPadding around the viewport (0 to 1 as 100% of the viewport, default 0.1.

Returns

void

Remarks

During an active position transition the camera fits the target layout, not the interpolated positions currently on screen.


fitViewByCoordinates()

fitViewByCoordinates(coordinates, duration?, padding?): void

Fits the given coordinates into the viewport.

Parameters

ParameterTypeDescription
coordinatesnumber[]Array of coordinates in the format [x0, y0, x1, y1, …].
duration?numberDuration of the animation (default: 250ms).
padding?numberPadding around the viewport (0 to 1 as 100% of the viewport, default 0.1).

Returns

void

Remarks

During an active position transition the camera fits the supplied coordinates directly; ongoing point animations may finish at a layout that no longer matches the framed view.


setFocusedPoint()

setFocusedPoint(index?): void

Sets focus on a point by index. Draws a ring around the focused point.

Parameters

ParameterTypeDescription
index?numberIndex of the point to be focused.

Returns

void

Remarks

If focusedPointIndex is set, it will have priority over this method.


setPinnedPoints()

setPinnedPoints(indices): void

Sets which points are pinned (fixed) in position.

Pinned points:

  • Do not move due to physics forces (gravity, repulsion, link forces, etc.)
  • Still participate in force calculations (other nodes are attracted to/repelled by them)
  • Can still be dragged by the user if enableDrag is true

Parameters

ParameterTypeDescription
indicesnumber[]Array of point indices to pin. Set to [] or null to unpin all points.

Returns

void

Example

// Pin points 0 and 5
  graph.setPinnedPoints([0, 5])
 
  // Unpin all points
  graph.setPinnedPoints([])
  graph.setPinnedPoints(null)

getConnectedPointIndices()

getConnectedPointIndices(index): number[] | undefined

Gets the indices of the points that are connected to the point with the given index.

Parameters

ParameterTypeDescription
indexnumberThe index of the point to get the connected points for.

Returns

number[] | undefined

An array of indices of the connected points, or undefined if the point index is invalid or there are no connected points.

Deprecated

Prefer getNeighboringPointIndices.


getNeighboringPointIndices()

getNeighboringPointIndices(pointIndices): number[] | undefined

Returns each input point’s neighbors — points connected by a link in either direction. Results are deduplicated when multiple inputs share neighbors.

Parameters

ParameterTypeDescription
pointIndicesnumber | number[]A single point index or an array of indices.

Returns

number[] | undefined

Array of neighboring point indices, or undefined if the graph is not initialized.


getConnectedLinkIndices()

getConnectedLinkIndices(pointIndices): number[] | undefined

Returns link indices where both endpoints are within the provided point set.

Parameters

ParameterTypeDescription
pointIndicesnumber | number[]A single point index or an array of point indices.

Returns

number[] | undefined

Deduplicated array of link indices, or undefined if the graph is not initialized.


findPointsInRect()

findPointsInRect(rect): number[] | undefined

Find point indices inside a rectangular area. Coordinates are canvas-relative pixels.

Parameters

ParameterTypeDescription
rect[[number, number], [number, number]]Two opposite corners of the rectangle: [[left, top], [right, bottom]].

Returns

number[] | undefined

Array of point indices inside the rectangle, or undefined if the graph is not initialized.


findPointsInPolygon()

findPointsInPolygon(polygonPath): number[] | undefined

Find point indices inside a polygon area. Coordinates are canvas-relative pixels.

Parameters

ParameterTypeDescription
polygonPath[number, number][]Array of points defining the polygon [[x1, y1], [x2, y2], ..., [xn, yn]].

Returns

number[] | undefined

Array of point indices inside the polygon, or undefined if the graph is not initialized.


getPointDegrees()

getPointDegrees(index): { inDegree: number; outDegree: number; } | undefined

Gets the in-degree and out-degree (link counts) for the point with the given index.

Parameters

ParameterTypeDescription
indexnumberThe index of the point to get the degrees for.

Returns

{ inDegree: number; outDegree: number; } | undefined

An object containing the in-degree (incoming links) and out-degree (outgoing links) for the point, or undefined if the cosmograph instance is not initialized or the point index is invalid.


spaceToScreenPosition()

Call Signature

spaceToScreenPosition(spacePosition, options?): [number, number] | undefined

Converts the X and Y point coordinates from the space coordinate system to the screen coordinate system.

Parameters
ParameterTypeDescription
spacePosition[number, number]Array of x and y coordinates in the space coordinate system.
options?PositionDimensionsOptions-
Returns

[number, number] | undefined

Array of x and y coordinates in the screen coordinate system.

Call Signature

spaceToScreenPosition(spacePosition, options): [number, number] | undefined

Parameters
ParameterType
spacePosition[number, number, number]
optionsPositionDimensionsOptions & object
Returns

[number, number] | undefined


screenToSpacePosition()

Call Signature

screenToSpacePosition(screenPosition, options?): [number, number] | undefined

Converts the X and Y point coordinates from the screen coordinate system to the space coordinate system.

Parameters
ParameterTypeDescription
screenPosition[number, number]Array of x and y coordinates in the screen coordinate system.
options?PositionDimensionsOptions & object-
Returns

[number, number] | undefined

Array of x and y coordinates in the space coordinate system.

Call Signature

screenToSpacePosition(screenPosition, options): [number, number, number] | undefined

Parameters
ParameterType
screenPosition[number, number]
optionsPositionDimensionsOptions & object
Returns

[number, number, number] | undefined


getCameraState()

getCameraState(): Camera3dState | undefined

Returns

Camera3dState | undefined


setCameraState()

setCameraState(state, duration?): void

Parameters

ParameterType
statePartial<Camera3dState>
duration?number

Returns

void


spaceToScreenRadius()

spaceToScreenRadius(spaceRadius): number | undefined

Converts the point radius value from the space coordinate system to the screen coordinate system.

Parameters

ParameterTypeDescription
spaceRadiusnumberRadius of the point in the space coordinate system.

Returns

number | undefined

Radius of the point in the screen coordinate system.


getPointRadiusByIndex()

getPointRadiusByIndex(index): number | undefined

Get point space radius by its index.

Parameters

ParameterTypeDescription
indexnumberIndex of the point.

Returns

number | undefined

Radius of the point in the space coordinate system.


getPointScreenRadiusByIndex()

getPointScreenRadiusByIndex(index, pointPosition?): number | undefined

Get point screen radius by its index.

Parameters

ParameterTypeDescription
indexnumberIndex of the point.
pointPosition?[number, number, number]-

Returns

number | undefined

Radius of the point in the screen coordinate system.


getSampledPointPositionsMap()

Call Signature

getSampledPointPositionsMap(options?): Map<number, [number, number]> | undefined

For the points that are currently visible on the screen, get a sample of point ids with their coordinates. The resulting number of points will depend on the pointSamplingDistance configuration property, and the sampled points will be evenly distributed.

Parameters
ParameterType
options?PositionDimensionsOptions & object
Returns

Map<number, [number, number]> | undefined

A Map where keys are the ids of the points and values are their corresponding X and Y coordinates.

Call Signature

getSampledPointPositionsMap(options): Map<number, [number, number, number]> | undefined

Parameters
ParameterType
optionsPositionDimensionsOptions & object
Returns

Map<number, [number, number, number]> | undefined


getSampledLinkPositionsMap()

Call Signature

getSampledLinkPositionsMap(options?): Map<number, [number, number, number]> | undefined

For the links that are currently visible on the screen, get a sample of link indices with their midpoint coordinates and angle. The resulting number of links will depend on the linkSamplingDistance configuration property, and the sampled links will be evenly distributed (one link per grid cell, based on link midpoint in screen space). Each value is [x, y, angle]: position in data space; angle in radians for screen-space rotation (0 = right, positive = clockwise, e.g. for CSS rotation).

Parameters
ParameterType
options?PositionDimensionsOptions & object
Returns

Map<number, [number, number, number]> | undefined

Call Signature

getSampledLinkPositionsMap(options): Map<number, [number, number, number, number]> | undefined

Parameters
ParameterType
optionsPositionDimensionsOptions & object
Returns

Map<number, [number, number, number, number]> | undefined


getActiveSelectionSourceId()

getActiveSelectionSourceId(): string | undefined

Gets the id of the filter widget that last drove the points crossfilter.

Returns

string | undefined

The id of the active filter widget, or undefined if no filter is active.


getPointIndicesByIds()

getPointIndicesByIds(ids): Promise<number[] | undefined>

Returns an array of point indices in the order they were sent to getPointIndicesByIds.

Parameters

ParameterTypeDescription
idsstring[]Array of point ids.

Returns

Promise<number[] | undefined>

A Promise resolving to an array of point indices.


getPointIdsByIndices()

getPointIdsByIndices(indices): Promise<string[] | undefined>

Returns an array of point ids in the order they were sent to getPointIdsByIndices.

Parameters

ParameterTypeDescription
indicesnumber[]Array of point indices.

Returns

Promise<string[] | undefined>

A Promise resolving to an array of point ids.


getPointsByIndices()

getPointsByIndices(indices): Promise<CosmographData | undefined>

Returns points entries as a CosmographData table by their indices.

Parameters

ParameterTypeDescription
indicesnumber[]Array of point indices.

Returns

Promise<CosmographData | undefined>

A Promise resolving to a CosmographData table of points.


getPointIndicesByExactValues()

getPointIndicesByExactValues(column, values): Promise<number[] | undefined>

Returns an array of point indices that match the provided values in a column.

Parameters

ParameterTypeDescription
columnstringThe column to filter by.
values(string | number)[]The values to match in the specified column.

Returns

Promise<number[] | undefined>

A Promise resolving to an array of point indices, or undefined if the operation fails.


getPointIndicesByNumericValue()

getPointIndicesByNumericValue(column, value, isMax): Promise<number[] | undefined>

Returns an array of point indices that match the provided numeric value in the specified column.

Parameters

ParameterTypeDescription
columnstringThe column in the points table to filter by.
valuestring | numberThe numeric value to match in the specified column.
isMaxbooleanIndicates whether to return the indices for the maximum or minimum value.

Returns

Promise<number[] | undefined>

A Promise resolving to an array of point indices, or undefined if the operation fails.


getPointIndicesByLinksExactValues()

getPointIndicesByLinksExactValues(column, values): Promise<number[] | undefined>

Returns an array of point indices that match the provided link column values.

Parameters

ParameterTypeDescription
columnstringThe column in the links table to filter by.
values(string | number)[]The values to match in the specified column.

Returns

Promise<number[] | undefined>

A Promise resolving to an array of point indices.


getPointIndicesByLinksNumericValue()

getPointIndicesByLinksNumericValue(column, value, isMax): Promise<number[] | undefined>

Returns an array of point indices that match the provided link column numeric value.

Parameters

ParameterTypeDescription
columnstringThe column in the links table to filter by.
valuestring | numberThe numeric value to match in the specified column.
isMaxbooleanIndicates whether to return the indices for the maximum or minimum value.

Returns

Promise<number[] | undefined>

A Promise resolving to an array of point indices.


getLinksByPointIds()

getLinksByPointIds(ids): Promise<CosmographData | undefined>

Returns links entries as a CosmographData table where the source or target point id is in the provided array.

Parameters

ParameterTypeDescription
idsstring[]Array of point ids.

Returns

Promise<CosmographData | undefined>

A Promise resolving to a CosmographData table of links.


getLinksByPointIndices()

getLinksByPointIndices(indices): Promise<CosmographData | undefined>

Returns links entries as a CosmographData table where the source or target point index is in the provided array.

Parameters

ParameterTypeDescription
indicesnumber[]Array of point indices.

Returns

Promise<CosmographData | undefined>

A Promise resolving to a CosmographData table of links.


getPointsData()

getPointsData(): Promise<CosmographData | undefined>

Returns all points entries as a CosmographData table.

Returns

Promise<CosmographData | undefined>

A Promise resolving to a CosmographData table of points.


getLinksData()

getLinksData(): Promise<CosmographData | undefined>

Returns all links entries as a CosmographData table.

Returns

Promise<CosmographData | undefined>

A Promise resolving to a CosmographData table of links.


searchPoints()

searchPoints(input, options): Promise<CosmographSearchResult>

Searches point data across the requested fields.

Each searched field value is converted to a string before matching, so this method can search text, numeric, boolean, date, and other scalar columns. By default, matching is case-insensitive and checks whether the query occurs anywhere in a field value.

The returned rows are limited to 100 by default. Use limit and offset for pagination, returnFields to return only specific columns, and totalCount to display the complete number of matching points before pagination.

This method does not update the graph selection.

Parameters

ParameterTypeDescription
inputstringSearch query.
optionsCosmographSearchOptionsSearch behavior, fields, pagination, and returned columns.

Returns

Promise<CosmographSearchResult>

Matching point rows and the total number of matches before pagination.

Example

const result = await cosmograph.searchPoints('bike', {
  fields: ['label', 'topic'],
  returnFields: ['idx', 'label', 'topic'],
  limit: 50,
})
 
console.log(result.rows)
console.log(result.totalCount)

getPointIndicesBySearch()

getPointIndicesBySearch(input, options): Promise<number[]>

Returns point indices matching a search query.

Matching follows the same rules as searchPoints, but the query returns point indices only. This is more efficient when the caller wants to select, filter, or fit the view to all matching points without loading complete rows.

Unlike searchPoints, this method has no default limit, so it returns every matching point index unless limit is explicitly provided. The returnFields option is ignored.

This method does not update the graph selection. Pass the result to selectPoints when selection is desired.

Parameters

ParameterTypeDescription
inputstringSearch query.
optionsCosmographSearchOptionsSearch options. The default limit is undefined, returning all matching point indices.

Returns

Promise<number[]>

Matching point indices.

Example

const indices = await cosmograph.getPointIndicesBySearch('bike', {
  fields: ['label', 'topic'],
})
 
cosmograph.selectPoints(indices)
cosmograph.fitViewByIndices(indices)

convertCosmographDataToObject()

convertCosmographDataToObject(data): Record<string, unknown>[]

Converts a CosmographData table to an array of objects.

Parameters

ParameterTypeDescription
dataCosmographDataCosmographData table.

Returns

Record<string, unknown>[]

An array of objects.


flattenPositions()

flattenPositions(positions): number[] | undefined

Converts an array of tuple positions to a single flattened array containing all coordinates sequentially.

Parameters

ParameterTypeDescription
positions[number, number][]An array of tuple positions.

Returns

number[] | undefined

A flattened array of coordinates.


pair()

pair(pointPositions): [number, number][] | undefined

Converts a flat array of point positions to tuple pairs representing coordinates.

Parameters

ParameterTypeDescription
pointPositionsnumber[]A flattened array of coordinates.

Returns

[number, number][] | undefined

An array of tuple positions.


addPoints()

addPoints(points): Promise<void>

Adds points to the Cosmograph instance.

Parameters

ParameterTypeDescription
pointsCosmographPointInput[]The points data to add.

Returns

Promise<void>

A promise that resolves when the points have been added.

Remarks

Minimal to provide is point a id. Other fields are optional, should respect already existing fields in the points data, if not provided, will be filled with default values.


addLinks(links): Promise<void>

Adds links to the Cosmograph instance.

Parameters

ParameterTypeDescription
linksCosmographLinkInput[]The links data to add.

Returns

Promise<void>

A promise that resolves when the links have been added.

Remarks

Minimal to provide is a source point and target point id. Other fields are optional, should respect already existing fields in the links data, if not provided, will be filled with default values.


removePointsByIndices()

removePointsByIndices(indices, removeAttachedLinks?): Promise<void>

Removes points from the Cosmograph instance by their indices.

Parameters

ParameterTypeDescription
indicesnumber[]The indices of the points to remove.
removeAttachedLinks?booleanWhether to also remove links attached to the points.

Returns

Promise<void>

A promise that resolves when the points have been removed.


removePointsByIds()

removePointsByIds(ids): Promise<void>

Removes points from the Cosmograph instance by their IDs.

Parameters

ParameterTypeDescription
idsstring[]The IDs of the points to remove.

Returns

Promise<void>

A promise that resolves when the points have been removed.


removeLinksByPointIdPairs()

removeLinksByPointIdPairs(pairs): Promise<void>

Removes links from the Cosmograph instance by their point ID pairs.

Parameters

ParameterTypeDescription
pairs[string, string][]The point ID pairs of the links to remove.

Returns

Promise<void>

A promise that resolves when the links have been removed.


removeLinksByPointIndicesPairs()

removeLinksByPointIndicesPairs(pairs): Promise<void>

Removes links from the Cosmograph instance by their point indices pairs.

Parameters

ParameterTypeDescription
pairs[number, number][]The point indices pairs of the links to remove.

Returns

Promise<void>

A promise that resolves when the links have been removed.


addMosaicComponent()

addMosaicComponent(component, container, config?): Promise<MosaicVgplotComponent | undefined>

Adds a custom Mosaic component (vgplot, spec, etc.) and mounts it to a container. The component will automatically participate in Cosmograph’s crossfilter system.

Parameters

ParameterTypeDescription
componentHTMLElementThe vgplot component
containerHTMLElementThe DOM element to mount the component into
config?{ id?: string; }Optional configuration for the component
config.id?string-

Returns

Promise<MosaicVgplotComponent | undefined>

A promise that resolves to the created component


removeMosaicComponent()

removeMosaicComponent(id): Promise<boolean>

Removes a custom Mosaic component by its ID.

Parameters

ParameterTypeDescription
idstringThe ID of the component to remove

Returns

Promise<boolean>

A promise that resolves to true if the component was removed, false otherwise


getMosaicComponents()

getMosaicComponents(): ReadonlyMap<string, MosaicVgplotComponent> | undefined

Gets all registered Mosaic components.

Returns

ReadonlyMap<string, MosaicVgplotComponent> | undefined

A readonly map of component IDs to components