<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="https://www.aras.com/community/cfs-file/__key/system/syndication/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>including external js libs / Charts.js</title><link>https://www.aras.com/community/f/development/3815/including-external-js-libs-charts-js</link><description>Hi, Issue with version 11SP12:

 

Add a HTML field to the form with:

&amp;lt;script src=&amp;quot;../scripts/Test/Chart.min.js&amp;quot;&amp;gt;&amp;lt;/script&amp;gt;

&amp;lt;canvas id=&amp;quot;myChart&amp;quot; width=&amp;quot;400&amp;quot; height=&amp;quot;400&amp;quot;&amp;gt;&amp;lt;/canvas&amp;gt;

&amp;lt;script&amp;gt;
var ctx = document.getElementById(&amp;quot;myChart&amp;quot;).getContext(&amp;#39;2d</description><dc:language>ja-JP</dc:language><generator>Telligent Community 12</generator><item><title>RE: including external js libs / Charts.js</title><link>https://www.aras.com/community/thread/1790?ContentTypeID=1</link><pubDate>Wed, 25 Jul 2018 06:38:30 GMT</pubDate><guid isPermaLink="false">916d3f7e-8ddc-42f8-8d45-380822f51406:49555543-f2fb-4870-ab27-a252c5c3adf3</guid><dc:creator>Former Member</dc:creator><description>Perfect answer. Thank you so much, Eli

Yes, the issue was my JavaScript code is running before Chart.min.js gets loaded.

As suggested best practice, I have also moved my js code to Innovator/Client/javascript folder.

Also thanks for reference link to Workflow Timeline project, it is helpful.&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: including external js libs / Charts.js</title><link>https://www.aras.com/community/thread/1789?ContentTypeID=1</link><pubDate>Mon, 23 Jul 2018 16:21:50 GMT</pubDate><guid isPermaLink="false">916d3f7e-8ddc-42f8-8d45-380822f51406:e6d4c970-d37f-4cd4-af2b-65d7e2b2ebdb</guid><dc:creator>Eli Donahue</dc:creator><description>Hi ke,

It sounds like your JavaScript is running before Chart.min.js gets loaded. You can try wrapping your logic in a require block. I find that typically resolves these timing issues.
&lt;pre&gt;require([
    "../scripts/Test/Chart.min.js" 
], function(
    Chart
) {
    // this function contains all logic requiring Chart.min.js
    function loadChart() {
        var ctx = document.getElementById(&amp;quot;myChart&amp;quot;).getContext(&amp;#39;2d&amp;#39;);
        var myChart = new Chart(ctx, {...});
        
        // remaining chart logic here
    }

    // call the load chart function once Chart.min.js is loaded
    loadChart();
});&lt;/pre&gt;
You can see this approach used in several Aras Community Projects, like this method in the &lt;a href="https://github.com/ArasLabs/workflow-timeline/blob/master/Import/WorkflowTimeline/Import/Method/labs_WorkflowTimeline.xml"&gt;Workflow Timeline project&lt;/a&gt;.

Another thing that may help is putting your Test folder in the Innovator/Client/javascript folder instead of the scripts folder. I&amp;#39;m not sure whether this makes a difference, but I think it may have resolved an issue for me once.

Hope this helps!

Eli

&lt;hr /&gt;

Eli Donahue

Aras Labs Software Engineer&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>