remember Selection Lifecycle
Drives the background lifecycle of a ChartSelection:
Clears the selection when data changes according to equality 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.
Source data key compared using equality. An unequal value clears selection; a new instance equal to the previous value preserves it.
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.