module powerbi . extensibility . visual { interface VisualSettingsTreeParams { show : boolean ; maxDepth : string ; minBucket : string ; } interface VisualSettingsOptParams { show : boolean ; complexity : string ; xval : string ; maxNumAttempts : string ; } interface VisualSettingsAdditionalParams { show : boolean ; showWarnings : boolean ; showInfo : boolean ; } export class Visual implements IVisual { private imageDiv : HTMLDivElement ; private imageElement : HTMLImageElement ; private settings_tree_params : VisualSettingsTreeParams ; private settings_opt_params : VisualSettingsOptParams ; private settings_additional_params : VisualSettingsAdditionalParams ; public constructor ( options ) { this . imageDiv = document . createElement ( 'div' ) ; this . imageDiv . className = 'rcv_autoScaleImageContainer' ; options . element . appendChild ( this . imageDiv ) ; this . imageElement = document . createElement ( 'img' ) ; this . imageElement . className = 'rcv_autoScaleImage' ; this . imageDiv . appendChild ( this . imageElement ) ; this . settings_tree_params = < VisualSettingsTreeParams > { show : false , maxDepth : "15" , minBucket : "2" , } ; this . settings_opt_params = < VisualSettingsOptParams > { show : false , complexity : "1e-5" , xval : "auto" , maxNumAttempts : "10" } ; this . settings_additional_params = < VisualSettingsAdditionalParams > { show : false , showWarnings : true , showInfo : true , } ; } public update ( options ) { let dataViews = options . dataViews ; if ( ! dataViews || dataViews . length === 0 ) return ; let dataView = dataViews [ 0 ] ; if ( ! dataView || ! dataView . metadata ) return ; this . settings_tree_params = < VisualSettingsTreeParams > { show : getValue < boolean > ( dataView . metadata . objects , 'settings_tree_params' , 'show' , false ) , maxDepth : getValue < string > ( dataView . metadata . objects , 'settings_tree_params' , 'maxDepth' , "15" ) , minBucket : getValue < string > ( dataView . metadata . objects , 'settings_tree_params' , 'minBucket' , "2" ) , } ; this . settings_opt_params = < VisualSettingsOptParams > { show : getValue < boolean > ( dataView . metadata . objects , 'settings_opt_params' , 'show' , false ) , complexity : getValue < string > ( dataView . metadata . objects , 'settings_opt_params' , 'complexity' , "1e-5" ) , xval : getValue < string > ( dataView . metadata . objects , 'settings_opt_params' , 'xval' , "auto" ) , maxNumAttempts : getValue < string > ( dataView . metadata . objects , 'settings_opt_params' , 'maxNumAttempts' , "10" ) , } ; this . settings_additional_params = < VisualSettingsAdditionalParams > { show : getValue < boolean > ( dataView . metadata . objects , 'settings_additional_params' , 'show' , false ) , showWarnings : getValue < boolean > ( dataView . metadata . objects , 'settings_additional_params' , 'showWarnings' , true ) , showInfo : getValue < boolean > ( dataView . metadata . objects , 'settings_additional_params' , 'showInfo' , true ) } ; let imageUrl = null ; if ( dataView . scriptResult && dataView . scriptResult . payloadBase64 ) { imageUrl = "data:image/png;base64," + dataView . scriptResult . payloadBase64 ; } if ( imageUrl ) { this . imageElement . src = imageUrl ; } else { this . imageElement . src = null ; } this . onResizing ( options . viewport ) ; } public onResizing ( finalViewport ) { this . imageDiv . style . height = finalViewport . height + 'px' ; this . imageDiv . style . width = finalViewport . width + 'px' ; } public enumerateObjectInstances ( options ) { let objectName = options . objectName ; let objectEnumeration = [ ] ; switch ( objectName ) { case 'settings_tree_params' : objectEnumeration . push ( { objectName : objectName , properties : { show : this . settings_tree_params . show , maxDepth : this . settings_tree_params . maxDepth , minBucket : this . settings_tree_params . minBucket , } , selector : null } ) ; break ; case 'settings_opt_params' : objectEnumeration . push ( { objectName : objectName , properties : { show : this . settings_opt_params . show , complexity : this . settings_opt_params . complexity , xval : this . settings_opt_params . xval , maxNumAttempts : this . settings_opt_params . maxNumAttempts } , selector : null } ) ; break ; case 'settings_additional_params' : objectEnumeration . push ( { objectName : objectName , properties : { show : this . settings_additional_params . show , showWarnings : this . settings_additional_params . showWarnings , showInfo : this . settings_additional_params . showInfo , } , selector : null } ) ; break ; } ; return objectEnumeration ; } } }