VividD
VividD

Reputation: 10536

D3 tree/cluster diagram - changing node text color

I would like to have diagram similar to this one: (the most important part is that I would like to have node text displayed in several colors; it doesn't matter whether the diagram is tree or cluster)

enter image description here

This is a test example:

jsfiddle

enter image description here

I tried changing text color via CSS, and within JavaScript code, bit it always remains black. Why?

Upvotes: 5

Views: 3902

Answers (1)

VividD
VividD

Reputation: 10536

I found the answer:

    fill: #5555ff;    

in CSS for node/text solves the problem.

SVG text element does not care about color attribute, like other HTML elements. Setting fill is the right way.

enter image description here

Upvotes: 8

Related Questions