jasondavies / d3-cloud

Create word clouds in JavaScript.
https://www.jasondavies.com/wordcloud/
Other
3.82k stars 1.07k forks source link

Quote-Unquote! #123

Closed pgoswami3 closed 7 years ago

pgoswami3 commented 7 years ago

Hi Jason,

I know it's not a real issue but any help would be appreciated.

I'm trying to render my tweets into a word cloud but when I project my array of words, the array of quoted texts turns out to be unquoted one.

The only change on your part of code is to use my variable (textOnly)

d3.layout.cloud().size([600, 600])
        .words(<%= textOnly %>.map(function(d) {
          return {text: d, size: 10 + Math.random() * 90};
}))

, instead of an array of predefined words ['I', 'am', 'Groot']

Snap 1: Console o/p with quoted/unique words

screen shot 2017-05-29 at 10 26 44 am

Snap 2: o/p in browser

screen shot 2017-05-29 at 10 27 16 am
jasondavies commented 7 years ago

Looks like you aren't encoding your variable correctly as a JavaScript array in your JSP template. (I assume that's JSP syntax.) Sorry, this isn't the place to ask for generic help: try StackOverflow.