【发布时间】:2016-12-27 00:05:36
【问题描述】:
在我的自定义 Power BI 代码中,我使用了“数据颜色”选项。我正在推动数据点进一步使用,如下所示:
this.dataPoints.push({
category: String(categories.values[index]),
value: Number(dataValues.values[index]),
color: getCategoricalObjectValue<Fill>(categories, index, 'colorSelector', 'fill', defaultColor).solid.color,
selectionId: this.host.createSelectionIdBuilder().withCategory(categories, index).createSelectionId()
})
我使用了包含getCategoricalObjectValue 函数定义的帮助文件。函数定义如图:
export function getCategoricalObjectValue<T>(category: DataViewCategoryColumn, index: number, objectName: string, propertyName: string, defaultValue: T): T {
let categoryObjects = category.objects;
if (categoryObjects) {
let categoryObject: DataViewObject = categoryObjects[index];
if (categoryObject) {
let object = categoryObject[objectName];
if (object) {
let property: T = object[propertyName];
if (property !== undefined) {
return property;
}
}
}
}
return defaultValue;
}
我面临getCategoricalObjectValue 函数的问题,其中category.objects 总是未定义,无论何时从格式菜单更改颜色。
我需要帮助来解决上述问题。我使用的所有代码都基于https://github.com/Microsoft/PowerBI-visuals 上给出的条形图示例
【问题讨论】:
标签: node.js typescript powerbi powerbi-embedded