import powerbiVisualsApi from "powerbi-visuals-api" ; import * as lodash from "lodash" ; import DataView = powerbiVisualsApi . DataView ; import DataViewValueColumns = powerbiVisualsApi . DataViewValueColumns ; import DataViewCategoryColumn = powerbiVisualsApi . DataViewCategoryColumn ; import DataViewCategorical = powerbiVisualsApi . DataViewCategorical ; import PrimitiveValue = powerbiVisualsApi . PrimitiveValue ; import DataViewValueColumn = powerbiVisualsApi . DataViewValueColumn ; import DataViewCategoricalColumn = powerbiVisualsApi . DataViewCategoricalColumn ; export class WordCloudColumns < T > { public static GET_CATEGORICAL_VALUES ( dataView ) { let categorical = dataView && dataView . categorical , categories = categorical && categorical . categories || [ ] , values = < DataViewValueColumns > ( categorical && categorical . values || [ ] ) , series = categorical && values . source && this . GET_SERIES_VALUES ( dataView ) ; return categorical && lodash . mapValues ( < any > new this < DataViewCategoryColumn [ ] > ( ) , ( n , key ) => { return ( < any [ ] > lodash . toArray ( categories ) ) . concat ( < any [ ] > lodash . toArray ( values ) ) . filter ( ( column ) => column . source . roles && column . source . roles [ key ] ) . map ( ( column ) => column . values ) [ 0 ] || values . source && values . source . roles && values . source . roles [ key ] && series ; } ) ; } public static GET_SERIES_VALUES ( dataView ) { return dataView && dataView . categorical && dataView . categorical . values && dataView . categorical . values . map ( ( column ) => { return column . source . groupName !== undefined ? column . source . groupName : column . source . queryName ; } ) ; } public static GET_CATEGORICAL_COLUMNS ( dataView ) { let categorical = dataView && dataView . categorical , categories = categorical && categorical . categories || [ ] , values = < DataViewValueColumns > ( categorical && categorical . values || [ ] ) ; return categorical && lodash . mapValues ( < any > ( new this < DataViewCategoryColumn > ( ) ) , ( n , key ) => { return categories . filter ( ( column ) => column . source . roles && column . source . roles [ key ] ) [ 0 ] || values . source && values . source . roles && values . source . roles [ key ] && values || values . filter ( ( column ) => column . source . roles && column . source . roles [ key ] ) ; } ) ; } public Category ? : T = null ; public Values ? : T = null ; public Excludes ? : T = null ; }