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
Nishantjain
Continued Contributor
Continued Contributor

SelectionID: MatrixNode - Selection based on hierarchy and not the node

Hi there, 
I have successfully built a custom visual using the dataviewmappings "matrix" and everything is working fine except the interaction. 

For example, my data is structure as 

2013

  - Jan

  - Feb

  - Mar

2014

  - Jan

  - Feb

  - Mar

 

When I select the child "Jan" for year 2013, the interaction is only for "Jan" but not for 2013 and it is showing Jan for both 2013 and 2014. I want the year to be filtered based on the child node selected. 

 

I have got the selectionid for all the nodes but they are not linked in a hierarchy. They are currently independent to each other. 

 

I have build the selectionId as below. This gives the selectionId for the each node

 

//obj is the node in the hierarchy

var selectionId: ISelectionId = host.createSelectionIdBuilder()
    .withMatrixNode(obj, levels)
    .createSelectionId();

I have built the interaction as below

if (this.host.allowInteractions) {
    const isCtrlPressed: boolean = (d3.event as MouseEvent).ctrlKey;
    //d3.select(nodes[i]).attr('fill-opacity', 1);
    this.selectionManager
        .select(d.selectionId, isCtrlPressed)
        .then((ids: ISelectionId[]) => {
            if (this.selectionManager.hasSelection() && !isCtrlPressed) {
                bars.attr('fill-opacity', 0.5);
            };
            d3.select(nodes[i]).attr('fill-opacity', 1);
        });
    (<Event>d3.event).stopPropagation();
}

 

Thanks

Nishant 

1 ACCEPTED SOLUTION
Nishantjain
Continued Contributor
Continued Contributor

@jprmsn mate, I gave up on this issue about an year ago, assuming there is some bug. I can't  believe this was so simple. Thanks a lot. Made my day

View solution in original post

4 REPLIES 4
jprmsn
Frequent Visitor

I think the issue is that the samples given for .withMatrixNode only set the selection to the particular row and not the full context including parent rows.

Anyone know how to do this?

jprmsn
Frequent Visitor

The answer is to do .withMatrixNode(...).withMatrixNode(...), etc.

A call for the row and a call for each parent, followed by createSelectionId will work.

Nishantjain
Continued Contributor
Continued Contributor

@jprmsn mate, I gave up on this issue about an year ago, assuming there is some bug. I can't  believe this was so simple. Thanks a lot. Made my day

Great.  Appreciate it if you could mark it as the solution.

John

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