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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Anonymous
Not applicable

Visuals interactions

Hi,

I need to create a visual that knows when the same category has been selected in another visual. But I am lost : (

interactions.png

 

 

I have tried to follow this tutorial.

https://docs.microsoft.com/es-es/power-bi/developer/visuals/selection-api#select-datapoints-to-slice...

 

But I don't know if the information is updated and completed.


1. First problem

According to the tutorial:

 

private host: IVisualHost;
private selectionManager: ISelectionManager;

constructor(options: VisualConstructorOptions) {
        this.host = options.host;
        // ...
        this.selectionManager = this.host.createSelectionManager();
    }

 


I try:

 

...
import IVisualHost = powerbi.extensibility.IVisualHost;
import ISelectionManager = powerbi.extensibility.ISelectionManager;
...

 constructor(options: VisualConstructorOptions) {

    this.host = options.host;
    this.selectionManager = this.host.createSelectionManager();

 

 

But, tslinter:

Property 'createSelectionManager' does not exist on type 'IVisualHost'


Then, in the update

 

    const selection: ISelectionId = this.host.createSelectionIdBuilder()
            .withTable(options.dataViews[0].table, 1)
            .createSelectionId();

 


But
Property 'createSelectionIdBuilder' does not exist on type 'IVisualHost'

Please, does anyone know any updated reference where it is explained how to interrelate visuals (table mode)

Ty in advance

1 ACCEPTED SOLUTION
dm-p
Super User
Super User

Hi @Anonymous,

Sorry to hear you're having trouble. However, please try to post more complete code, as it is difficult to reproduce your issue if we don't have the complete picture and can only guess at how we can help.

It is difficult to be 100% certain this is the correct solution, but I'll go with my gut. I'm pretty sure that you might not have added the class properties from the tutorial you have quoted.

From your code snippet, it looks like you've imported the references for IVisualHost and ISelectionManager, but you need to make class properties for host and selectionManager, otherwise you cannot use them in either the constructor or update methods, and this is likely why the TS compiler is getting upset.

Please ensure that you add the following between the class declaration and the constructor method:

 

 

private host: IVisualHost;
private selectionManager: ISelectionManager;

 

 

This way, your properties should be visible to the class's internal methods and you can assign/utilise them as needed. [Further reading]

Again, it's hard to confirm completely without further context, but your approach to selection ID generation after this looks like it might be okay.

If you do have all this set up correctly, please post your full code somewhere - ideally as a repo or Gist on GitHub or somewhere similar - and we can take a more detailed look. Please include any other relevant details such as your capabilities and settings files. If you can't share your whole project, please create a minimal visual that reproduces the issue and we can focus on those areas and get you up and running.

Good luck!

Daniel





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!


My course: Introduction to Developing Power BI Visuals


On how to ask a technical question, if you really want an answer (courtesy of SQLBI)




View solution in original post

3 REPLIES 3
Anonymous
Not applicable

dm-p
Super User
Super User

Hi @Anonymous,

Sorry to hear you're having trouble. However, please try to post more complete code, as it is difficult to reproduce your issue if we don't have the complete picture and can only guess at how we can help.

It is difficult to be 100% certain this is the correct solution, but I'll go with my gut. I'm pretty sure that you might not have added the class properties from the tutorial you have quoted.

From your code snippet, it looks like you've imported the references for IVisualHost and ISelectionManager, but you need to make class properties for host and selectionManager, otherwise you cannot use them in either the constructor or update methods, and this is likely why the TS compiler is getting upset.

Please ensure that you add the following between the class declaration and the constructor method:

 

 

private host: IVisualHost;
private selectionManager: ISelectionManager;

 

 

This way, your properties should be visible to the class's internal methods and you can assign/utilise them as needed. [Further reading]

Again, it's hard to confirm completely without further context, but your approach to selection ID generation after this looks like it might be okay.

If you do have all this set up correctly, please post your full code somewhere - ideally as a repo or Gist on GitHub or somewhere similar - and we can take a more detailed look. Please include any other relevant details such as your capabilities and settings files. If you can't share your whole project, please create a minimal visual that reproduces the issue and we can focus on those areas and get you up and running.

Good luck!

Daniel





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!


My course: Introduction to Developing Power BI Visuals


On how to ask a technical question, if you really want an answer (courtesy of SQLBI)




Hi all I'm trying to add interactions for my custom visual , But I'm facing some issues in my visual.ts 

 

I've used R script to create my custom visual table,To add interactions in visual.ts i'm facing issues with these statements

 

 private hostIVisualHost;
 private selectionManagerISelectionManager;
 
Cannot find name 'IVisualHost'
'selectionManager' is declared but its value is never read
 
     for (let i = 0len = Math.max(category.values.lengthdataValue.values.length); i < leni++) {
            const colorstring = getColumnColorByIndex(categoryicolorPalette);
    
            const selectionIdISelectionId = host.createSelectionIdBuilder()
                .withCategory(categoryi)
                .createSelectionId();
    }
In this loop I'm facing a lot of issues,
 
 
Thanks in advance.

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.

Top Kudoed Authors