timdream / wordcloud2.js

Tag cloud/Wordle presentation on 2D canvas or HTML
https://wordcloud2-js.timdream.org/
MIT License
2.36k stars 511 forks source link

Uncaught ReferenceError: WordCloud is not defined #127

Closed jpru closed 6 years ago

jpru commented 6 years ago

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

jpru commented 6 years ago

solved. sorry for disturbing...

jeffdyke commented 3 years ago

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.

tiago-a-ribeiro commented 11 months ago

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