timdream / wordcloud2.js

Tag cloud/Wordle presentation on 2D canvas or HTML

Home Page:https://wordcloud2-js.timdream.org/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Uncaught ReferenceError: WordCloud is not defined

jpru opened this issue · comments

commented

Hi,

I am trying wordcloud2.js and getting the error "Uncaught ReferenceError: WordCloud is not defined" in the javascript console. What am I doing wrong? Here is my sample code:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
	<style type="text/css">
	.wordcloud {
		float: left;
		position: relative;
		width: 500px;
		height: 150px;
		background-color: #eeeeee;
	}
	</style>
</head>
<body>
        <canvas id="my_canvas" class="wordcloud"></canvas>
	<script type="text/javascript" src="src/wordcloud2.js"></script>
	<script type="text/javascript">
		WordCloud(document.getElementById('my_canvas'), { list: [['foo', 12], ['bar', 6]] } );
	</script>
</body>
</html>

TIA,
Jürgen

commented

solved. sorry for disturbing...

This is literally the most frustrating response to a question or bug report on the internet, it's been a couple years please don't continue this behaviour @jpru, no matter how wrong you may have been. It may still help someone.

Funnily enough I ran into this exact issue, the solution that worked for me was using the CDN rather than linking the js file directly.

Mentioned in this issue: #140