与 power bi 相同的问题- 论坛 - 开发人员
我尝试使用我的矩阵自定义视觉创建选择,但这会在其他视觉上产生错误
这是我的转换,使用 builder withMatrixNode
function visualTransform(options: VisualUpdateOptions, host: IVisualHost): DataViewModel {
let dataViews = options.dataViews[0];
var rows = dataViews.matrix.rows;
let listSelectionId: DataListSelection[] = [];
let selectionIdBuilder = host.createSelectionIdBuilder();
rows.root.children.forEach(x => {
listSelectionId.push({
value: x.value,
selectionId: selectionIdBuilder.withMatrixNode(x, rows.levels).createSelectionId()
});
if (x.children)
x.children.forEach(z => {
listSelectionId.push({
value: z.value,
selectionId: selectionIdBuilder.withMatrixNode(z, rows.levels).createSelectionId()
});
if (z.children)
z.children.forEach(a => {
listSelectionId.push({
value: a.value,
selectionId: selectionIdBuilder.withMatrixNode(a, rows.levels).createSelectionId()
});
})
})
});
return {
dataPoints: listSelectionId
}
}
我已经添加了单击侦听器以获取选择 ID 并在管理器中选择它,这是控制台日志
我的选择代码有什么问题?还有一个问题,我已经在我的经理中声明了 selectcallback,但在其他视觉对象进行选择时从未调用过
this.selectionManager = this.host.createSelectionManager();
console.log('constructor allow interaction', this.host.allowInteractions);
this.selectionManager.registerOnSelectCallback(() => {
console.log('selection manager callback', this.selectionManager.getSelectionIds());
});
this.selectionIdBuilder = options.host.createSelectionIdBuilder();