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

Data Days is here! Join us now for 60+ days of learning, challenges, and connection. Learn more

Reply
Anonymous
Not applicable

adding interaction to custom visual

i have created a histogram custom visual  to show summary statistics . but i can not add interaction to the visual . 

 

this is my visual.ts code 
can any one help me out . i will share my dataview also

 
here i share my visual.ts and capabilities files
 
Data view : 
 
"dataViewMappings": [
    {
      "scriptResult": {
        "dataInput": {
          "table": {
            "rows": {
              "select": [
                {
                  "for": {
                    "in": "UniqueID"
                  }
                },
                {
                  "for": {
                    "in": "Values"
                  }
                }
              ],
              "dataReductionAlgorithm": {
                "top": {}
              }
            }
          }
        },
 
2 REPLIES 2
Anonymous
Not applicable

thank you for your replay 
when i debuging my visual my visual.ts file  not receving my dataview. why it is so  

public update(options: VisualUpdateOptions😞 void {

        console.log('Visual update', options.dataViews);
        console.log('*****Work Area*****')
        console.log(options)
        console.log('*******************')
        debugger;


        if (!options ||
            !options.type ||
            !options.viewport ||
            !options.dataViews ||
            options.dataViews.length === 0 ||
            !options.dataViews[0]) {
            return;
        }

 
my table in options view is null

18.06.2024_11.41.50_REC.png
Anonymous
Not applicable

Hi  @Anonymous ,

 

Adding interactions to custom visual objects requires interaction permissions.

Start by defining a variable via options.host.hostCapabilities.allowInteractions as whether or not interaction permissions are allowed.

Try code like below:

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

For the ts file you provide, you can interact with the visual object in two ways, by selecting and filtering.

vyangliumsft_0-1718342633548.png

For more details, you can refer to below document:

Visual interactions in Power BI visuals - Power BI | Microsoft Learn

Power BI visual data point selections - Power BI | Microsoft Learn

 

Best Regards,

Liu Yang

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Helpful resources

Announcements
Fabric Data Days is here Carousel

Fabric Data Days 2026

Don't miss out on Data Days, June 15 through August 7. Learn Fabric, Power BI, SQL, AI and more.

May Power BI Update Carousel

Power BI Monthly Update - May 2026

Check out the May 2026 Power BI update to learn about new features.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

Top Kudoed Authors