SeregPie / VueWordCloud

Generates a cloud out of the words.
https://seregpie.github.io/VueWordCloud/
MIT License
386 stars 60 forks source link

Words not change when words input change #29

Closed kennj2016 closed 6 years ago

kennj2016 commented 6 years ago
 <vue-word-cloud 
                                        style="width: 400px; height: 400px;"
                                          :words="dataTagWords" 
                                          :color="([, weight]) => weight > 10 ? 'DeepPink' : weight > 5 ? 'RoyalBlue' : 'Indigo'"
                                      font-family="Roboto"
                                    ></vue-word-cloud>
SeregPie commented 6 years ago

Please upload your code somewhere, so I can have a look at it.

kennj2016 commented 6 years ago
words = words.replace(/[&\/\\#,+()$~%.'":*?<>{}]/g, '').toLowerCase();

let words_except = ['a', 'b', 'p', 'n', 'id', 'uses', 'h', 'is', 'was', 'am', 'are', 'the', 'to', 'be', 'to', 'of', 'and',
 'in', 'that', 'have', 'i', 'it', 'for', 'on', 'with', 'he', 'as', 'you',
 'do', 'at', 'this', 'but', 'his', 'by', "the", "of", "and", "a", "to", "in", "is", "you", "that", "it", "he", "was", "for",
 "on", "are", "as", "with", "his", "they", "I", "at", "be", "this", "have", "from", "or",
 "one", "had", "by", "word", "but", "not", "what", "all", "were", "we", "when", "your", "can",
 "said", "there", "use", "an", "each", "which", "she", "do", "how", "their", "if",
 "will", "up", "other", "about", "out", "many", "then", "them", "these", "so", "some", "her",
 "would", "make", "like", "him", "into", "time", "has", "look", "two", "more", "write", "go", "see",
 "number", "no", "way", "could", "people", "my", "than", "first", "water", "been", "call", "who",
 "oil", "its", "now", "find", "long", "down", "day", "did", "get", "come", "made", "may", "part"
];

words = words.replace(/[^a-zA-Z]+/g, ' ');
let reg_replace = "";
for (var i = words_except.length - 1; i >= 0; i--) {
 reg_replace = " " + words_except[i] + " ";
 words = words.replace(new RegExp(reg_replace, 'gi'), " ");
}

words = words.replace(/([ ]+)/g, '$1§sep§').split('§sep§');

console.log(words.length);

let wordsCloud = [];

for (let k in words) {
 if (words.hasOwnProperty(k)) {
  let i = words[k].trim();
  wordsCloud[i] = (wordsCloud[i] || 0) + 1;
 }
}

for (let k in wordsCloud) {
 this.dataTagWords.push([k, wordsCloud[k]]);

}
SeregPie commented 6 years ago

Can you please upload a full working example on https://jsfiddle.net

kennj2016 commented 6 years ago

Hi, can you let me know what kind of codes do you want to look at? the whole project or just some pages?

Thanks

On Thu, Mar 1, 2018 at 10:53 AM, Sergej Sintschilin < notifications@github.com> wrote:

Please upload your code somewhere, so I can have a look at it.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/SeregPie/VueWordCloud/issues/29#issuecomment-369636414, or mute the thread https://github.com/notifications/unsubscribe-auth/ATeY-gClYWaHJI5zkFKoWQYEqWLgo0nnks5taBmIgaJpZM4SYdnV .