Forum Discussion

tomdenby's avatar
tomdenby
Frequent Visitor
5 years ago

map data role to Variable in visual.ts

Hi  ,

 

Im trying to map a data role to a variable in Visual.ts.

 

I know how to create the data role but for some reason cant get it to map to a variable.

 

does anyone know of any simple tutorials or youtube videos that go through and explain the steps?

 

Thanks, 

 

Tom. 

5 Replies

    • tomdenby's avatar
      tomdenby
      Frequent Visitor

      thanks for your comment i will look into this further over the next week 

  • tomdenby 

     

    I am not sure what you want to capture in the variable, but when you want to know what data is added to a certain dataRole in your visuals you can look into the DataView.

     

    You can find the metadata-property there that contains all data-columns added to your visuals (dataView[0].metadata.columns). Each MetaDataColumn has a roles-proprty that contains a property with the name of the dataRole it has been added to.

     

    You also could use the DataViewUtils provided by Microsoft to get this information out of the DataView.

     

    I hope this will help you further developping your own visuals.

     

    Regards

     

    Paul

    • tomdenby's avatar
      tomdenby
      Frequent Visitor

      paul-maessen 

      thanks for your comment. i will look into this  more shortly. 

       

      just to add some more context what i would like to do is map the data value to a configuaration variable within the code as part of an API call to get authentication, it will always be a single value. rather than a table or values to display within the visual.  hope this helps 

      • paul-maessen's avatar
        paul-maessen
        Resolver I

        tomdenby 

         

        The problem with the custom visuals is that you only get one dataView returned. You can specify multiple dataViews but depending on the conditions you have set the API only returns one dataView.

         

        So if you only need one single value then it sould be part of the dataView you are using which can be a single Value but mostly is categorical, table or matrix. 

         

        So if you only provide a single Value for authentication you dont have other data for your visual πŸ™‚

        In this case it might be logical that your authentication value is part of your dataView and probably repeated in your table or values.

         

        Regards

         

        Paul