Visual interactions in Power BI visuals

Sometimes you want to allow the user to interact with the visual by selecting, zooming, or clicking on it. Other times you want the visual to be static, so the user can't interact with the visual.

Visuals can query the value of the allowInteractions flag, which indicates if the visual allows visual interactions. For example, visuals can be interactive during report viewing or editing, but visuals can be non-interactive when they're viewed in a dashboard. These interactions include click, pan, zoom, selection, and others.

Note

Best practice is to enable tooltips in all scenarios, regardless of the indicated flag.

Set interactive permissions

The allowInteractions flag is passed as a boolean value during the initialization of the visual as a member of the IVisualHost interface.

For any Power BI scenario that requires non-interactive visuals (for example, dashboard tiles), set the allowInteractions flag to false. Otherwise (for example, Report), set allowInteractions to true.

The following code sample shows how to use the allowInteractions flag to set interactive permissions.

   ...
   let allowInteractions = options.host.hostCapabilities.allowInteractions;
   bars.on('click', function(d) {
       if (allowInteractions) {
           selectionManager.select(d.selectionId);
           ...
       }
   });

For more information about using the allowInteractions flag, see the SampleBarChart visual repository.

Visual API