Skip to content

Commit

Permalink
feat: Add css class override for node text
Browse files Browse the repository at this point in the history
  • Loading branch information
ErikGartner committed Dec 27, 2015
1 parent c995eb5 commit 21b8677
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ The data object should have the following structure:
[{
name: "Father",
class: "overriding-css-class",
textClass: "overriding-css-class",
marriage: {
spouse: {
name: "Mother",
Expand Down
10 changes: 4 additions & 6 deletions src/builder.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,11 +78,7 @@ const treeBuilder = {
// Create the node rectangles.
nodes.append('rect')
.attr('class', function(d) {
if (d.class) {
return d.class;
} else {
return opts.styles.node;
}
return d.class ? d.class : opts.styles.nodes;
})
.attr('width', nodeSize[0] / 2)
.attr('height', nodeSize[1] / 3)
Expand All @@ -104,7 +100,9 @@ const treeBuilder = {
.text(function(d) {
return d.name;
})
.attr('class', opts.styles.text)
.attr('class', function(d) {
return d.textClass ? d.textClass : opts.styles.text;
})
.attr('x', tx)
.attr('y', ty);
},
Expand Down

0 comments on commit 21b8677

Please sign in to comment.