in src/dataLabel/dataLabelUtils.ts [354:416]
export function enumerateDataLabels(
options: dataLabelInterfaces.VisualDataLabelsSettingsOptions): powerbi.VisualObjectInstance {
if (!options.dataLabelsSettings) {
return;
}
let instance: powerbi.VisualObjectInstance = {
objectName: "labels",
selector: options.selector,
properties: {},
};
if (options.show && options.selector) {
instance.properties["showSeries"] = options.dataLabelsSettings.show;
}
else if (options.show) {
instance.properties["show"] = options.dataLabelsSettings.show;
}
instance.properties["color"] = options.dataLabelsSettings.labelColor || defaultLabelColor;
if (options.displayUnits) {
instance.properties["labelDisplayUnits"] = options.dataLabelsSettings.displayUnits;
}
if (options.precision) {
let precision = options.dataLabelsSettings.precision;
instance.properties["labelPrecision"] = precision === defaultLabelPrecision ? null : precision;
}
if (options.position) {
instance.properties["labelPosition"] = options.dataLabelsSettings.position;
if (options.positionObject) {
instance.validValues = { "labelPosition": options.positionObject };
}
}
if (options.labelStyle) {
instance.properties["labelStyle"] = options.dataLabelsSettings.labelStyle;
}
if (options.fontSize) {
instance.properties["fontSize"] = options.dataLabelsSettings.fontSize;
}
if (options.labelDensity) {
let lineChartSettings = <any>options.dataLabelsSettings;
if (lineChartSettings) {
instance.properties["labelDensity"] = lineChartSettings.labelDensity;
}
}
// Keep show all as the last property of the instance.
if (options.showAll) {
instance.properties["showAll"] = options.dataLabelsSettings.showLabelPerSeries;
}
options.instances.push(instance);
return instance;
}