remember Selection Lifecycle
Drives the background lifecycle of a ChartSelection:
Clears the selection when data reference changes between recompositions. The first composition never clears selection, so an
initialIndexprovided to rememberChartSelection is preserved.Clears the selection when itemCount becomes zero, or when the currently selected index is no longer in
0 until itemCount. The bounds check re-runs whenever the index or item count changes, so externalselection.select(...)calls that fall out of range are caught immediately.When lifetime is SelectionLifetime.AutoDeselect, renews the auto-clear timer on each new selection.
The helper never overrides gesture-driven selection or explicit clear() calls beyond the rules above. Density-mode (compact vs scrollable) reshuffles should be reported through itemCount when the source range changes; if the chart reshuffles renderData while preserving source indices, pass itemCount = Int.MAX_VALUE to skip the bounds check.
Parameters
The hoisted selection holder.
Stable identity key for the source data. Changing this reference clears selection.
Number of selectable items in the source data, or Int.MAX_VALUE to skip the bounds check.
Background policy. Defaults to SelectionLifetime.Persistent.
Restarts SelectionLifetime.AutoDeselect when its value changes. Pass null until automatic cleanup is armed.