ESM
import { getCategorySeriesSum, getSeriesPercentOfCategory, getSmallestPositiveFieldValue, getSmallestPositiveStacked100PercentContribution, isWebChartBinArray } from "@arcgis/charts-components/utils/data/index.js";

Functions

getCategorySeriesSum

Function

Sums finite series field values for a single category (data item). Shared by sorting percent calculation and stacked100 axis bounds. Persistence of technicalSortingFieldBySum for sorting is done by calculateSeriesPercent.

Signature
getCategorySeriesSum (dataItem: WebChartDataItem, yList: string[]): number

Parameters

ParameterTypeDescriptionRequired
dataItem

The category data item

yList
string[]

The series y field names to include

Returns
number

The sum of finite numeric values for the given fields

getSeriesPercentOfCategory

Function

Returns a series value as a fraction of its category total (0-1).

Signature
getSeriesPercentOfCategory (value: number, categoryTotal: number): number | undefined

Parameters

ParameterTypeDescriptionRequired
value

The series value for the category

categoryTotal

The sum of series values in the category

Returns
number | undefined

The series fraction of the category total (0-1), or undefined when it cannot be computed

getSmallestPositiveFieldValue

Function

Finds the smallest positive numeric value across the given field names in the chart data. Used when a logarithmic axis min resolves to 0 (or below) because zeros are present alongside tiny positives.

Signature
getSmallestPositiveFieldValue (dataItems: WebChartDataItem[], fieldNames: string[]): number | undefined

Parameters

ParameterTypeDescriptionRequired
dataItems

The chart data items

fieldNames
string[]

The field names to scan

Returns
number | undefined

The smallest positive value found, or undefined when none are found

getSmallestPositiveStacked100PercentContribution

Function

Finds the smallest positive 100%-stacked contribution (0-100) across categories and series. Matches amcharts valueYTotalPercent / valueXTotalPercent units used for stacked100 rendering. Uses getCategorySeriesSum for each category total.

Signature
getSmallestPositiveStacked100PercentContribution (props: { dataItems: WebChartDataItem[]; seriesConfig: WebChartSeriesType[]; filteredSeriesIds?: string[]; }): number | undefined

Parameters

ParameterTypeDescriptionRequired
props
{ dataItems: WebChartDataItem[]; seriesConfig: WebChartSeriesType[]; filteredSeriesIds?: string[]; }

The chart data items

Returns
number | undefined

The smallest positive percent contribution (0-100), or undefined when none are found

isWebChartBinArray

Function

Indicates whether a data array is a WebChartBin[].

Signature
isWebChartBinArray (data: WebChartBin[] | WebChartDataItem[]): data is WebChartBin[]

Parameters

ParameterTypeDescriptionRequired
data

The data array to test

Returns
data is WebChartBin[]