Skip to content

Documentation / @ripl/charts / resolveColorBy

Function: resolveColorBy() ​

resolveColorBy<TData>(colorBy?): (item) => string | undefined

Defined in: charts/src/core/color.ts:26

Resolves a per-item color accessor (colorBy) into a function returning each item's color.

A property key reads that field, a function is passed through, and an absent accessor yields a function returning undefined so callers can fall back to the series color generator.

Type Parameters ​

Type ParameterDescription
TDataThe data-item type.

Parameters ​

ParameterTypeDescription
colorBy?keyof TData | ((item) => string)The colorBy accessor, or undefined when the chart has no per-item color.

Returns ​

A function mapping a data item to its color (or undefined).

(item) => string | undefined