in src/interactivitySelectionService.ts [156:190]
protected select(dataPoints: SelectableDataPoint | SelectableDataPoint[], multiSelect: boolean): void {
const selectableDataPoints: SelectableDataPoint[] = [].concat(dataPoints);
const originalSelectedIds = [...<ISelectionId[]>this.selectionManager.getSelectionIds()];
if (!multiSelect || !selectableDataPoints.length) {
// if multiselect isn't active need to reset curent selections
// or clear selection by passing empty array of selection in dataPoints parameter
this.selectionManager.clear();
}
// array of selection of selected datapoints
const selectionIdsToSelect: ISelectionId[] = [];
selectableDataPoints.forEach((dataPoint: SelectableDataPoint) => {
if (!dataPoint || !dataPoint.identity) {
return;
}
const shouldDataPointBeSelected: boolean = !this.isDataPointSelected(dataPoint, originalSelectedIds);
// update state of datapoint, set as selected and acumulate selectionId in temp array
if (shouldDataPointBeSelected) {
dataPoint.selected = true;
selectionIdsToSelect.push(<ISelectionId>dataPoint.identity);
} else {
// set selection as false if datapoint isn't selected
dataPoint.selected = false;
if (multiSelect) {
selectionIdsToSelect.push(<ISelectionId>dataPoint.identity);
}
}
});
// if multiselect isn't active selection manager resets current state of selection and applies new selections
this.selectionManager.select(selectionIdsToSelect, multiSelect);
this.syncSelectionState();
}