WordCloud - Sample

Overview

A list of words, where the size and color of each word is determined by the number of times it appears in the text.

Example

Sample Code

<html>
  <head>
    <link rel="stylesheet" type="text/css" href="http://visapi-gadgets.googlecode.com/svn/trunk/wordcloud/wc.css"/>
    <script type="text/javascript" src="http://visapi-gadgets.googlecode.com/svn/trunk/wordcloud/wc.js"></script>
    <script type="text/javascript" src="http://www.google.com/jsapi"></script>
  </head>
  <body>
    <div id="wcdiv"></div>
    <script type="text/javascript">
      google.load("visualization", "1");
      google.setOnLoadCallback(draw);
      function draw() {
        var data = new google.visualization.DataTable();
        data.addColumn('string', 'Text1');
        data.addColumn('string', 'Text2');
        data.addRows(3);
        data.setCell(0, 0, 'This is a test');
        data.setCell(0, 1, 'This test is quite hard');
        data.setCell(1, 0, 'A hard test or not?');
        data.setCell(1, 1, 'This was not too hard');
        data.setCell(2, 0, 'Hard hard hard this is so hard !!!');
        data.setCell(2, 1, 'For every test there is a solution. For every one');
        var outputDiv = document.getElementById('wcdiv');
        var wc = new WordCloud(outputDiv);
        wc.draw(data, null);
      }
    </script>
  </body>
</html>

Expected Data Format

Any number of rows and columns. All string values are concatenated. Any other column type is ignored.

Options

stopWords A string of all the words to ignore in the text. The words should be separated by spaces or commas. The default value is "a an and is or the". Example:
  wc.draw(data, {stopWords: 'a an and is or the of for to'});

Methods

none

Events

none

Contact Information

For comments, ideas problem reports please contact visapi.gadgets@gmail.com.