Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
9 years ago

Custom visual with external library

I am trying to develop a custom visual using d3-hierarchy (https://github.com/d3/d3-hierarchy). I've installed both the library and the typings using npm into the node_modules folder, and added the files to the tsconfig.json and pbiviz.json.

 

When I try to import the module, both VS Code and the TS compiler complain that they can't find a module called d3-hierarchy. Strangely, I get auto complete in VS Code for the library.

 

How can I set up my environment so I can use d3-hierarchy?

 

6 Replies

  • If I am not wrong, you don't need to import the module.

    Just define lib in global dependencies in typings.json as it is done here for d3 .

    To use this library in your file , define variable with same name where ever you want to use this lib.

    • Anonymous's avatar
      Anonymous
      Not applicable

      Thank you for your answer. I don't understand yet what string I have to enter. I included a screenshot of my typings.json

       

      I've looked into the github repository, but the string for d3 doesn't match the repositories structure, so I'm at a bit of a loss here :/ 

    • kuldeep_kumar's avatar
      kuldeep_kumar
      Advocate I

      Adding typings is just for the sake, that you will get intellisense for respective methods in given object.

      If you don't need to have this, then you can directly go with solution as v-chuncz-msft mentioned.

  • v-viig's avatar
    v-viig
    Community Champion

    Hello Anonymous

     

    The current version of Power BI Visuals Tools don't support ES2015 (import/export) module system.

    In other words, you should use another type definisitions that doesn't use ES2015.

     

    Ignat Vilesov,

    Software Engineer

     

    Microsoft Power BI Custom Visuals

    [email protected]