Importing external Js libraries



  • Hi, first time using the forums. I have been searching thoroughly because it seems like a dumb question but I haven't find anything.

    I'm trying to test if i can import an external library and use it inside.

    <script type="text/javascript" src="https://d3js.org/d3.v5.js"></script>
    

    This doesn't work if I try to use it in a function below.

    function sum(sample) {
        return d3.sum(sample);
    }
    

    I think I can solve the problem loading the script manually or using the assets module, but I'd like to know if there is any way to get outside js and use them on reports or if just there isn't any and I'm stuck uploading all the libraries I use.

    Thanks!



  • Nevermind, discovered the hard way that document or any imports done in HTML only exists on the HTML universe so in the end I'd have to put the scripts inside <script> tags.

    At least I can use assets to modularize the application so that should work ok :)


Log in to reply
 

Looks like your connection to jsreport forum was lost, please wait while we try to reconnect.