Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
372 views
in Technique[技术] by (71.8m points)

javascript - Lightweight Charts - Uncaught ReferenceError: LightweightCharts is not defined

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?

question from:https://stackoverflow.com/questions/65943167/lightweight-charts-uncaught-referenceerror-lightweightcharts-is-not-defined

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...