-
Notifications
You must be signed in to change notification settings - Fork 22.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This is a utility for creating a Bézier curve between opposite corners of a rectangle. This is commonly used to draw smooth curves connecting parent and child nodes in a hierarchical node-link diagram. A projection may be specified which allows the curve to be transformed from polar coordinates. This commit also changes the semantics of the recently-added `links` method, such that the objects have `source` and `target` properties that match the default diagonal format.
- Loading branch information
Showing
11 changed files
with
106 additions
and
71 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
d3.svg.diagonal = function() { | ||
var source = d3_svg_chordSource, | ||
target = d3_svg_chordTarget, | ||
projection = d3_svg_diagonalProjection; | ||
|
||
function diagonal(d, i) { | ||
var p0 = source.call(this, d, i), | ||
p3 = target.call(this, d, i), | ||
m = (p0.y + p3.y) / 2, | ||
p = [p0, {x: p0.x, y: m}, {x: p3.x, y: m}, p3]; | ||
p = p.map(projection); | ||
return "M" + p[0] + "C" + p[1] + " " + p[2] + " " + p[3]; | ||
} | ||
|
||
diagonal.source = function(x) { | ||
if (!arguments.length) return source; | ||
source = d3_functor(x); | ||
return diagonal; | ||
}; | ||
|
||
diagonal.target = function(x) { | ||
if (!arguments.length) return target; | ||
target = d3_functor(x); | ||
return diagonal; | ||
}; | ||
|
||
diagonal.projection = function(x) { | ||
if (!arguments.length) return projection; | ||
projection = x; | ||
return diagonal; | ||
}; | ||
|
||
return diagonal; | ||
}; | ||
|
||
function d3_svg_diagonalProjection(d) { | ||
return [d.x, d.y]; | ||
} |