JavaScript & React libraryAPI

Interface: LabelsCosmographConfig

Extended by

Properties

showLabels?

optional showLabels: boolean

Whether to show labels (except hovered) on the Cosmograph canvas. When true, labels are visible only if pointLabelBy is provided. Default: false


showDynamicLabels?

optional showDynamicLabels: boolean

Show automatic labels for the evenly distributed points that are currently visible on the screen.

Works only when pointLabelBy is provided. Default: true


showLabelsFor?

optional showLabelsFor: string[]

An array of point ids to show labels for.

Works only when pointLabelBy is provided. Default: undefined


showTopLabels?

optional showTopLabels: boolean

Show labels for the top points. Works only when pointLabelBy is provided. Default: true


showTopLabelsLimit?

optional showTopLabelsLimit: number

Sets the maximum number of top points to show labels for. Default: 30


showClusterLabels?

optional showClusterLabels: boolean

Show labels for the clusters based on the pointClusterBy column. When any point is selected, cluster labels will be hidden until the selection is cleared.

Has effect only when pointClusterBy is provided. Default: false


pointLabelColor?

optional pointLabelColor: string

Specifies the CSS color to use for the point labels.

If undefined, label will be colored as point.


pointLabelFontSize?

optional pointLabelFontSize: number

Specifies the font size to use for the point labels.

@default: 13


clusterLabelFontSize?

optional clusterLabelFontSize: number

Specifies the font size to use for the cluster labels.

@default: 16


clusterLabelClassName?

optional clusterLabelClassName: string | (text, clusterIndex) => string

Specifies the CSS class to use for the cluster labels.

Param

The text of the label.

Param

The index of the cluster.

Returns

The CSS class/string to be applied to the cluster label. @default: 'background: #35374887; font-weight: 300; opacity: 0.9;'


scaleClusterLabels?

optional scaleClusterLabels: boolean

Whether to scale the cluster labels based on the number of points in the cluster. Default: true


usePointColorStrategyForClusterLabels?

optional usePointColorStrategyForClusterLabels: boolean

If true, cluster labels will acquire colors from the current point coloring strategy (pointColorStrategy). This can be useful when pointClusterBy and pointColorBy refer to the same data. Default: false


pointLabelFn()?

optional pointLabelFn: (value, index?) => string

Specifies the function that will be used to generate the labels based on pointLabelBy column. It should return a string.

Works only when pointLabelBy is provided. Overrides the values specified in pointLabelBy column by processing them.

Parameters

ParameterTypeDescription
valueunknownThe value from the pointLabelBy column.
index?numberThe index of the point.

Returns

string

Text of label.


pointLabelWeightFn()?

optional pointLabelWeightFn: (value, index?) => number

Specifies the function that will be used to generate the label weights. Should return a number between 0 and 1.

Works only when pointLabelWeightBy is provided. Overrides the values specified in pointLabelWeightBy column by processing them.

Parameters

ParameterTypeDescription
valueunknownValue from the pointLabelWeightBy column.
index?numberIndex of the point.

Returns

number

Label weight value to be applied to the point label.


pointLabelClassName?

optional pointLabelClassName: string | (text, pointIndexBy, pointIdBy?) => string

Specifies the CSS class to use for the point labels. This can either be a string specifying a fixed CSS class name or a function that returns a CSS class name based on the point index and optional point ID.

Remarks

When provided as a function, accepts:

Param

The text of the label.

Param

The index of the point.

Param

The optional ID of the point.

Returns

CSS class name to be applied to the point label.


staticLabelWeight?

optional staticLabelWeight: number

Specifies the weight of the static labels. Default: 0.8


dynamicLabelWeight?

optional dynamicLabelWeight: number

Specifies the weight of the dynamic labels. Default: 0.7


labelMargin?

optional labelMargin: number

Specifies the margin between the label and the point. Default: 5


labelPadding?

optional labelPadding: [number, number, number, number]

Specifies the [left, top, right, bottom] padding of the label element. Default: [6.5, 4.5, 6.5, 4.5]


customLabels?

optional customLabels: CosmographCustomLabel[]

Specifies an array of custom labels to be displayed on the Cosmograph canvas. Each custom label is defined by the CosmographCustomLabel type, which includes properties for the label text, position, weight and optional CSS class.


showFocusedPointLabel?

optional showFocusedPointLabel: boolean

Controls whether to show the label for the focused point.


showHoveredPointLabel?

optional showHoveredPointLabel: boolean

Whether to show a hovered point label. Default: false


hoveredPointLabelClassName?

optional hoveredPointLabelClassName: string | (text, pointIndexBy, pointIdBy?) => string

Specifies the CSS class to use for the hovered point label. This can either be a string specifying a fixed CSS class name or a function that returns a CSS class name based on the point index and optional point ID.

Param

The index of the point.

Param

The optional ID of the point.

Returns

The CSS class to be applied to the point label.