Forum Discussion
Custom visual: should cross filtering occur automatically?
Hi Anonymous,
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
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.