import powerbi from "powerbi-visuals-api" ; import ISelectionId = powerbi . visuals . ISelectionId ; import DataViewCategoryColumn = powerbi . DataViewCategoryColumn ; import DataViewMatrix = powerbi . DataViewMatrix ; import DataViewMatrixNode = powerbi . DataViewMatrixNode ; import ISelectionIdBuilder = powerbi . visuals . ISelectionIdBuilder ; import IVisualHost = powerbi . extensibility . visual . IVisualHost ; export class SelectionIdBuilder { private visualHost : IVisualHost ; private matrix : DataViewMatrix ; private matrixDataArray : DataViewMatrixNode [ ] = [ ] ; private builder : ISelectionIdBuilder ; constructor ( IVisualHost , matrix ) { this . visualHost = IVisualHost ; this . matrix = matrix ; this . getMatrixArray ( this . matrix . rows . root ) ; this . matrixDataArray . shift ( ) ; } private getMatrixArray ( node ) { this . matrixDataArray . push ( node ) ; if ( node . children ) { node . children . forEach ( child => this . getMatrixArray ( child ) ) ; } } public createSelectionId ( index ) { debugger ; return this . visualHost . createSelectionIdBuilder ( ) . withMatrixNode ( this . matrixDataArray [ index ] , this . matrix . rows . levels ) . createSelectionId ( ) ; } }