nothing is being displayed in div
ORESoftware opened this issue · comments
Alexander Mills commented
I have this:
<div id="my_canvas"></div>
and then this js call:
<script>
WordCloud(document.getElementById('my_canvas'), {list: [['foo', 3], ['bar', 5]]});
</script>
the WordCloud() function gets called, but nothing gets displayed, weird
Vincent De Feo commented
You need to initialize both a canvas and an HTML container!
<div id="my_container"></div>
<canvas id="my_canvas"></canvas>
<script>
WordCloud([
document.getElementById('my_canvas'),
document.getElementById('my_container'),
], {list: [['foo', 3], ['bar', 5]]});
</script>
This works!
Tony Chiboucas commented
Note: Order is important here.
- HTML should be div first.
WordCloud
call must initialize canvas element first.
HTML Element appears to be built from the Canvas element. You can have a canvas without html, but to have an html cloud, you must have a canvas. Either element may be set to display: none
.