2

Is drillthrough supported in a Power BI Custom Visual?

enter image description here

If so, could you please provide a snippet of your visual.ts file to show how it's to be used? I've been searching for documentation on it and nothing has turned up - I'm beginning to think its not available for developers yet and only for the official visuals provided by Power BI.

G0BLiN
  • 905
  • 10
  • 18
FirstRedPepper
  • 452
  • 5
  • 20

2 Answers2

2

It seems like Drillthrough is not supported yet.

Response from Microsoft after posting question in forum: http://community.powerbi.com/t5/Developer/Use-Drillthrough-in-Custom-Visual/m-p/270240#M8199

FirstRedPepper
  • 452
  • 5
  • 20
  • Note to newcomers: support has been added in November 2018 - see my [answer] (https://stackoverflow.com/a/54666686/3892498) below – G0BLiN Feb 13 '19 at 09:30
0

Good news! As of API v2.2.0

Custom visuals now support drillthrough

The official developer blog mentions it in the Nov 2018 post.

To enable drillthrough, the visual just need to support Context Menu (detailed instructions in Adding Context-Menu to the Bar Chart). Once a context menu event is triggered on anything sending a dataPoint.selectionId, the menu will include a drillthrough option.

If you are using D3, and store your SVG as this.svg in your code, the basic code can look something like:

this.svg.on('contextmenu', () => {
  const mouseEvent: MouseEvent = d3.event as MouseEvent;
  const eventTarget: EventTarget = mouseEvent.target;
  let dataPoint = d3.select(eventTarget).datum();
  this.selectionManager.showContextMenu(dataPoint? dataPoint.selectionId : {}, {
    x: mouseEvent.clientX,
    y: mouseEvent.clientY
  });
  mouseEvent.preventDefault();
});

(copied from custom visuals official documentation - as linked above)

Note how the selection.id is passed in the selectionManager.showContextMenu() call - that's what enables drillthrough.


Disclaimer: I'm a Microsoft employee, working in one of Power BI development teams. This answer is posted based on my personal knowledge and experience, and is not endorsed or approved by Microsoft in any way.

Community
  • 1
  • 1
G0BLiN
  • 905
  • 10
  • 18
  • And if you are not using D3? Is there also a way to enable a context menu? – ChrisW Sep 21 '20 at 17:57
  • @ChrisW - `contextmenu` is a standard HTML element event (see e.g. MDN's documentation for [contextmenu event](https://developer.mozilla.org/en-US/docs/Web/API/Element/contextmenu_event)) - just in case you weren't aware, sorry if this was obvious ;). While the example above (from the official documentation) uses D3, it is not necessary - your code must perform 3 "tasks", implemented with/without any framework of your choice: 1. listen to `contextmenu` event. 2. On trigger, call `selectionManager.showContextMenu()`, providing mouse coordinates and optionally `selectionId'. 3. Prevent default. – G0BLiN Sep 22 '20 at 12:44