timdream / wordcloud2.js

Tag cloud/Wordle presentation on 2D canvas or HTML
https://wordcloud2-js.timdream.org/
MIT License
2.34k stars 510 forks source link

Issue #172: Add extra data to color, classes and fontWeight callbacks #173

Closed adrienpwd closed 3 years ago

adrienpwd commented 3 years ago

https://github.com/timdream/wordcloud2.js/issues/172

Here is the initial change to the code to have access to the extra data we pass in the 2d array. I would like to add a test for each callback, unless you think it's not necessary (no breaking change). However I'm wondering why in the tests the list array is like this: Grumpy,5.33935546875,wizards,4.67193603515625,make,8.4375,toxic,5.9326171875,brew,2.669677734375,for,4.74609375,the,2.669677734375,evil,2.00225830078125,Queen,1.8771171569824219,and,2.669677734375,Jack,2.669677734375 Instead of: [[Grumpy, 5.33935546875], [wizards, 4.67193603515625], ...] How should I add the extra data for each word ?

timdream commented 3 years ago

Thank you!