0

在我的自定义 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上给出的条形图示例

4

1 回答 1

0

问题在于已弃用的现有代码或实施最近发生了变化。

解决方案在下面提供的链接中给出: https ://github.com/Microsoft/PowerBI-visuals-sampleBarChart/issues/5

于 2016-12-26T16:05:36.843 回答