How to assign random colors to D3 bar chart?

后端 未结 3 556
花落未央
花落未央 2021-02-05 10:31

I am working on a D3 bar chart as per the mock-up below:

\"Bar

How do I make the bars to have rando

3条回答
  •  后悔当初
    2021-02-05 10:52

    d3 has 4 built in color palettes.

    Here's the link for the built in color palettes.

    This tutorial is good on using specific colors for specific element.

    Another tutorial by Jerome Cukier.

    And the official site for d3 colors.

    Fiddle - Note: In the fiddle I've passed the colors by adding colors in the data.

    It can even be done by passing the colors from a different variables.

    Hope this helps.

提交回复
热议问题