Nilsymbol
Nilsymbol

Reputation: 525

changing text font through css for specific text in d3

I am using the d3 framework and I am trying to specify the font the following element using css (I want to use a custom font, that is why I am using css).

var anchorNode = svg.selectAll("g.anchorNode").data(force2.nodes()).enter().append("svg:g").attr("class", "anchorNode");
anchorNode.append("svg:circle");
anchorNode.append("svg:text").text("test"); 

I tried using

text {
    font: 2px Arial;
    pointer-events: none;
}

but this does not work for this specific text. I am assuming it is because the text is appended to the node. What would be the correct syntax to access the text in css?

Upvotes: 0

Views: 2018

Answers (1)

Will
Will

Reputation: 1299

Do you have a link to the rendered HTML or a jsfiddle?

It looks like your appending a class called anchorNode. You could possibly updating the CSS font for that class:

.anchorNode {
      font-family: "Times New Roman", Times, serif;
      font-size: 2px;
}

Upvotes: 3

Related Questions