The ultimate Fabric, Power BI, SQL, and AI community-led learning event. Save €200 with code FABCOMM.
Get registeredEnhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends September 15. Request your voucher.
I've encountered an issue when using the withTable selection with a map-based custom visual that I'm developing using Leaflet. The wrong row is selected when I create the selection in the custom visual. To demonstrate this, I put the same data passed to the custom visual in a native table visual.
When I click on the table visual, it shows a specific segment in the custom visual:
But when I click on the segment in the custom visual, it shows a different row in the table:
I am using the v2.6.0 of the API. Simplified code is below. What am I doing wrong?
capabilities.json
{
"dataRoles": [
{
"displayName": "Geometry (WKT)",
"kind": "Grouping",
"name": "geometry"
},
{
"displayName": "Volume Count",
"kind": "Measure",
"name": "count"
},
{
"displayName": "Tooltips",
"kind": "Grouping",
"name": "tooltips"
}
],
"dataViewMappings": [
{
"table": {
"rows": {
"select": [
{ "for": { "in": "geometry" } },
{ "for": { "in": "count" } },
{ "for": { "in": "tooltips" } }
]
}
}
}
]
}
visual.ts
public update(options: VisualUpdateOptions) {
const table = options.dataViews[0].table;
table.rows.forEach((row, index) => {
// Generate line geometry from data
const line = ...
// Selection
const selectionId = this.host.createSelectionIdBuilder()
.withTable(table, index)
.createSelectionId();
const polyline = L.polyline(line)
.on("click", () => { this.selectionManager.select(selectionId); })
.addTo(this.map);
});
}
Solved! Go to Solution.
I ended up switching to using a Basic Filter from the Visual Filters API instead of Selection and everything worked.
I ended up switching to using a Basic Filter from the Visual Filters API instead of Selection and everything worked.
I tried updating to the Visuals API 3.5.1, but I'm still encountering the same issue.
I also tried packaging the visual and trying it in Desktop, but still encountering the same issue.
An easier way to demonstrate is to duplicate the custom visual on the page. When I select the rows in one custom visual, the same number of rows is passed to the other custom visual, but not the same rows.
I tried investigating at the identityIndex from the selectionId.getKey(), but that seems like it's an index local to the visual itself.
Any ideas on what to investigate next?