Closed ghost closed 12 years ago
I had the same question, I found the answer in the demo.
var fill = d3.scale.category20();
...
.style("fill", function(d) { return fill(d.text.toLowerCase()); })
...
I’ve updated the example to include some colour, but this is really a D3.js usage question.
In future you might be better off asking on StackOverflow or the d3-js Google Group. GitHub issues are meant to be for bugs only. Thanks!
in d3 v4, use as follow:
var color = d3.scaleOrdinal(d3.schemeCategory10);
This no longer works. Is using custom style deprecated? At a skim, it almost looks like the textFill is hard coded to red...
@alexresolute
Looking at the example from the /examples
folder I simply added this after the font family style:
...
.style('font-family', 'Impact')
.style('fill', function (d) {
return randomColor()
})
...
// this is of course just an example, taken from
// https://stackoverflow.com/a/25873123/3098783
const randomColor = () => {
return 'hsla(' + (Math.random() * 360) + ', 100%, 50%, 1)';
}
Hi,
I want to know how to color differently each word in the cloud ?
Thanks for you help
Amine