Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!

Reply
emma_s
Helper I
Helper I

Custom visual: should cross filtering occur automatically?

Hello, I have built a treemap visual. I am using Pbiviz v3.1. I have tooltips working via ISelectionID. I thought this meant that filtering of other graphics would work automatically (I'm sure it has in the past) but it isn't working. When I click on one block of the treemap (via the developer visual), it doesn't reduce the colour strength of the other blocks, and doesn't produce any filtering of other charts on the page.

 

Can someone just tell me if I'm right, in that cross filtering should work automatically, as long as ISelectionID is working? 

 

categories.values.forEach((item, index) => {
const selID: ISelectionId = host.createSelectionIdBuilder().withCategory(categories, index).createSelectionId();
treemapDataPoints.push({
category: <string>item,
selectionId: selID,
value: 0
});
})

 

I notice that when I hover over a standard graphics, the cursor is an arrow. With my custom treemap, the cursor is a hand. I don't know if this is significant!  

 

Thanks for any help

2 REPLIES 2
dm-p
Super User
Super User

Hi @emma_s,

Hopefully I'm understanding your challenge correctly. By default, all custom visuals will accept cross-filtered data from other visuals, slicers or page filters. This will restrict the available data in your dataView and does not require any further effort from your side.

If you are referring to highlighting - where your visual updates to only highlight partial data, or you want to click selectionId-bound objects in your visual to filter others - then no, this has never been enabled by default and has to be specifically coded into your visual.

The docs have a good starting point for this, using the sample bar chart repo.

Good luck!

Daniel





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!


My course: Introduction to Developing Power BI Visuals


On how to ask a technical question, if you really want an answer (courtesy of SQLBI)




HI @dm-p. Thanks for your reply. My problem was a bit different to what you thought. My graphic responded correctly to filtering from other graphics. But when I clicked the graphical elements of my graphic, they did not cause filtering in other graphics.

 

I had thought this was standard behaviour once I assigned a SelectionID to the graphical elements. It is not. For anyone wanting to build filtering into their custom visuals, search for selectionManager here: https://github.com/microsoft/PowerBI-visuals-sampleBarChart/blob/master/src/barChart.ts

 

You need to create and "register a callback" on the selectionManager in constructor(). Then you need an onclick event (as you would have in regular d3 or javascript) in the update() function, but in this case you need to reference the selectionManager within that event. There are many functions and references to be added to make this work. The bar chart code linked here gives you enough to work it out.

Helpful resources

Announcements
April AMA free

Microsoft Fabric AMA Livestream

Join us Tuesday, April 09, 9:00 – 10:00 AM PST for a live, expert-led Q&A session on all things Microsoft Fabric!

March Fabric Community Update

Fabric Community Update - March 2024

Find out what's new and trending in the Fabric Community.

Top Solution Authors
Top Kudoed Authors