powerbi-custom-visuals - PowerBI Desktop 自定义视觉 - 存储问题
问题描述
我在 PowerBI 中为我的公司开发了 ISO 日历周的自定义过滤器。
它工作得很好,但我无法将当前过滤器保存到本地存储。它在发布时可以在网络上运行,但不能在桌面版本中运行。
import ILocalVisualStorageService = powerbi.extensibility.ILocalVisualStorageService;
constructor(options: VisualConstructorOptions){
this.storage = options.host.storageService;
}
在我的第一个更新周期中,我检查本地存储并在必要时进行设置。
//to get data in async function
let cache = await this.storage.get("filter");
//to set data in async function
await this.storage.set("filter", "xyz");
是否可以在桌面中使用本地存储?
亲切的问候
托拜厄斯
解决方案
您是否尝试联系 Power BI 视觉对象支持以激活本地存储 API,因为它默认未激活?
https://docs.microsoft.com/en-us/power-bi/developer/visuals/local-storage
或者,对于您的用例,使用persistProperties服务可能会更好。PBI Visuals 文档网站上关于此功能的文档很少,但您可以在 powerbi-visuals-sankey custom visual 中找到一个示例,它用于存储各种属性。
https://github.com/microsoft/powerbi-visuals-sankey
您的案例的粗略示例:
options.host.persistProperties({
VisualObjectInstance = {
objectName: "filterSetting",
selector: undefined,
properties: {
filter: "xyz"
}
};
});
触发 persistProperties 函数后,视觉对象触发更新,用持久属性填充 VisualUpdateOptions 的 options.dataViews.metadata.objects。请注意,您必须事先在 capabilities.json 中定义您的属性。
推荐阅读
- html - flexbox中的水平滚动溢出父级
- android-studio - 如何在连续模式下配置 ktlint gradle 插件?
- typescript - 加载前更改模块内的 VUE 组件
- lisp - 从文件中剪辑阅读列表并将其展平,但不工作,不将 lst 识别为列表
- php - Symfony/Doctrine:获取可用命令列表
- python - NameError:名称“缓冲区”未定义
- c# - ASP.NET Core:模态不会将值传递给控制器方法
- plot - 朱莉娅死于等高线图的创作
- arrays - 循环遍历 Numpy 数组和切片
- javascript - Google Charts - 组织结构图出现损坏