javascripthtmljsphighchartsexternal-script

Using HighChart JS files locally


I'm trying to use the highchats js files locally in code. When I use the official link as below it is working

<script src="http://code.highcharts.com/highcharts.js"></script>
<script src="http://code.highcharts.com/highcharts-more.js"></script>
<script src="http://code.highcharts.com/modules/exporting.js"></script>
<div id="container" style="height: 400px; min-width: 310px; max-width: 600px; margin: 0 auto"></div>

When I tried same as a local imported file as below it is not working

<script src="${pageContext.servletContext.contextPath}/resources/js/exporting.js"></script>
<script src="${pageContext.servletContext.contextPath}/resources/js/highcharts-more.js"></script> 
<script src="${pageContext.servletContext.contextPath}/resources/js/highcharts.js"></script>

the below is the error i'm facing

enter image description here

Is it possible to use locally or if i keep those files in my server will it help.


Solution

  • I think the order is important when you are loading libraries. Try this:

       <script src="${pageContext.servletContext.contextPath}/resources/js/highcharts.js"></script>
      <script src="${pageContext.servletContext.contextPath}/resources/js/highcharts-more.js"></script> 
        <script src="${pageContext.servletContext.contextPath}/resources/js/exporting.js">    </script>