Giter VIP home page Giter VIP logo

Comments (5)

vincenttheeten avatar vincenttheeten commented on May 19, 2024 1

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()); })
...

from d3-cloud.

Honghe avatar Honghe commented on May 19, 2024 1

in d3 v4, use as follow:

var color = d3.scaleOrdinal(d3.schemeCategory10);

from d3-cloud.

alexresolute avatar alexresolute commented on May 19, 2024 1

This no longer works. Is using custom style deprecated? At a skim, it almost looks like the textFill is hard coded to red...

from d3-cloud.

jasondavies avatar jasondavies commented on May 19, 2024

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!

from d3-cloud.

jankapunkt avatar jankapunkt commented on May 19, 2024

@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)';
}

from d3-cloud.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.