Forum Discussion

12 Replies

  • Re: Does anybody know how to translate Javascript to Typescript?

    AFAIK there's no magical tool [nor formula...] allowing you to really sort of "reverse back the engine process".
    That is, converting JavaScript transpilled code result back to it's original TypeScript state.


    First you have to consider the fact that TypeScript is a superset of JavaScript, which means that the original code
    you would write in TypeScript is meant to be transpiled in JavaScript and NOT the other way around.

    You could of course try modifying the .js extension to .ts  -as pointed in the link - and then refactor code manually piece-by-piece. Personally I would rather suggest investing some time learning TypeScript as it will be much more rewarding option in the end.


    RE: d3js-orgchart
    That's an interesting sample which may worth taking a look at. The code uses php getPositions.php function to generate json but that's okay as result... I used a mock json and came with similar result.

     

    To be honnest, I haven't really found much existing custom components that actually come near to what you're looking for unfortunately.  

    You can take a look at this one TreeViz

    One which I found real nice and interesting was the Breakdown Tree sample built during a contest.

     

    However it seems the author thought the coding approach was a bit deprecated and no longer met new PBI Visuals criterias. So he has decided to remove content from Github. :smileysad:
    Same thing for another one shown in following  Decomposition Tree video.  Link is broken :smileysad:
    Authors could have given access so we could have a peak under the hood. Who jnows we may have come with something where they left off... Anyway...

     

    So in conclusion, when dealing with creating custom Tree viz this leaves us 3 options:

    1st option -would be to create a new custom component "all from scratch" from the ground up in order to recreate a similar code logic in TypeScript.
    That may not be a profitable options unless of course you're confortable and proficient enough in combining TypeScript and d3.js.

    2nd option - would be taking an existing raw d3.js code and bring modification in order to adapt it to a Power BI Visuals context.
    Jon Gallant gave a good liquidFillGauge example  on How to Create a Power BI Custom Visual Based on an Existing d3 Visual 3 part series. That's a basic single data approach. Taking an existing Tree Viz raw d3.js code would avoid you writing everything from the ground up though hierarchic dataViewMapping and conversion wiring may still require a bit more work... 

     

    3rd options - is to use Visio pre-built orgchart tool. That may not be the best option as it's still in preview and will request
    hosting the Visio file either on OneDrive Business or on Sharepoint Server but still it's better than nothing. 

    • surfersamu's avatar
      surfersamu
      Helper II

      Thank you so much for pointing me to the right direction. Yeah I saw those breakdown trees from the competition. I've been sending messages but I don't get a reply lol.

       

      I found this over the weekend:

      https://codepen.io/thebard/pen/WjPQJL

       

      Looks pretty good but yeah I'm in the process of learning Typescript right now.

       

      I'm going with option 2. Thanks thats a good resource for me to start playing around. I think after that tutorial I could probably modify that TreeViz visual you gave me!

       

      I can't really use Vizio because the data is comming from an API so it wouldn't be practical to have to be creating Vizio diagrams and manually updating the tree.

       

      Thank you so much for your help I really appreciate it.

       

      I will keep you guys updated on this breakdown tree and I will create a repo so other people can use it in the future.

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

        What API version do you use? Have you tried to build your visual using API 1.7 (1.8)?

         

        Ignat Vilesov,

        Software Engineer

         

        Microsoft Power BI Custom Visuals

        [email protected]

  • Eric_Zhang's avatar
    Eric_Zhang
    Microsoft Employee

    surfersamu wrote:

    It would be awesome if someone could translate this:

     

    https://github.com/BernhardZuba/d3js-orgchart

     

    So we could use it as a custom visual.


    surfersamu

    Not an expert on Typescript, it seems your can do that in Visual studio, however manual effort is still required when converting, see Converting existing JavaScript code to TypeScript in Visual Studio. For more constructive advice, I'd suggest your ask help from the dedicated Typescript forum.

    • surfersamu's avatar
      surfersamu
      Helper II

      Yea I'm tyring to find tutorials on how to do graphics on Power BI but I've only found one on youtube with limited information :(