SeregPie/VueWordCloud

Words not change when words input change

kennj2016 opened this issue · 4 comments

 <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>

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

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]]);

}

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