Link to home
Start Free TrialLog in
Avatar of splanton
splantonFlag for United Kingdom of Great Britain and Northern Ireland

asked on

wordcloud2 help required

I have downloaded wordcloud2.js to create my own word cloud (attached)

The included documentation is 'scant' to say the least

I have a page with the 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>
	<script type="text/javascript" src="wordcloud2.js"></script>
	<script type="text/javascript">
		WordCloud(document.getElementById('my_canvas'), { list: [['foo', 12], ['bar', 6]] } );
	</script>
	<canvas id="my_canvas" class="wordcloud"></canvas>
</body>
</html>

Open in new window


All I keep getting is the following error:

Line: 754
Error: Unable to get property 'dispatchEvent' of undefined or null reference

which refers to the following:

/* Send DOM event */
    var sendEvent = function sendEvent(el, type, cancelable, detail) {
      var evt = document.createEvent('CustomEvent');
      evt.initCustomEvent(type, true, cancelable, detail || {});
      return el.dispatchEvent(evt);
    };

Open in new window


It is highlighting the reference el.dispatchEvent(evt);

Has anyone had practical experience of using wordcloud or can fathom out it's implementation because I have been trying for hours with no joy.

Regards
wordcloud2.js
ASKER CERTIFIED SOLUTION
Avatar of Alexandre Simões
Alexandre Simões
Flag of Switzerland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of splanton

ASKER

School boy error! Well spotted. I am off to kick myself round the car park. :)
If you were here you had to pay me a beer :)