highcharts / highcharts-react-native

Other
103 stars 79 forks source link

How to correctly link moment and moment-timezone #11

Closed jj-julia closed 5 years ago

jj-julia commented 5 years ago

I am trying to use the timezone feature https://api.highcharts.com/highcharts/time.timezone What is the best way to import moment and moment-timezones? Currently I am importing the scripts from a CDN in the index.html file (see below). It works, however, every time I navigate away and return the timezone reverts to the UTC. Am I approaching this in the wrong way?

Thanks

<html>
    <head>
        <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=0" />
        <link rel="stylesheet" type="text/css" href="css/styles.css" />
    </head>
    <body>
        <div id="container" style="width: 100%; display:flex;flex-direction: column;"></div>
        <script type="text/javascript" src="js/moment-timezone-with-data-2012-2022.min.js"></script>
        <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.18.1/moment.min.js"></script>
        <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/moment-timezone/0.5.13/moment-timezone-with-data-2012-2022.min.js"></script>
    </body>
</html>
sebastianbochan commented 5 years ago

Hi @jj-julia, Probably the file moment-timezone-with-data-2012-2022.min.js is not loaded, because you try to do load it from local file system. Try to use the global url (like cdn).

jj-julia commented 5 years ago

Unfortunately I cant use the CDN because we are building an offline first app. I ended up modifying the wrapper to load them there instead. The reason was that the order the files loaded varied on the second load, causing it to fail second time around.

SaeedZhiany commented 5 years ago

@sebastianbochan I had this question too. by default, all highcharts, jquery, and other required libraries will download in every webview. is there any way to put and used them locally. in case of fully offline usages?

sebastianbochan commented 5 years ago

Hi @SaeedZhiany, All files are loaded locally, not from CDN. As a result, the app will work offline.