in src/services/asterPlotConverterService.ts [253:371]
public getConvertedData(localizationManager: ILocalizationManager): AsterPlotData {
let categoryValue: any = this.categoricalValueColumns.Category,
category: DataViewCategoryColumn = this.categoricalColumns.Category,
values: number[] = <number[]>this.categoricalColumns.Y[0].values,
categoricalColumns: AsterPlotColumns<DataViewCategoryColumn & DataViewValueColumn[] & DataViewValueColumns> = this.categoricalColumns;
for (let i = 0; i < categoryValue.length; i++) {
let formattedCategoryValue = categoryValue[i],
currentValue = values[i];
let tooltipInfo: VisualTooltipDataItem[];
if (this.isMoreThanOneMeasure(categoricalColumns)) {
let secondMeasureValue: number = <number>categoricalColumns.Y[1].values[i];
tooltipInfo = this.buildTwoMeasuresTooltip(formattedCategoryValue, currentValue, secondMeasureValue, localizationManager);
currentValue += secondMeasureValue;
} else {
tooltipInfo = this.buildOneMeasureTooltip(formattedCategoryValue, currentValue, localizationManager);
}
let identity: powerbi.visuals.CustomVisualOpaqueIdentity = category.identity[i],
fillColor: string,
strokeColor: string,
strokeWidth: number,
sliceWidth: number;
if (category.objects && category.objects[i]) {
fillColor = this.colorHelper.getColorForMeasure(category.objects[i], "");
} else {
fillColor = this.colorHelper.getColorForMeasure(category.objects && category.objects[i], (<any>identity).identityIndex);
}
strokeColor = this.colorHelper.getHighContrastColor("foreground", fillColor);
strokeWidth = this.colorHelper.isHighContrast ? maxStrokeWidth : minStrokeWidth;
sliceWidth = Math.max(0, categoricalColumns.Y.length > 1 ? <number>categoricalColumns.Y[1].values[i] : 1);
let selectionId: ISelectionId = this.visualHost.createSelectionIdBuilder()
.withCategory(category, i)
.withMeasure(category.source.queryName)
.createSelectionId();
if (sliceWidth > 0) {
this.dataPoints.push({
sliceHeight: values[i] - this.minValue,
sliceWidth,
label: this.labelFormatter.format(<any>currentValue),
fillColor,
strokeColor,
strokeWidth,
identity: selectionId,
selected: false,
tooltipInfo,
labelFontSize: this.fontSizeInPx,
highlight: false,
categoryName: formattedCategoryValue
});
}
// Handle legend data
if (this.settings.legend.show) {
this.legendData.dataPoints.push({
label: formattedCategoryValue,
color: strokeColor,
// icon: LegendIcon.Box,
selected: false,
identity: selectionId
});
}
// Handle highlights
if (this.hasHighlights) {
let highlightValues: number[] = <number[]>this.categoricalColumns.Y[0].highlights,
isNotNull: boolean = highlightValues[i] != null;
currentValue = isNotNull
? <number>highlightValues[i]
: 0;
if (this.isMoreThanOneMeasure(categoricalColumns)) {
let secondMeasureValue: number = <number>categoricalColumns.Y[1].highlights[i] !== null ? <number>categoricalColumns.Y[1].highlights[i] : 0;
tooltipInfo = this.buildTwoMeasuresTooltip(formattedCategoryValue, currentValue, secondMeasureValue, localizationManager);
currentValue += secondMeasureValue;
} else {
tooltipInfo = this.buildOneMeasureTooltip(formattedCategoryValue, currentValue, localizationManager);
}
this.highlightedDataPoints.push({
sliceHeight: isNotNull ? highlightValues[i] - this.minValue : null,
sliceWidth: Math.max(0, (categoricalColumns.Y.length > 1 && categoricalColumns.Y[1].highlights[i] !== null) ? <number>categoricalColumns.Y[1].highlights[i] : sliceWidth),
label: this.labelFormatter.format(<any>currentValue),
fillColor,
strokeColor,
strokeWidth,
identity: selectionId,
selected: false,
tooltipInfo,
labelFontSize: this.fontSizeInPx,
highlight: true,
categoryName: formattedCategoryValue
});
}
}
return this.dataPoints.length
? {
dataPoints: this.dataPoints,
settings: this.settings,
hasHighlights: this.hasHighlights,
legendData: this.legendData,
highlightedDataPoints: this.highlightedDataPoints,
labelFormatter: this.labelFormatter,
centerText: category.source.displayName
}
: null;
}