private clearIncorrectSelection()

in src/WordCloud.ts [1503:1542]


    private clearIncorrectSelection(dataView: DataView): void {
        let categories: DataViewCategoryColumn[],
            identityKeys: string[],
            oldIdentityKeys: string[] = this.oldIdentityKeys;

        categories = dataView
            && dataView.categorical
            && dataView.categorical.categories;

        identityKeys = categories
            && categories[0]
            && categories[0].identity
            && categories[0].identity.map((identity: CustomVisualOpaqueIdentity) => JSON.stringify(identity));

        this.oldIdentityKeys = identityKeys;

        if (oldIdentityKeys && oldIdentityKeys.length > identityKeys.length) {
            this.valueSelectionManager.clear(false);

            return;
        }

        if (!lodash.isEmpty(identityKeys)) {
            let incorrectValues: SelectionIdValues<string>[] = this.valueSelectionManager
                .getSelectionIdValues
                .filter((idValue: SelectionIdValues<string>) => {
                    return idValue.selectionId.some((selectionId: ISelectionId) => {
                        return lodash.includes(identityKeys, selectionId.getKey());
                    });
                });

            incorrectValues.forEach((value: SelectionIdValues<string>) => {
                this.valueSelectionManager
                    .selectedValues
                    .splice(this.valueSelectionManager
                        .selectedValues
                        .indexOf(value.value), 1);
            });
        }
    }