Note that there are some explanatory texts on larger screens.

plurals
  1. POError caused by string being too big when passed to Google Visualization API
    text
    copied!<p>I am trying to create a <a href="http://visapi-gadgets.googlecode.com/svn/trunk/wordcloud/doc.html" rel="nofollow noreferrer">WordCloud</a> through the <a href="http://code.google.com/apis/visualization/documentation/reference.html" rel="nofollow noreferrer">Google Visualization API</a>. You have to create a google.visualization.DataTable and add the string to a cell in the table. I basically copied the example linked above, and passed in a simple string of a few words (@note.articletext), and the WordCloud worked fine.</p> <pre><code> &lt;script type="text/javascript"&gt; google.load("visualization", "1"); google.setOnLoadCallback(draw); function draw() { var data = new google.visualization.DataTable(); data.addColumn('string', 'Text1'); data.addRows(1); data.setCell(0, 0, '&lt;%= @note.articletext %&gt;'); var outputDiv = document.getElementById('wcdiv'); var wc = new WordCloud(outputDiv); wc.draw(data, {width:300, height:300}); } &lt;/script&gt; </code></pre> <p>But I want to create the WordCloud based on a article, which (obviously) is a very large string. When I pass in a string containing a whole article, I get the following error:</p> <pre><code>unterminated string literal data.setCell(0, 0, 'There was a da...ne ended with a time-out in his crib. </code></pre> <p>Again, this error doesn't occur when I pass in a small string, so it's caused by the size of the string. Or potentially the google.visualization.DataTable has a limit on how big a single cell can be (I can't find mention of such a limit though). Does anyone know how can I fix this? Thanks for reading.</p> <p>Edit: In case it's important, I'm using Ruby on Rails.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload