in src/converter.ts [81:192]
public convert(): void {
this.dataPoints = [];
this.numberOfCategoriesSelectedInData = 0;
// If category exists, we render labels using category values. If not, we render labels
// using measure labels.
if (this.categoryValues) {
let objects = this.dataViewMetadata ? <any>this.dataViewMetadata.objects : undefined;
let isInvertedSelectionMode: boolean = false;
let numberOfScopeIds: number;
if (objects && objects.general && objects.general.filter) {
if (!this.identityFields) {
return;
}
let filter: SemanticFilter = <SemanticFilter>objects.general.filter;
}
let hasSelection: boolean = undefined;
if (this.dataViewCategorical.values) {
for (let idx: number = 0; idx < this.categoryValues.length; idx++) {
let selected = this.isCategoryColumnSelected(chicletSlicerProps.selectedPropertyIdentifier, this.category, idx);
if (selected != null) {
hasSelection = selected;
break;
}
}
}
let dataViewCategorical = this.dataViewCategorical,
value: number = -Infinity;
this.hasHighlights = false;
for (let categoryIndex: number = 0, categoryCount = this.categoryValues.length; categoryIndex < categoryCount; categoryIndex++) {
let categoryIsSelected: boolean = this.isCategoryColumnSelected(
chicletSlicerProps.selectedPropertyIdentifier,
this.category,
categoryIndex);
let selectable: boolean = true;
if (hasSelection != null) {
if (isInvertedSelectionMode) {
if (this.category.objects == null)
categoryIsSelected = undefined;
if (categoryIsSelected != null) {
categoryIsSelected = hasSelection;
} else if (categoryIsSelected == null) {
categoryIsSelected = !hasSelection;
}
} else {
if (categoryIsSelected == null) {
categoryIsSelected = !hasSelection;
}
}
}
if (categoryIsSelected) {
this.numberOfCategoriesSelectedInData++;
}
let categoryValue: any = this.categoryValues[categoryIndex],
categoryLabel: string = valueFormatter.format(categoryValue, this.categoryFormatString),
imageURL: string = '';
if (this.dataViewCategorical.values) {
// Series are either measures in the multi-measure case, or the single series otherwise
for (let seriesIndex: number = 0; seriesIndex < this.dataViewCategorical.values.length; seriesIndex++) {
let seriesData: any = dataViewCategorical.values[seriesIndex];
if (seriesData.values[categoryIndex] != null) {
value = <number>seriesData.values[categoryIndex];
if (seriesData.highlights) {
selectable = !(seriesData.highlights[categoryIndex] === null);
this.hasHighlights = true;
}
}
}
}
if (this.image) {
const uncheckedImageURL = this.image.values[categoryIndex] as string;
if (!/^(ftp|http|https):\/\/[^ "]+$/.test(uncheckedImageURL) &&
!/^data:image/.test(uncheckedImageURL)) {
imageURL = undefined;
} else {
imageURL = uncheckedImageURL;
}
}
let categorySelectionId: ISelectionId = this.host.createSelectionIdBuilder()
.withCategory(this.category, categoryIndex)
.createSelectionId();
this.dataPoints.push({
identity: categorySelectionId as powerbi.visuals.ISelectionId,
category: categoryLabel,
imageURL: imageURL,
value: value,
selected: false,
selectable: selectable
});
}
if (numberOfScopeIds != null && numberOfScopeIds > this.numberOfCategoriesSelectedInData) {
this.hasSelectionOverride = true;
}
}
}