JavaScript & React libraryAPI

Interface: CosmographDataPrepPointsConfig

Represents the configuration options for preparing points data for the Cosmograph.

Extends

Properties

pointIdBy?

optional pointIdBy: string

Unique identifier column for each point. Required for mapping links to points correctly.

Inherited from

CosmographPointsConfig.pointIdBy


pointColorBy?

optional pointColorBy: string

The column name for the point color. If provided, points will be colored based on the values in this column, which should be either a color string or an array of numeric [r, g, b, a] values.

Inherited from

CosmographPointsConfig.pointColorBy


pointColorByFn?

optional pointColorByFn: ColorAccessorFn<number> | ColorAccessorFn<string> | ColorAccessorFn<boolean> | ColorAccessorFn<unknown>

Specifies the function that will be used to generate the color for each point based on the value in the pointColorBy column. It takes a point record as input and its index, and should return a color string or an array of [r, g, b, a] values.

Overrides the values in pointColorBy column by processing them (in this case the values in the pointColorBy column can be of any type, not just colors).

Has effect only when pointColorBy is provided and pointColorStrategy is undefined.

See

pointColorStrategy

Returns

The color as a string or an array of [r, g, b, a] value to be applied to the point.

Example

// Color points based on a value of the `pointColorBy` column
pointColorByFn: (value: number) => value > 10 ? 'red' : '#00ff00'
 
// Color points based on the index of the point
pointColorByFn: (value: number, index: number) => index % 2 === 0 ? 'red' : '#00ff00'
 
// Color points using RGBA values
pointColorByFn: (value: unknown) => [255, 0, 0, 1]

Inherited from

CosmographPointsConfig.pointColorByFn


pointColorPalette?

optional pointColorPalette: string[]

An optional array of color strings that can be used to color the points in the visualization. If provided, the points will be colored using the colors in this palette, cycling through the array as needed.

Used when pointColorStrategy is set to 'categorical', 'continuous', or 'degree'.`

Inherited from

CosmographPointsConfig.pointColorPalette


pointColorByMap?

optional pointColorByMap: Record<string, string | [number, number, number, number]>

An optional mapping of values to colors for the points in the visualization. The keys in the map should be string and the values can be either color strings or arrays of RGBA values.

Used when pointColorStrategy is set to 'map'.

Default

undefined

Example

pointColorByMap: {
  'active': '#ff0000', // string key with hex color
  '42': [255, 0, 0, 1], // number key with RGBA array
  'true': 'red'  // boolean key with css-valid color
}

Inherited from

CosmographPointsConfig.pointColorByMap


pointColorStrategy?

optional pointColorStrategy: "map" | "categorical" | "continuous" | "degree" | "preciseDegree" | "linkDirection" | "direct" | "single"

Specifies the strategy for coloring points based on data from the pointColorBy column.

When undefined (default), will automatically use the optimal strategy based on the input configuration and color data type. Current strategy can be acquired with Cosmograph.activePointColorStrategy getter.

See PointColorStrategy for available strategies and their documentation.

Inherited from

CosmographPointsConfig.pointColorStrategy


pointSizeBy?

optional pointSizeBy: string

The column name that should contain numeric values to be used for the point size and label weight (if labels enabled). If provided, points will be sized based on the values in this column.

Inherited from

CosmographPointsConfig.pointSizeBy


pointSizeStrategy?

optional pointSizeStrategy: "auto" | "degree" | "preciseDegree" | "direct" | "single"

Specifies the strategy for sizing points based on data from the pointSizeBy column.

When undefined (default), will automatically use the optimal strategy based on the input configuration and size data type. Current strategy can be acquired with Cosmograph.activePointSizeStrategy getter.

See PointSizeStrategy for available strategies and their documentation.

Inherited from

CosmographPointsConfig.pointSizeStrategy


pointSizeRange?

optional pointSizeRange: [number, number]

Defines the range for automatic point size scaling. Takes [min, max] values in pixels.

When pointSizeBy column contains numeric values, they will be automatically remapped to fit within this range to prevent oversized points.

Used when pointSizeStrategy is set to 'auto' or 'degree'.

Default

[2, 9]

Inherited from

CosmographPointsConfig.pointSizeRange


pointSizeByFn?

optional pointSizeByFn: SizeAccessorFn<number> | SizeAccessorFn<string> | SizeAccessorFn<boolean> | SizeAccessorFn<unknown>

Function that generates sizes for points based on values in the pointSizeBy column.

Overrides the values in pointSizeBy column by processing them (values can be of any type, not just numbers).

Has effect only when pointSizeBy is provided and pointSizeStrategy is undefined.

See

pointSizeStrategy

Example

// Size points based on a value of the `pointSizeBy` column
pointSizeByFn: (value: boolean) => value ? 8 : 4
 
// Size points based on the index
pointSizeByFn: (value: unknown, index: number) => index % 2 === 0 ? 8 : 4
 
// Size points using a calculation
pointSizeByFn: (value: number) => Math.min(value * 2, 10)

Inherited from

CosmographPointsConfig.pointSizeByFn


pointClusterBy?

optional pointClusterBy: string

Column name containing cluster assignments for points. Can be string or number.

Remarks

Cosmograph will automatically generate a mapping of cluster values to their indices that will be available in the clusterMapping getter.

Inherited from

CosmographPointsConfig.pointClusterBy


pointClusterByFn()?

optional pointClusterByFn: (value, index?) => unknown

Function that generates cluster assignments for points based on values in the pointClusterBy column.

Overrides the values in pointClusterBy column by processing them.

Has effect only when pointClusterBy is provided.

Parameters

ParameterType
valueany
index?number

Returns

unknown

Example

pointClusterByFn: (value: string) => value.length

Inherited from

CosmographPointsConfig.pointClusterByFn


pointClusterStrengthBy?

optional pointClusterStrengthBy: string

The pointClusterStrengthBy column defines how strongly each point is attracted to its assigned cluster during the simulation.

The column should contain numeric values where higher values (closer to 1.0) = stronger attraction, point stays closer to its cluster, Lower values (closer to 0.0) = weaker attraction, point can move more freely away from its cluster

Has effect only when pointClusterBy is provided.

Inherited from

CosmographPointsConfig.pointClusterStrengthBy


pointLabelBy?

optional pointLabelBy: string

The column name for the point label.

Inherited from

CosmographPointsConfig.pointLabelBy


pointLabelWeightBy?

optional pointLabelWeightBy: string

Specify the numeric column that will be used for the point label weight. Higher weight values make labels more likely to be shown.

If not provided, the points labels will be sorted by pointSizeBy if provided or their total links count (degree) otherwise .

Inherited from

CosmographPointsConfig.pointLabelWeightBy


pointXBy?

optional pointXBy: string

The column name for the point’s x-coordinate. If provided with pointYBy, points will be positioned based on the values from pointXBy and pointYBy columns.

Inherited from

CosmographPointsConfig.pointXBy


pointYBy?

optional pointYBy: string

The column name for the point’s y-coordinate. If provided with pointXBy, points will be positioned based on the values from pointXBy and pointYBy columns.

Inherited from

CosmographPointsConfig.pointYBy


pointIncludeColumns?

optional pointIncludeColumns: string[]

An array of additional column names to include in the point data.

These columns will be available on the point objects but not used by Cosmograph directly, can be used as accessors for Cosmograph components. Useful for storing additional information about the points.

Inherited from

CosmographPointsConfig.pointIncludeColumns


linkSourceBy?

optional linkSourceBy: string

The column name to use as the source for links.


linkTargetsBy?

optional linkTargetsBy: string[]

The column names to use as the targets for links.


outputFilename?

optional outputFilename: string

The filename to use for the output points data. Has impact only when CosmographDataPrepConfig is passed into downloadCosmographData.


csvParseTimeFormat?

optional csvParseTimeFormat: string

The time format to use when parsing CSV data. Has impact only when source data is CSV.


csvColumnTypesMap?

optional csvColumnTypesMap: Record<string, string>

A mapping of column names to data types for CSV parsing. Has impact only when source data is CSV.


pointDefaultColor?

optional pointDefaultColor: string | [number, number, number, number]

The default color to use for points when no point colors are provided, or if the color value in the array is undefined or null. This can be either a hex color string (e.g., ‘#b3b3b3’) or an array of RGBA values in the format [red, green, blue, alpha] where each value is a number between 0 and 255. Default value: ‘#b3b3b3’

Inherited from

GraphConfigInterface.pointDefaultColor


pointGreyoutOpacity?

optional pointGreyoutOpacity: number

Opacity value for points when they are greyed out (when selection is active). Values range from 0 (completely transparent) to 1 (fully opaque).

If defined, this value will override the alpha/opacity component of pointGreyoutColor.

Default value: undefined

Inherited from

GraphConfigInterface.pointGreyoutOpacity


pointDefaultSize?

optional pointDefaultSize: number

The default size value to use for points when no point sizes are provided or if the size value in the array is undefined or null. Default value: 4

Inherited from

GraphConfigInterface.pointDefaultSize


pointSizeScale?

optional pointSizeScale: number

Scale factor for the point size. Default value: 1

Inherited from

GraphConfigInterface.pointSizeScale