Comments (9)
The code block in https://timdream.org/wordcloud2.js/#love provides the exact example.
from wordcloud2.js.
Proposed a solution here: #61
from wordcloud2.js.
Sorry about the late reply. I agree this feature, but I don't think each of the item should be represented as arrays anymore. How about let's do a little refactor first like this?
[ { word: 'foo', score: 6, color: '#00b2ee' }, ... ]
Please maintain compatibility with the old syntax by checking the object type, with, e.g.,
if (Array.isArray(foo)) {
foo = { word: foo[0], score: foo[1] };
}
Thank you!
from wordcloud2.js.
Of course, you know the code best. Do you have any estimation on when you are able to implement it?
from wordcloud2.js.
Don't think I will be able to work on this anytime soon. I think you are capable of working on this and you should. Thanks for helping out!
from wordcloud2.js.
Hi,
I try differently loop through the array but I can setup individual colour for a single word. I have seen in API documentation callback function but I don't understand how to apply to code. I get continuously syntax error.
Is it any chance to get an example of code how to do that?
from wordcloud2.js.
Thank you,
It's working. :)
from wordcloud2.js.
When trying to utilizes this feature I have run into some challenges.
It seems that when item
is passed in to the color callback function it only contains the word and not any other of the array elements. In contrast the item works as expected when passed into the click callback.
This can be seen by editing the example configuration at https://timdream.org/wordcloud2.js/#love with the following:
color: function(item){
console.log(item);
},
click: function(item){
console.log(item);
}
The first callback logs just the word, the second one logs the array of word and number.
from wordcloud2.js.
I had the same issue. In case it helps anyone, here is my workaround. Seems to do the job.
var list = [
['foo', 40, '#FD0100'],
['bar', 60, '#019240']
];
var listColorCounter = 0;
WordCloud(document.getElementById(divId), {
list: list,
fontFamily: 'Open Sans, Arial, sans-serif',
color: function () {
return list[listColorCounter++][2];
},
click: function(item){
console.log(item);
},
rotateRatio: 0.5,
rotationSteps: 2,
backgroundColor: '#FAF6EB'
});
from wordcloud2.js.
Related Issues (20)
- Text is truncated HOT 1
- Uncaught TypeError: ..... Value is not of type 'long'. HOT 1
- No type for version 1.2.2
- First words aligned
- How to randomize the filling order? HOT 3
- How do I change Device pixel density (dppx)? HOT 1
- Canvas not filled on Chromium
- can you please add example for how to add mouse events
- How can we rotate the text to specific angle?
- How we can add background color to the masked image HOT 1
- Keep getting many null is not an object errors
- Semver Dependency Issue
- Demo pages fails to 'run' on Chrome
- Where can we find the code of the demo page? HOT 1
- Next 14
- treat words as a single rectangle to avoid overlapping?
- How to render correct sizes based on order instead of count?
- Fix low font quality rendering
- Fill the whole canvas
- Add data to DOM
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from wordcloud2.js.