in src/visual.ts [294:393]
public static CONVERTER(dataView: DataView, options: VisualUpdateOptions, visualHost: IVisualHost, colorHelper: ColorHelper): BulletChartModel {
let categorical: BulletChartColumns<
DataViewCategoryColumn & DataViewValueColumn[] & DataViewValueColumns
> = BulletChartColumns.GETCATEGORICALCOLUMNS(dataView);
if (!categorical || !categorical.Value || !categorical.Value[0]) {return null;}
let categoricalValues: BulletChartColumns<any[]> =
BulletChartColumns.GETCATEGORICALVALUES(dataView);
let settings: BulletchartSettings = BulletChart.parseSettings(dataView, colorHelper);
BulletChart.updateOrientation(settings);
BulletChart.limitProperties(settings);
let bulletModel: BulletChartModel = <BulletChartModel>{settings: settings, bars: [], barRects: [], valueRects: [], targetValues: [], viewportLength: BulletChart.zeroValue};
let verticalOrientation: boolean = settings.orientation.orientation === BulletChartOrientation.VerticalBottom
|| settings.orientation.orientation === BulletChartOrientation.VerticalTop;
let reversedOrientation: boolean = settings.orientation.orientation === BulletChartOrientation.HorizontalRight
|| settings.orientation.orientation === BulletChartOrientation.VerticalBottom;
bulletModel.labelHeight = (settings.labels.show || BulletChart.zeroValue) && parseFloat(PixelConverter.fromPoint(settings.labels.fontSize));
bulletModel.labelHeightTop = (settings.labels.show || BulletChart.zeroValue) && parseFloat(PixelConverter.fromPoint(settings.labels.fontSize)) / BulletChart.value1dot4;
bulletModel.spaceRequiredForBarHorizontally = Math.max(settings.axis.axis ? BulletChart.value60 : BulletChart.value28, bulletModel.labelHeight + BulletChart.value25);
bulletModel.viewportLength = Math.max(0, (verticalOrientation
? (options.viewport.height - bulletModel.labelHeightTop - BulletChart.SubtitleMargin - BulletChart.value25 - BulletChart.YMarginVertical * BulletChart.value2)
: (options.viewport.width - (settings.labels.show ? settings.labels.maxWidth : 0) - BulletChart.XMarginHorizontalLeft - BulletChart.XMarginHorizontalRight)) - BulletChart.ScrollBarSize);
bulletModel.hasHighlights = !!(categorical.Value[0].values.length > BulletChart.zeroValue && categorical.Value[0].highlights);
let valueFormatString: string = valueFormatter.getFormatStringByColumn(categorical.Value[0].source, true);
let categoryFormatString: string = categorical.Category ? valueFormatter.getFormatStringByColumn(categorical.Category.source, true) : BulletChart.emptyString;
let length: number = categoricalValues.Value.length;
for (let idx = 0; idx < length; idx++) {
let category: string = BulletChart.emptyString;
if (categorical.Category) {
category = valueFormatter.format(categoricalValues.Category[idx], categoryFormatString);
category = TextMeasurementService.getTailoredTextOrDefault( BulletChart.getTextProperties(category, settings.labels.fontSize), verticalOrientation ? this.MaxLabelWidth : settings.labels.maxWidth); }
let toolTipItems: BulletChartTooltipItem[] = [],
value = categoricalValues.Value[idx] || BulletChart.zeroValue;
toolTipItems.push({ value: value, metadata: categorical.Value[0], customName: settings.tooltips.valueCustomName });
let targetValue: number = categoricalValues.TargetValue ? categoricalValues.TargetValue[idx] : settings.values.targetValue;
if (lodashIsnumber(targetValue)) {
toolTipItems.push({ value: targetValue, metadata: categorical.TargetValue && categorical.TargetValue[0], customName: settings.tooltips.targetCustomName });}
let targetValue2: number = categoricalValues.TargetValue2 ? categoricalValues.TargetValue2[idx] : settings.values.targetValue2;
if (lodashIsnumber(targetValue2)) { toolTipItems.push({ value: targetValue2, metadata: categorical.TargetValue2 && categorical.TargetValue2[0], customName: settings.tooltips.target2CustomName });}
let minimum: number = BulletChart.GETRANGEVALUE(categoricalValues.Minimum ? categoricalValues.Minimum[idx] : undefined, settings.values.minimumPercent, targetValue);
let needsImprovement: number = BulletChart.GETRANGEVALUE(categoricalValues.NeedsImprovement ? categoricalValues.NeedsImprovement[idx] : undefined, settings.values.needsImprovementPercent, targetValue, minimum);
let satisfactory: number = BulletChart.GETRANGEVALUE(categoricalValues.Satisfactory ? categoricalValues.Satisfactory[idx] : undefined, settings.values.satisfactoryPercent, targetValue, minimum);
let good: number = BulletChart.GETRANGEVALUE(categoricalValues.Good ? categoricalValues.Good[idx] : undefined, settings.values.goodPercent, targetValue, minimum);
let veryGood: number = BulletChart.GETRANGEVALUE(categoricalValues.VeryGood ? categoricalValues.VeryGood[idx] : undefined, settings.values.veryGoodPercent, targetValue, minimum);
let maximum: number = BulletChart.GETRANGEVALUE(categoricalValues.Maximum ? categoricalValues.Maximum[idx] : undefined, settings.values.maximumPercent, targetValue, minimum);
let anyRangeIsDefined: boolean = [needsImprovement, satisfactory, good, veryGood].some(lodashIsnumber);
minimum = lodashIsnumber(minimum) ? minimum : BulletChart.zeroValue;
needsImprovement = lodashIsnumber(needsImprovement) ? Math.max(minimum, needsImprovement) : needsImprovement;
satisfactory = lodashIsnumber(satisfactory) ? Math.max(satisfactory, needsImprovement) : satisfactory;
good = lodashIsnumber(good) ? Math.max(good, satisfactory) : good;
veryGood = lodashIsnumber(veryGood) ? Math.max(veryGood, good) : veryGood;
let minMaxValue = lodashMax([minimum, needsImprovement, satisfactory, good, veryGood, value, targetValue, targetValue2].filter(lodashIsnumber));
maximum = lodashIsnumber(maximum) ? Math.max(maximum, minMaxValue) : minMaxValue;
veryGood = lodashIsnumber(veryGood) ? veryGood : maximum;
good = lodashIsnumber(good) ? good : veryGood;
satisfactory = lodashIsnumber(satisfactory) ? satisfactory : good;
needsImprovement = lodashIsnumber(needsImprovement) ? needsImprovement : satisfactory;
let scale: ScaleLinear<number, number> = (scaleLinear().clamp(true).domain([minimum, maximum]).range(verticalOrientation ? [bulletModel.viewportLength, 0] : [0, bulletModel.viewportLength]));
let firstScale: number = scale(minimum);
let secondScale: number = scale(needsImprovement);
let thirdScale: number = scale(satisfactory);
let fourthScale: number = scale(good);
let fifthScale: number = scale(veryGood);
let lastScale: number = scale(maximum);
let valueScale: number = scale(value);
let firstColor: string = settings.colors.minColor,
secondColor: string = settings.colors.needsImprovementColor,
thirdColor: string = settings.colors.satisfactoryColor,
fourthColor: string = settings.colors.goodColor,
lastColor: string = settings.colors.veryGoodColor,
firstFillColor: string = colorHelper.isHighContrast ? colorHelper.getThemeColor() : firstColor,
secondFillColor: string = colorHelper.isHighContrast ? colorHelper.getThemeColor() : secondColor,
thirdFillColor: string = colorHelper.isHighContrast ? colorHelper.getThemeColor() : thirdColor,
fourthFillColor: string = colorHelper.isHighContrast ? colorHelper.getThemeColor() : fourthColor,
lastFillColor: string = colorHelper.isHighContrast ? colorHelper.getThemeColor() : lastColor;
let highlight: any = categorical.Value[0].highlights && categorical.Value[0].highlights[idx] !== null;
let selectionIdBuilder = () => categorical.Category
? visualHost.createSelectionIdBuilder().withCategory(categorical.Category, idx)
: visualHost.createSelectionIdBuilder();
const minStrokeWidth: number = 0, maxStrokeWidthBars: number = 0.5, maxStrokeWidthValues: number = 1.5;
let barRectsStrokeWidth: number = colorHelper.isHighContrast ? maxStrokeWidthBars : minStrokeWidth,
valueRectsStrokeWidth: number = colorHelper.isHighContrast ? maxStrokeWidthValues : minStrokeWidth;
BulletChart.additems(anyRangeIsDefined, bulletModel, idx, firstScale, secondScale, firstFillColor, firstColor, thirdScale,
secondFillColor, secondColor, fourthScale, thirdFillColor, thirdColor, fifthScale, fourthFillColor,
fourthColor, lastScale, lastFillColor, lastColor, maxStrokeWidthBars, toolTipItems, highlight, selectionIdBuilder);
let bulletFillColor = colorHelper.isHighContrast ? colorHelper.getThemeColor() : settings.colors.bulletColor;
BulletChart.addItemToBarArray(bulletModel.valueRects, idx, firstScale, valueScale, bulletFillColor, settings.colors.bulletColor,
maxStrokeWidthValues, null, toolTipItems, selectionIdBuilder(), highlight);
let scaledTarget: number = scale(targetValue || BulletChart.zeroValue);
if (lodashIsnumber(scaledTarget)) {
bulletModel.targetValues.push({barIndex: idx, value: targetValue && scale(targetValue), fill: bulletFillColor, stroke: settings.colors.bulletColor, strokeWidth: maxStrokeWidthValues,
key: selectionIdBuilder().withMeasure(scaledTarget.toString()).createSelectionId().getKey(),
value2: targetValue2 && scale(targetValue2),
});} let xAxisProperties: IAxisProperties = BulletChart.getxaxisproperties(settings, bulletModel, scale, categorical, valueFormatString, verticalOrientation);
let bar1: BarData = { scale: scale, barIndex: idx, categoryLabel: category,
x: verticalOrientation ? (BulletChart.XMarginVertical + BulletChart.SpaceRequiredForBarVertically * idx) : (reversedOrientation ? BulletChart.XMarginHorizontalRight : BulletChart.XMarginHorizontalLeft),
y: verticalOrientation ? (BulletChart.YMarginVertical) : (BulletChart.YMarginHorizontal + bulletModel.spaceRequiredForBarHorizontally * idx),
xAxisProperties: xAxisProperties,
key: selectionIdBuilder().createSelectionId().getKey(),
}; bulletModel.bars.push(bar1);
} return bulletModel;}