Forum Discussion
popeadam
1 year agoNew Member
Context menu for visualisation that doesn't need it....
I have a visualisation which has no great need for a context menu other than to be consistent with other Power BI custom visuals. The visual does not use the d3 library, and I can't find a sample to ...
popeadam
1 year agoNew Member
Managed to resolve this using the d3 library:
import {select} from "d3";
export class Visual implements IVisual {
private selectionManager: ISelectionManager;
constructor(options: VisualConstructorOptions) {
this.selectionManager = options.host.createSelectionManager();
this.handleContextMenu();
}
private handleContextMenu() {
select(this.target).on("contextmenu", (event: MouseEvent) => {
this.selectionManager.showContextMenu({}, {
x: event.clientX,
y: event.clientY,
});
event.preventDefault();
});
}