1

I have been trying to get this supposedly very easy to install "lightweight-charts" package going (link to GitHub page), but something is always standing in the way. Of the two install options, the first one quarrels with Firefox, which tries to impose some ridiculous certificate standard about my localhost loaded script files before allowing .js files, about which I can not even hang exceptions since Firefox will first 'search for information of the page' before allowing me to click the greyed out "add an exception" button. (and of course, it can never find a local page with web searches..)

The second option, "installation"/referencing via CDN seems just to be blocked because I get

"Uncaught ReferenceError: LightweightCharts is not defined"

...even when previously loading the package in the head.

Here is a screenshot of the very simple page. enter image description here

const chart = LightweightCharts.createChart(document.getElementById('lwc'), { width: 400, height: 300 });
const lineSeries = chart.addLineSeries();
lineSeries.setData([
  { time: '2019-04-11', value: 80.01 },
  { time: '2019-04-12', value: 96.63 },
  { time: '2019-04-13', value: 76.64 },
  { time: '2019-04-14', value: 81.89 },
  { time: '2019-04-15', value: 74.43 },
  { time: '2019-04-16', value: 80.01 },
  { time: '2019-04-17', value: 96.63 },
  { time: '2019-04-18', value: 76.64 },
  { time: '2019-04-19', value: 81.89 },
  { time: '2019-04-20', value: 74.43 },
]);
<html>
  <head>
    <title>Turtle</title>
    <script src="https://unpkg.com/lightweight-charts/dist/lightweight-charts.standalone.production.js"></script>
  </head>
  <body>
    <h1>Chart</h1>
    <div id="lwc"></div>
    <script src="lwc.js"></script>
  </body>
</html>

...which is just the example they have on their Github with the subtle change of using .getElementById instead of .body.

But not only does it not work at all, but I also found someone making a video of doing exactly the same thing as me, and it worked first try!

So, if I had to guess, I would say something might be blocking the internet connection to this file somehow, causing the SCR in the title to never be cited. I tried to run Firefox in safe mode and loaded this on Chrome as well to make sure it wasn't an add-on, but both failed. Then I attempted to run the page via a python server, but with the same results. I have been searching here for 2 hours without finding more relevant information too. What can I make of this?

Chayim Friedman
  • 47,971
  • 5
  • 48
  • 77
RiiNagaja
  • 92
  • 9
  • Picture says not much other than no activity: https://abload.de/img/screenshot2021-01-28215khn.jpg – RiiNagaja Jan 28 '21 at 19:23
  • @Jry9972 if there is an error in the script then probably yeah :P – Chayim Friedman Jan 28 '21 at 19:23
  • @Jry9972: Yes, it is. A full list of all the functions etc in a big text file. – RiiNagaja Jan 28 '21 at 19:26
  • @Chayim Friedman : I just tried this with a second old laptop that I still had, running Windows 7 and altogether different setup. I got the same error, so if the above webpage and script run on your side like you said, the only culprit left would be my internet provider blocking access I suppose. – RiiNagaja Jan 28 '21 at 22:00
  • Again, please upload a screenshot of the Network tab – Chayim Friedman Jan 28 '21 at 22:04
  • I did so above, but went to performance analysis, since there is literally nothing to see otherwise: https://abload.de/img/networktab1kk3i.jpg – RiiNagaja Jan 28 '21 at 22:14
  • Click on the "Reload" button then upload the screenshot – Chayim Friedman Jan 28 '21 at 22:16
  • I did so many times, and also on the screenshot before. Button, ctrl+shift+R, f5. This is all I get X( – RiiNagaja Jan 28 '21 at 22:21
  • In Chrome it is like this: https://abload.de/img/networktab-chromeptk0n.jpg Same problem but something to see at least. – RiiNagaja Jan 28 '21 at 22:26
  • So the library is not loaded for some reason – Chayim Friedman Jan 28 '21 at 22:28
  • 1
    Try to copy the code of the library and paste it in the beginning of lwc.js; does it work? – Chayim Friedman Jan 28 '21 at 22:31
  • This is what I already concluded in the post after spending a lot of time trying to figure it out before asking. Anyway, still, much thanks for helping me out over this time. I will look into this again tomorrow, and am sure I will be able to make it work eventually. It might be the metered connection for example, or my unwillingness and constant battle with windows update somehow. This script shall kneel eventually... – RiiNagaja Jan 28 '21 at 22:33
  • Oh, wait, that worked! ...Why though? Anyway, good thing I could solve it before bed to sleep better. I will accept your answer tomorrow if you formulate it. Much thanks again! – RiiNagaja Jan 28 '21 at 22:38
  • 1
    It's not good to mix library and user code, so download the library as a js file and link to it `` instead of ``. It should work too – Chayim Friedman Jan 28 '21 at 22:45
  • 4
    There is a typo on your screenshot - you wrote a `scr=` instead of `src=` in a ` – timocov Jan 29 '21 at 13:24
  • @timocov Okay, I should just give up programming. This whole thing literally had only 3 lines to check, and I already knew which one of those had problems, and yet I would not see it. I have had typo diversion problems in the past, but never 5 hours bad. You can shoot me now. – RiiNagaja Jan 29 '21 at 18:01

1 Answers1

1

Try to add the Lightweight-charts package using CDN link.

<script src="https://unpkg.com/lightweight-charts@3.4.0/dist/lightweight-charts.standalone.production.js"></script>

works fine for me.

Amir
  • 43
  • 6