Skip to content

Documentation / @ripl/charts / computeStackOffset

Function: computeStackOffset() ​

computeStackOffset<TSeries, TData>(series, current, item, getValue, currentIndex?): number

Defined in: charts/src/core/data.ts:109

Computes the stacked baseline offset for a series at a given data item. Positive and negative values stack independently so diverging stacks render correctly. Series earlier in the array sit closer to the baseline.

Type Parameters ​

Type Parameter
TSeries
TData

Parameters ​

ParameterTypeDescription
seriesTSeries[]The series that stack together, in stacking order.
currentTSeriesThe series to compute the offset for.
itemTDataThe data item being stacked.
getValue(series, item) => numberResolves a series' numeric value at a data item.
currentIndexnumbercurrent's index in series, when the caller already holds it. Defaults to an indexOf scan, which is quadratic when the offset is computed for every series in turn.

Returns ​

number