【问题标题】:Unable to set Data Colors from Format option in Power BI无法从 Power BI 中的“格式”选项设置数据颜色
【发布时间】: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


    【解决方案1】:

    问题在于已弃用的现有代码或最近的实现已更改。

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2020-10-20
      • 2021-06-19
      • 2020-06-03
      • 1970-01-01
      • 2022-08-03
      • 2021-01-03
      • 2023-03-18
      相关资源
      最近更新 更多