mirror of
https://github.com/nunocoracao/blowfish.git
synced 2026-01-30 15:31:52 +00:00
config redirect
This commit is contained in:
+13
@@ -0,0 +1,13 @@
|
||||
Copyright 2010-2021 Mike Bostock
|
||||
|
||||
Permission to use, copy, modify, and/or distribute this software for any purpose
|
||||
with or without fee is hereby granted, provided that the above copyright notice
|
||||
and this permission notice appear in all copies.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
||||
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||
FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
||||
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
|
||||
OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
|
||||
TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF
|
||||
THIS SOFTWARE.
|
||||
+234
@@ -0,0 +1,234 @@
|
||||
# d3-chord
|
||||
|
||||
Visualize relationships or network flow with an aesthetically-pleasing circular layout.
|
||||
|
||||
[<img alt="Chord Diagram" src="https://raw.githubusercontent.com/d3/d3-chord/master/img/chord.png" width="480" height="480">](https://observablehq.com/@d3/chord-diagram)
|
||||
|
||||
## Installing
|
||||
|
||||
If you use npm, `npm install d3-chord`. You can also download the [latest release on GitHub](https://github.com/d3/d3-chord/releases/latest). For vanilla HTML in modern browsers, import d3-chord from Skypack:
|
||||
|
||||
```html
|
||||
<script type="module">
|
||||
|
||||
import {chord} from "https://cdn.skypack.dev/d3-chord@3";
|
||||
|
||||
const c = chord();
|
||||
|
||||
</script>
|
||||
```
|
||||
|
||||
For legacy environments, you can load d3-chord’s UMD bundle from an npm-based CDN such as jsDelivr; a `d3` global is exported:
|
||||
|
||||
```html
|
||||
<script src="https://cdn.jsdelivr.net/npm/d3-path@3"></script>
|
||||
<script src="https://cdn.jsdelivr.net/npm/d3-chord@3"></script>
|
||||
<script>
|
||||
|
||||
const chord = d3.chord();
|
||||
|
||||
</script>
|
||||
```
|
||||
|
||||
## API Reference
|
||||
|
||||
<a href="#chord" name="chord">#</a> d3.<b>chord</b>() · [Source](https://github.com/d3/d3-chord/blob/master/src/chord.js)
|
||||
|
||||
Constructs a new chord layout with the default settings.
|
||||
|
||||
<a href="#_chord" name="_chord">#</a> <i>chord</i>(<i>matrix</i>) · [Source](https://github.com/d3/d3-chord/blob/master/src/chord.js)
|
||||
|
||||
Computes the chord layout for the specified square *matrix* of size *n*×*n*, where the *matrix* represents the directed flow amongst a network (a complete digraph) of *n* nodes. The given *matrix* must be an array of length *n*, where each element *matrix*[*i*] is an array of *n* numbers, where each *matrix*[*i*][*j*] represents the flow from the *i*th node in the network to the *j*th node. Each number *matrix*[*i*][*j*] must be nonnegative, though it can be zero if there is no flow from node *i* to node *j*. From the [Circos tableviewer example](http://mkweb.bcgsc.ca/circos/guide/tables/):
|
||||
|
||||
```js
|
||||
const matrix = [
|
||||
[11975, 5871, 8916, 2868],
|
||||
[ 1951, 10048, 2060, 6171],
|
||||
[ 8010, 16145, 8090, 8045],
|
||||
[ 1013, 990, 940, 6907]
|
||||
];
|
||||
```
|
||||
|
||||
The return value of *chord*(*matrix*) is an array of *chords*, where each chord represents the combined bidirectional flow between two nodes *i* and *j* (where *i* may be equal to *j*) and is an object with the following properties:
|
||||
|
||||
* `source` - the source subgroup
|
||||
* `target` - the target subgroup
|
||||
|
||||
Each source and target subgroup is also an object with the following properties:
|
||||
|
||||
* `startAngle` - the start angle in radians
|
||||
* `endAngle` - the end angle in radians
|
||||
* `value` - the flow value *matrix*[*i*][*j*]
|
||||
* `index` - the node index *i*
|
||||
|
||||
The chords are typically passed to [d3.ribbon](#ribbon) to display the network relationships. The returned array includes only chord objects for which the value *matrix*[*i*][*j*] or *matrix*[*j*][*i*] is non-zero. Furthermore, the returned array only contains unique chords: a given chord *ij* represents the bidirectional flow from *i* to *j* *and* from *j* to *i*, and does not contain a duplicate chord *ji*; *i* and *j* are chosen such that the chord’s source always represents the larger of *matrix*[*i*][*j*] and *matrix*[*j*][*i*].
|
||||
|
||||
The *chords* array also defines a secondary array of length *n*, *chords*.groups, where each group represents the combined outflow for node *i*, corresponding to the elements *matrix*[*i*][0 … *n* - 1], and is an object with the following properties:
|
||||
|
||||
* `startAngle` - the start angle in radians
|
||||
* `endAngle` - the end angle in radians
|
||||
* `value` - the total outgoing flow value for node *i*
|
||||
* `index` - the node index *i*
|
||||
|
||||
The groups are typically passed to [d3.arc](https://github.com/d3/d3-shape#arc) to produce a donut chart around the circumference of the chord layout.
|
||||
|
||||
<a href="#chord_padAngle" name="chord_padAngle">#</a> <i>chord</i>.<b>padAngle</b>([<i>angle</i>]) · [Source](https://github.com/d3/d3-chord/blob/master/src/chord.js)
|
||||
|
||||
If *angle* is specified, sets the pad angle between adjacent groups to the specified number in radians and returns this chord layout. If *angle* is not specified, returns the current pad angle, which defaults to zero.
|
||||
|
||||
<a href="#chord_sortGroups" name="chord_sortGroups">#</a> <i>chord</i>.<b>sortGroups</b>([<i>compare</i>]) · [Source](https://github.com/d3/d3-chord/blob/master/src/chord.js)
|
||||
|
||||
If *compare* is specified, sets the group comparator to the specified function or null and returns this chord layout. If *compare* is not specified, returns the current group comparator, which defaults to null. If the group comparator is non-null, it is used to sort the groups by their total outflow. See also [d3.ascending](https://github.com/d3/d3-array/blob/master/README.md#ascending) and [d3.descending](https://github.com/d3/d3-array/blob/master/README.md#descending).
|
||||
|
||||
<a href="#chord_sortSubgroups" name="chord_sortSubgroups">#</a> <i>chord</i>.<b>sortSubgroups</b>([<i>compare</i>]) · [Source](https://github.com/d3/d3-chord/blob/master/src/chord.js)
|
||||
|
||||
If *compare* is specified, sets the subgroup comparator to the specified function or null and returns this chord layout. If *compare* is not specified, returns the current subgroup comparator, which defaults to null. If the subgroup comparator is non-null, it is used to sort the subgroups corresponding to *matrix*[*i*][0 … *n* - 1] for a given group *i* by their total outflow. See also [d3.ascending](https://github.com/d3/d3-array/blob/master/README.md#ascending) and [d3.descending](https://github.com/d3/d3-array/blob/master/README.md#descending).
|
||||
|
||||
<a href="#chord_sortChords" name="chord_sortChords">#</a> <i>chord</i>.<b>sortChords</b>([<i>compare</i>]) · [Source](https://github.com/d3/d3-chord/blob/master/src/chord.js)
|
||||
|
||||
If *compare* is specified, sets the chord comparator to the specified function or null and returns this chord layout. If *compare* is not specified, returns the current chord comparator, which defaults to null. If the chord comparator is non-null, it is used to sort the [chords](#_chord) by their combined flow; this only affects the *z*-order of the chords. See also [d3.ascending](https://github.com/d3/d3-array/blob/master/README.md#ascending) and [d3.descending](https://github.com/d3/d3-array/blob/master/README.md#descending).
|
||||
|
||||
<a href="#chordDirected" name="chordDirected">#</a> d3.<b>chordDirected</b>() · [Source](https://github.com/d3/d3-chord/blob/master/src/chord.js), [Examples](https://observablehq.com/@d3/directed-chord-diagram)
|
||||
|
||||
A chord layout for directional flows. The chord from *i* to *j* is generated from the value in *matrix*[*i*][*j*] only.
|
||||
|
||||
<a href="#chordTranspose" name="chordTranspose">#</a> d3.<b>chordTranspose</b>() · [Source](https://github.com/d3/d3-chord/blob/master/src/chord.js)
|
||||
|
||||
A transposed chord layout. Useful to highlight outgoing (rather than incoming) flows.
|
||||
|
||||
<a href="#ribbon" name="ribbon">#</a> d3.<b>ribbon</b>() · [Source](https://github.com/d3/d3-chord/blob/master/src/ribbon.js)
|
||||
|
||||
Creates a new ribbon generator with the default settings.
|
||||
|
||||
<a href="#_ribbon" name="_ribbon">#</a> <i>ribbon</i>(<i>arguments…</i>) · [Source](https://github.com/d3/d3-chord/blob/master/src/ribbon.js)
|
||||
|
||||
Generates a ribbon for the given *arguments*. The *arguments* are arbitrary; they are simply propagated to the ribbon generator’s accessor functions along with the `this` object. For example, with the default settings, a [chord object](#_chord) expected:
|
||||
|
||||
```js
|
||||
const ribbon = d3.ribbon();
|
||||
|
||||
ribbon({
|
||||
source: {startAngle: 0.7524114, endAngle: 1.1212972, radius: 240},
|
||||
target: {startAngle: 1.8617078, endAngle: 1.9842927, radius: 240}
|
||||
}); // "M164.0162810494058,-175.21032946354026A240,240,0,0,1,216.1595644740915,-104.28347273835429Q0,0,229.9158815306728,68.8381247563705A240,240,0,0,1,219.77316791012538,96.43523560788266Q0,0,164.0162810494058,-175.21032946354026Z"
|
||||
```
|
||||
|
||||
Or equivalently if the radius is instead defined as a constant:
|
||||
|
||||
```js
|
||||
const ribbon = d3.ribbon()
|
||||
.radius(240);
|
||||
|
||||
ribbon({
|
||||
source: {startAngle: 0.7524114, endAngle: 1.1212972},
|
||||
target: {startAngle: 1.8617078, endAngle: 1.9842927}
|
||||
}); // "M164.0162810494058,-175.21032946354026A240,240,0,0,1,216.1595644740915,-104.28347273835429Q0,0,229.9158815306728,68.8381247563705A240,240,0,0,1,219.77316791012538,96.43523560788266Q0,0,164.0162810494058,-175.21032946354026Z"
|
||||
```
|
||||
|
||||
If the ribbon generator has a context, then the ribbon is rendered to this context as a sequence of path method calls and this function returns void. Otherwise, a path data string is returned.
|
||||
|
||||
<a href="#ribbon_source" name="ribbon_source">#</a> <i>ribbon</i>.<b>source</b>([<i>source</i>]) · [Source](https://github.com/d3/d3-chord/blob/master/src/ribbon.js)
|
||||
|
||||
If *source* is specified, sets the source accessor to the specified function and returns this ribbon generator. If *source* is not specified, returns the current source accessor, which defaults to:
|
||||
|
||||
```js
|
||||
function source(d) {
|
||||
return d.source;
|
||||
}
|
||||
```
|
||||
|
||||
<a href="#ribbon_target" name="ribbon_target">#</a> <i>ribbon</i>.<b>target</b>([<i>target</i>]) · [Source](https://github.com/d3/d3-chord/blob/master/src/ribbon.js)
|
||||
|
||||
If *target* is specified, sets the target accessor to the specified function and returns this ribbon generator. If *target* is not specified, returns the current target accessor, which defaults to:
|
||||
|
||||
```js
|
||||
function target(d) {
|
||||
return d.target;
|
||||
}
|
||||
```
|
||||
|
||||
<a href="#ribbon_radius" name="ribbon_radius">#</a> <i>ribbon</i>.<b>radius</b>([<i>radius</i>]) · [Source](https://github.com/d3/d3-chord/blob/master/src/ribbon.js)
|
||||
|
||||
If *radius* is specified, sets the source and target radius accessor to the specified function and returns this ribbon generator. If *radius* is not specified, returns the current source radius accessor, which defaults to:
|
||||
|
||||
```js
|
||||
function radius(d) {
|
||||
return d.radius;
|
||||
}
|
||||
```
|
||||
|
||||
<a href="#ribbon_sourceRadius" name="ribbon_sourceRadius">#</a> <i>ribbon</i>.<b>sourceRadius</b>([<i>radius</i>]) · [Source](https://github.com/d3/d3-chord/blob/master/src/ribbon.js)
|
||||
|
||||
If *radius* is specified, sets the source radius accessor to the specified function and returns this ribbon generator. If *radius* is not specified, returns the current source radius accessor, which defaults to:
|
||||
|
||||
```js
|
||||
function radius(d) {
|
||||
return d.radius;
|
||||
}
|
||||
```
|
||||
|
||||
<a href="#ribbon_targetRadius" name="ribbon_targetRadius">#</a> <i>ribbon</i>.<b>targetRadius</b>([<i>radius</i>]) · [Source](https://github.com/d3/d3-chord/blob/master/src/ribbon.js)
|
||||
|
||||
If *radius* is specified, sets the target radius accessor to the specified function and returns this ribbon generator. If *radius* is not specified, returns the current target radius accessor, which defaults to:
|
||||
|
||||
```js
|
||||
function radius(d) {
|
||||
return d.radius;
|
||||
}
|
||||
```
|
||||
|
||||
By convention, the target radius in asymmetric chord diagrams is typically inset from the source radius, resulting in a gap between the end of the directed link and its associated group arc.
|
||||
|
||||
<a href="#ribbon_startAngle" name="ribbon_startAngle">#</a> <i>ribbon</i>.<b>startAngle</b>([<i>angle</i>]) · [Source](https://github.com/d3/d3-chord/blob/master/src/ribbon.js)
|
||||
|
||||
If *angle* is specified, sets the start angle accessor to the specified function and returns this ribbon generator. If *angle* is not specified, returns the current start angle accessor, which defaults to:
|
||||
|
||||
```js
|
||||
function startAngle(d) {
|
||||
return d.startAngle;
|
||||
}
|
||||
```
|
||||
|
||||
The *angle* is specified in radians, with 0 at -*y* (12 o’clock) and positive angles proceeding clockwise.
|
||||
|
||||
<a href="#ribbon_endAngle" name="ribbon_endAngle">#</a> <i>ribbon</i>.<b>endAngle</b>([<i>angle</i>]) · [Source](https://github.com/d3/d3-chord/blob/master/src/ribbon.js)
|
||||
|
||||
If *angle* is specified, sets the end angle accessor to the specified function and returns this ribbon generator. If *angle* is not specified, returns the current end angle accessor, which defaults to:
|
||||
|
||||
```js
|
||||
function endAngle(d) {
|
||||
return d.endAngle;
|
||||
}
|
||||
```
|
||||
|
||||
The *angle* is specified in radians, with 0 at -*y* (12 o’clock) and positive angles proceeding clockwise.
|
||||
|
||||
<a href="#ribbon_padAngle" name="ribbon_padAngle">#</a> <i>ribbon</i>.<b>padAngle</b>([<i>angle</i>]) · [Source](https://github.com/d3/d3-chord/blob/master/src/ribbon.js)
|
||||
|
||||
If *angle* is specified, sets the pad angle accessor to the specified function and returns this ribbon generator. If *angle* is not specified, returns the current pad angle accessor, which defaults to:
|
||||
|
||||
```js
|
||||
function padAngle() {
|
||||
return 0;
|
||||
}
|
||||
```
|
||||
|
||||
The pad angle specifies the angular gap between adjacent ribbons.
|
||||
|
||||
<a href="#ribbon_context" name="ribbon_context">#</a> <i>ribbon</i>.<b>context</b>([<i>context</i>]) · [Source](https://github.com/d3/d3-chord/blob/master/src/ribbon.js)
|
||||
|
||||
If *context* is specified, sets the context and returns this ribbon generator. If *context* is not specified, returns the current context, which defaults to null. If the context is not null, then the [generated ribbon](#_ribbon) is rendered to this context as a sequence of [path method](http://www.w3.org/TR/2dcontext/#canvaspathmethods) calls. Otherwise, a [path data](http://www.w3.org/TR/SVG/paths.html#PathData) string representing the generated ribbon is returned. See also [d3-path](https://github.com/d3/d3-path).
|
||||
|
||||
<a href="#ribbonArrow" name="ribbonArrow">#</a> d3.<b>ribbonArrow</b>() · [Source](https://github.com/d3/d3-chord/blob/master/src/ribbon.js)
|
||||
|
||||
Creates a new arrow ribbon generator with the default settings.
|
||||
|
||||
<a href="#ribbonArrow_headRadius" name="ribbonArrow_headRadius">#</a> <i>ribbonArrow</i>.<b>headRadius</b>([<i>radius</i>]) · [Source](https://github.com/d3/d3-chord/blob/master/src/ribbon.js)
|
||||
|
||||
If *radius* is specified, sets the arrowhead radius accessor to the specified function and returns this ribbon generator. If *radius* is not specified, returns the current arrowhead radius accessor, which defaults to:
|
||||
|
||||
```js
|
||||
function headRadius() {
|
||||
return 10;
|
||||
}
|
||||
```
|
||||
+284
@@ -0,0 +1,284 @@
|
||||
// https://d3js.org/d3-chord/ v3.0.1 Copyright 2010-2021 Mike Bostock
|
||||
(function (global, factory) {
|
||||
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('d3-path')) :
|
||||
typeof define === 'function' && define.amd ? define(['exports', 'd3-path'], factory) :
|
||||
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.d3 = global.d3 || {}, global.d3));
|
||||
}(this, (function (exports, d3Path) { 'use strict';
|
||||
|
||||
var abs = Math.abs;
|
||||
var cos = Math.cos;
|
||||
var sin = Math.sin;
|
||||
var pi = Math.PI;
|
||||
var halfPi = pi / 2;
|
||||
var tau = pi * 2;
|
||||
var max = Math.max;
|
||||
var epsilon = 1e-12;
|
||||
|
||||
function range(i, j) {
|
||||
return Array.from({length: j - i}, (_, k) => i + k);
|
||||
}
|
||||
|
||||
function compareValue(compare) {
|
||||
return function(a, b) {
|
||||
return compare(
|
||||
a.source.value + a.target.value,
|
||||
b.source.value + b.target.value
|
||||
);
|
||||
};
|
||||
}
|
||||
|
||||
function chord() {
|
||||
return chord$1(false, false);
|
||||
}
|
||||
|
||||
function chordTranspose() {
|
||||
return chord$1(false, true);
|
||||
}
|
||||
|
||||
function chordDirected() {
|
||||
return chord$1(true, false);
|
||||
}
|
||||
|
||||
function chord$1(directed, transpose) {
|
||||
var padAngle = 0,
|
||||
sortGroups = null,
|
||||
sortSubgroups = null,
|
||||
sortChords = null;
|
||||
|
||||
function chord(matrix) {
|
||||
var n = matrix.length,
|
||||
groupSums = new Array(n),
|
||||
groupIndex = range(0, n),
|
||||
chords = new Array(n * n),
|
||||
groups = new Array(n),
|
||||
k = 0, dx;
|
||||
|
||||
matrix = Float64Array.from({length: n * n}, transpose
|
||||
? (_, i) => matrix[i % n][i / n | 0]
|
||||
: (_, i) => matrix[i / n | 0][i % n]);
|
||||
|
||||
// Compute the scaling factor from value to angle in [0, 2pi].
|
||||
for (let i = 0; i < n; ++i) {
|
||||
let x = 0;
|
||||
for (let j = 0; j < n; ++j) x += matrix[i * n + j] + directed * matrix[j * n + i];
|
||||
k += groupSums[i] = x;
|
||||
}
|
||||
k = max(0, tau - padAngle * n) / k;
|
||||
dx = k ? padAngle : tau / n;
|
||||
|
||||
// Compute the angles for each group and constituent chord.
|
||||
{
|
||||
let x = 0;
|
||||
if (sortGroups) groupIndex.sort((a, b) => sortGroups(groupSums[a], groupSums[b]));
|
||||
for (const i of groupIndex) {
|
||||
const x0 = x;
|
||||
if (directed) {
|
||||
const subgroupIndex = range(~n + 1, n).filter(j => j < 0 ? matrix[~j * n + i] : matrix[i * n + j]);
|
||||
if (sortSubgroups) subgroupIndex.sort((a, b) => sortSubgroups(a < 0 ? -matrix[~a * n + i] : matrix[i * n + a], b < 0 ? -matrix[~b * n + i] : matrix[i * n + b]));
|
||||
for (const j of subgroupIndex) {
|
||||
if (j < 0) {
|
||||
const chord = chords[~j * n + i] || (chords[~j * n + i] = {source: null, target: null});
|
||||
chord.target = {index: i, startAngle: x, endAngle: x += matrix[~j * n + i] * k, value: matrix[~j * n + i]};
|
||||
} else {
|
||||
const chord = chords[i * n + j] || (chords[i * n + j] = {source: null, target: null});
|
||||
chord.source = {index: i, startAngle: x, endAngle: x += matrix[i * n + j] * k, value: matrix[i * n + j]};
|
||||
}
|
||||
}
|
||||
groups[i] = {index: i, startAngle: x0, endAngle: x, value: groupSums[i]};
|
||||
} else {
|
||||
const subgroupIndex = range(0, n).filter(j => matrix[i * n + j] || matrix[j * n + i]);
|
||||
if (sortSubgroups) subgroupIndex.sort((a, b) => sortSubgroups(matrix[i * n + a], matrix[i * n + b]));
|
||||
for (const j of subgroupIndex) {
|
||||
let chord;
|
||||
if (i < j) {
|
||||
chord = chords[i * n + j] || (chords[i * n + j] = {source: null, target: null});
|
||||
chord.source = {index: i, startAngle: x, endAngle: x += matrix[i * n + j] * k, value: matrix[i * n + j]};
|
||||
} else {
|
||||
chord = chords[j * n + i] || (chords[j * n + i] = {source: null, target: null});
|
||||
chord.target = {index: i, startAngle: x, endAngle: x += matrix[i * n + j] * k, value: matrix[i * n + j]};
|
||||
if (i === j) chord.source = chord.target;
|
||||
}
|
||||
if (chord.source && chord.target && chord.source.value < chord.target.value) {
|
||||
const source = chord.source;
|
||||
chord.source = chord.target;
|
||||
chord.target = source;
|
||||
}
|
||||
}
|
||||
groups[i] = {index: i, startAngle: x0, endAngle: x, value: groupSums[i]};
|
||||
}
|
||||
x += dx;
|
||||
}
|
||||
}
|
||||
|
||||
// Remove empty chords.
|
||||
chords = Object.values(chords);
|
||||
chords.groups = groups;
|
||||
return sortChords ? chords.sort(sortChords) : chords;
|
||||
}
|
||||
|
||||
chord.padAngle = function(_) {
|
||||
return arguments.length ? (padAngle = max(0, _), chord) : padAngle;
|
||||
};
|
||||
|
||||
chord.sortGroups = function(_) {
|
||||
return arguments.length ? (sortGroups = _, chord) : sortGroups;
|
||||
};
|
||||
|
||||
chord.sortSubgroups = function(_) {
|
||||
return arguments.length ? (sortSubgroups = _, chord) : sortSubgroups;
|
||||
};
|
||||
|
||||
chord.sortChords = function(_) {
|
||||
return arguments.length ? (_ == null ? sortChords = null : (sortChords = compareValue(_))._ = _, chord) : sortChords && sortChords._;
|
||||
};
|
||||
|
||||
return chord;
|
||||
}
|
||||
|
||||
var slice = Array.prototype.slice;
|
||||
|
||||
function constant(x) {
|
||||
return function() {
|
||||
return x;
|
||||
};
|
||||
}
|
||||
|
||||
function defaultSource(d) {
|
||||
return d.source;
|
||||
}
|
||||
|
||||
function defaultTarget(d) {
|
||||
return d.target;
|
||||
}
|
||||
|
||||
function defaultRadius(d) {
|
||||
return d.radius;
|
||||
}
|
||||
|
||||
function defaultStartAngle(d) {
|
||||
return d.startAngle;
|
||||
}
|
||||
|
||||
function defaultEndAngle(d) {
|
||||
return d.endAngle;
|
||||
}
|
||||
|
||||
function defaultPadAngle() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
function defaultArrowheadRadius() {
|
||||
return 10;
|
||||
}
|
||||
|
||||
function ribbon(headRadius) {
|
||||
var source = defaultSource,
|
||||
target = defaultTarget,
|
||||
sourceRadius = defaultRadius,
|
||||
targetRadius = defaultRadius,
|
||||
startAngle = defaultStartAngle,
|
||||
endAngle = defaultEndAngle,
|
||||
padAngle = defaultPadAngle,
|
||||
context = null;
|
||||
|
||||
function ribbon() {
|
||||
var buffer,
|
||||
s = source.apply(this, arguments),
|
||||
t = target.apply(this, arguments),
|
||||
ap = padAngle.apply(this, arguments) / 2,
|
||||
argv = slice.call(arguments),
|
||||
sr = +sourceRadius.apply(this, (argv[0] = s, argv)),
|
||||
sa0 = startAngle.apply(this, argv) - halfPi,
|
||||
sa1 = endAngle.apply(this, argv) - halfPi,
|
||||
tr = +targetRadius.apply(this, (argv[0] = t, argv)),
|
||||
ta0 = startAngle.apply(this, argv) - halfPi,
|
||||
ta1 = endAngle.apply(this, argv) - halfPi;
|
||||
|
||||
if (!context) context = buffer = d3Path.path();
|
||||
|
||||
if (ap > epsilon) {
|
||||
if (abs(sa1 - sa0) > ap * 2 + epsilon) sa1 > sa0 ? (sa0 += ap, sa1 -= ap) : (sa0 -= ap, sa1 += ap);
|
||||
else sa0 = sa1 = (sa0 + sa1) / 2;
|
||||
if (abs(ta1 - ta0) > ap * 2 + epsilon) ta1 > ta0 ? (ta0 += ap, ta1 -= ap) : (ta0 -= ap, ta1 += ap);
|
||||
else ta0 = ta1 = (ta0 + ta1) / 2;
|
||||
}
|
||||
|
||||
context.moveTo(sr * cos(sa0), sr * sin(sa0));
|
||||
context.arc(0, 0, sr, sa0, sa1);
|
||||
if (sa0 !== ta0 || sa1 !== ta1) {
|
||||
if (headRadius) {
|
||||
var hr = +headRadius.apply(this, arguments), tr2 = tr - hr, ta2 = (ta0 + ta1) / 2;
|
||||
context.quadraticCurveTo(0, 0, tr2 * cos(ta0), tr2 * sin(ta0));
|
||||
context.lineTo(tr * cos(ta2), tr * sin(ta2));
|
||||
context.lineTo(tr2 * cos(ta1), tr2 * sin(ta1));
|
||||
} else {
|
||||
context.quadraticCurveTo(0, 0, tr * cos(ta0), tr * sin(ta0));
|
||||
context.arc(0, 0, tr, ta0, ta1);
|
||||
}
|
||||
}
|
||||
context.quadraticCurveTo(0, 0, sr * cos(sa0), sr * sin(sa0));
|
||||
context.closePath();
|
||||
|
||||
if (buffer) return context = null, buffer + "" || null;
|
||||
}
|
||||
|
||||
if (headRadius) ribbon.headRadius = function(_) {
|
||||
return arguments.length ? (headRadius = typeof _ === "function" ? _ : constant(+_), ribbon) : headRadius;
|
||||
};
|
||||
|
||||
ribbon.radius = function(_) {
|
||||
return arguments.length ? (sourceRadius = targetRadius = typeof _ === "function" ? _ : constant(+_), ribbon) : sourceRadius;
|
||||
};
|
||||
|
||||
ribbon.sourceRadius = function(_) {
|
||||
return arguments.length ? (sourceRadius = typeof _ === "function" ? _ : constant(+_), ribbon) : sourceRadius;
|
||||
};
|
||||
|
||||
ribbon.targetRadius = function(_) {
|
||||
return arguments.length ? (targetRadius = typeof _ === "function" ? _ : constant(+_), ribbon) : targetRadius;
|
||||
};
|
||||
|
||||
ribbon.startAngle = function(_) {
|
||||
return arguments.length ? (startAngle = typeof _ === "function" ? _ : constant(+_), ribbon) : startAngle;
|
||||
};
|
||||
|
||||
ribbon.endAngle = function(_) {
|
||||
return arguments.length ? (endAngle = typeof _ === "function" ? _ : constant(+_), ribbon) : endAngle;
|
||||
};
|
||||
|
||||
ribbon.padAngle = function(_) {
|
||||
return arguments.length ? (padAngle = typeof _ === "function" ? _ : constant(+_), ribbon) : padAngle;
|
||||
};
|
||||
|
||||
ribbon.source = function(_) {
|
||||
return arguments.length ? (source = _, ribbon) : source;
|
||||
};
|
||||
|
||||
ribbon.target = function(_) {
|
||||
return arguments.length ? (target = _, ribbon) : target;
|
||||
};
|
||||
|
||||
ribbon.context = function(_) {
|
||||
return arguments.length ? ((context = _ == null ? null : _), ribbon) : context;
|
||||
};
|
||||
|
||||
return ribbon;
|
||||
}
|
||||
|
||||
function ribbon$1() {
|
||||
return ribbon();
|
||||
}
|
||||
|
||||
function ribbonArrow() {
|
||||
return ribbon(defaultArrowheadRadius);
|
||||
}
|
||||
|
||||
exports.chord = chord;
|
||||
exports.chordDirected = chordDirected;
|
||||
exports.chordTranspose = chordTranspose;
|
||||
exports.ribbon = ribbon$1;
|
||||
exports.ribbonArrow = ribbonArrow;
|
||||
|
||||
Object.defineProperty(exports, '__esModule', { value: true });
|
||||
|
||||
})));
|
||||
+2
@@ -0,0 +1,2 @@
|
||||
// https://d3js.org/d3-chord/ v3.0.1 Copyright 2010-2021 Mike Bostock
|
||||
!function(n,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("d3-path")):"function"==typeof define&&define.amd?define(["exports","d3-path"],t):t((n="undefined"!=typeof globalThis?globalThis:n||self).d3=n.d3||{},n.d3)}(this,(function(n,t){"use strict";var e=Math.abs,r=Math.cos,u=Math.sin,o=Math.PI,l=o/2,i=2*o,a=Math.max,c=1e-12;function f(n,t){return Array.from({length:t-n},((t,e)=>n+e))}function s(n){return function(t,e){return n(t.source.value+t.target.value,e.source.value+e.target.value)}}function g(n,t){var e=0,r=null,u=null,o=null;function l(l){var c,s=l.length,g=new Array(s),d=f(0,s),p=new Array(s*s),h=new Array(s),y=0;l=Float64Array.from({length:s*s},t?(n,t)=>l[t%s][t/s|0]:(n,t)=>l[t/s|0][t%s]);for(let t=0;t<s;++t){let e=0;for(let r=0;r<s;++r)e+=l[t*s+r]+n*l[r*s+t];y+=g[t]=e}c=(y=a(0,i-e*s)/y)?e:i/s;{let t=0;r&&d.sort(((n,t)=>r(g[n],g[t])));for(const e of d){const r=t;if(n){const n=f(1+~s,s).filter((n=>n<0?l[~n*s+e]:l[e*s+n]));u&&n.sort(((n,t)=>u(n<0?-l[~n*s+e]:l[e*s+n],t<0?-l[~t*s+e]:l[e*s+t])));for(const r of n)if(r<0){(p[~r*s+e]||(p[~r*s+e]={source:null,target:null})).target={index:e,startAngle:t,endAngle:t+=l[~r*s+e]*y,value:l[~r*s+e]}}else{(p[e*s+r]||(p[e*s+r]={source:null,target:null})).source={index:e,startAngle:t,endAngle:t+=l[e*s+r]*y,value:l[e*s+r]}}h[e]={index:e,startAngle:r,endAngle:t,value:g[e]}}else{const n=f(0,s).filter((n=>l[e*s+n]||l[n*s+e]));u&&n.sort(((n,t)=>u(l[e*s+n],l[e*s+t])));for(const r of n){let n;if(e<r?(n=p[e*s+r]||(p[e*s+r]={source:null,target:null}),n.source={index:e,startAngle:t,endAngle:t+=l[e*s+r]*y,value:l[e*s+r]}):(n=p[r*s+e]||(p[r*s+e]={source:null,target:null}),n.target={index:e,startAngle:t,endAngle:t+=l[e*s+r]*y,value:l[e*s+r]},e===r&&(n.source=n.target)),n.source&&n.target&&n.source.value<n.target.value){const t=n.source;n.source=n.target,n.target=t}}h[e]={index:e,startAngle:r,endAngle:t,value:g[e]}}t+=c}}return(p=Object.values(p)).groups=h,o?p.sort(o):p}return l.padAngle=function(n){return arguments.length?(e=a(0,n),l):e},l.sortGroups=function(n){return arguments.length?(r=n,l):r},l.sortSubgroups=function(n){return arguments.length?(u=n,l):u},l.sortChords=function(n){return arguments.length?(null==n?o=null:(o=s(n))._=n,l):o&&o._},l}var d=Array.prototype.slice;function p(n){return function(){return n}}function h(n){return n.source}function y(n){return n.target}function v(n){return n.radius}function A(n){return n.startAngle}function b(n){return n.endAngle}function x(){return 0}function T(){return 10}function m(n){var o=h,i=y,a=v,f=v,s=A,g=b,T=x,m=null;function M(){var p,h=o.apply(this,arguments),y=i.apply(this,arguments),v=T.apply(this,arguments)/2,A=d.call(arguments),b=+a.apply(this,(A[0]=h,A)),x=s.apply(this,A)-l,M=g.apply(this,A)-l,q=+f.apply(this,(A[0]=y,A)),w=s.apply(this,A)-l,C=g.apply(this,A)-l;if(m||(m=p=t.path()),v>c&&(e(M-x)>2*v+c?M>x?(x+=v,M-=v):(x-=v,M+=v):x=M=(x+M)/2,e(C-w)>2*v+c?C>w?(w+=v,C-=v):(w-=v,C+=v):w=C=(w+C)/2),m.moveTo(b*r(x),b*u(x)),m.arc(0,0,b,x,M),x!==w||M!==C)if(n){var _=+n.apply(this,arguments),j=q-_,P=(w+C)/2;m.quadraticCurveTo(0,0,j*r(w),j*u(w)),m.lineTo(q*r(P),q*u(P)),m.lineTo(j*r(C),j*u(C))}else m.quadraticCurveTo(0,0,q*r(w),q*u(w)),m.arc(0,0,q,w,C);if(m.quadraticCurveTo(0,0,b*r(x),b*u(x)),m.closePath(),p)return m=null,p+""||null}return n&&(M.headRadius=function(t){return arguments.length?(n="function"==typeof t?t:p(+t),M):n}),M.radius=function(n){return arguments.length?(a=f="function"==typeof n?n:p(+n),M):a},M.sourceRadius=function(n){return arguments.length?(a="function"==typeof n?n:p(+n),M):a},M.targetRadius=function(n){return arguments.length?(f="function"==typeof n?n:p(+n),M):f},M.startAngle=function(n){return arguments.length?(s="function"==typeof n?n:p(+n),M):s},M.endAngle=function(n){return arguments.length?(g="function"==typeof n?n:p(+n),M):g},M.padAngle=function(n){return arguments.length?(T="function"==typeof n?n:p(+n),M):T},M.source=function(n){return arguments.length?(o=n,M):o},M.target=function(n){return arguments.length?(i=n,M):i},M.context=function(n){return arguments.length?(m=null==n?null:n,M):m},M}n.chord=function(){return g(!1,!1)},n.chordDirected=function(){return g(!0,!1)},n.chordTranspose=function(){return g(!1,!0)},n.ribbon=function(){return m()},n.ribbonArrow=function(){return m(T)},Object.defineProperty(n,"__esModule",{value:!0})}));
|
||||
+54
@@ -0,0 +1,54 @@
|
||||
{
|
||||
"name": "d3-chord",
|
||||
"version": "3.0.1",
|
||||
"description": "Visualize relationships or network flow with an aesthetically-pleasing circular layout.",
|
||||
"homepage": "https://d3js.org/d3-chord/",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/d3/d3-chord.git"
|
||||
},
|
||||
"keywords": [
|
||||
"d3",
|
||||
"d3-module",
|
||||
"chord",
|
||||
"radial",
|
||||
"network",
|
||||
"flow"
|
||||
],
|
||||
"license": "ISC",
|
||||
"author": {
|
||||
"name": "Mike Bostock",
|
||||
"url": "http://bost.ocks.org/mike"
|
||||
},
|
||||
"type": "module",
|
||||
"files": [
|
||||
"dist/**/*.js",
|
||||
"src/**/*.js"
|
||||
],
|
||||
"module": "src/index.js",
|
||||
"main": "src/index.js",
|
||||
"jsdelivr": "dist/d3-chord.min.js",
|
||||
"unpkg": "dist/d3-chord.min.js",
|
||||
"exports": {
|
||||
"umd": "./dist/d3-chord.min.js",
|
||||
"default": "./src/index.js"
|
||||
},
|
||||
"sideEffects": false,
|
||||
"dependencies": {
|
||||
"d3-path": "1 - 3"
|
||||
},
|
||||
"devDependencies": {
|
||||
"eslint": "7",
|
||||
"mocha": "8",
|
||||
"rollup": "2",
|
||||
"rollup-plugin-terser": "7"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "mocha 'test/**/*-test.js' && eslint src test",
|
||||
"prepublishOnly": "rm -rf dist && yarn test && rollup -c",
|
||||
"postpublish": "git push && git push --tags && cd ../d3.github.com && git pull && cp ../${npm_package_name}/dist/${npm_package_name}.js ${npm_package_name}.v${npm_package_version%%.*}.js && cp ../${npm_package_name}/dist/${npm_package_name}.min.js ${npm_package_name}.v${npm_package_version%%.*}.min.js && git add ${npm_package_name}.v${npm_package_version%%.*}.js ${npm_package_name}.v${npm_package_version%%.*}.min.js && git commit -m \"${npm_package_name} ${npm_package_version}\" && git push && cd -"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=12"
|
||||
}
|
||||
}
|
||||
+1
@@ -0,0 +1 @@
|
||||
export var slice = Array.prototype.slice;
|
||||
+122
@@ -0,0 +1,122 @@
|
||||
import {max, tau} from "./math.js";
|
||||
|
||||
function range(i, j) {
|
||||
return Array.from({length: j - i}, (_, k) => i + k);
|
||||
}
|
||||
|
||||
function compareValue(compare) {
|
||||
return function(a, b) {
|
||||
return compare(
|
||||
a.source.value + a.target.value,
|
||||
b.source.value + b.target.value
|
||||
);
|
||||
};
|
||||
}
|
||||
|
||||
export default function() {
|
||||
return chord(false, false);
|
||||
}
|
||||
|
||||
export function chordTranspose() {
|
||||
return chord(false, true);
|
||||
}
|
||||
|
||||
export function chordDirected() {
|
||||
return chord(true, false);
|
||||
}
|
||||
|
||||
function chord(directed, transpose) {
|
||||
var padAngle = 0,
|
||||
sortGroups = null,
|
||||
sortSubgroups = null,
|
||||
sortChords = null;
|
||||
|
||||
function chord(matrix) {
|
||||
var n = matrix.length,
|
||||
groupSums = new Array(n),
|
||||
groupIndex = range(0, n),
|
||||
chords = new Array(n * n),
|
||||
groups = new Array(n),
|
||||
k = 0, dx;
|
||||
|
||||
matrix = Float64Array.from({length: n * n}, transpose
|
||||
? (_, i) => matrix[i % n][i / n | 0]
|
||||
: (_, i) => matrix[i / n | 0][i % n]);
|
||||
|
||||
// Compute the scaling factor from value to angle in [0, 2pi].
|
||||
for (let i = 0; i < n; ++i) {
|
||||
let x = 0;
|
||||
for (let j = 0; j < n; ++j) x += matrix[i * n + j] + directed * matrix[j * n + i];
|
||||
k += groupSums[i] = x;
|
||||
}
|
||||
k = max(0, tau - padAngle * n) / k;
|
||||
dx = k ? padAngle : tau / n;
|
||||
|
||||
// Compute the angles for each group and constituent chord.
|
||||
{
|
||||
let x = 0;
|
||||
if (sortGroups) groupIndex.sort((a, b) => sortGroups(groupSums[a], groupSums[b]));
|
||||
for (const i of groupIndex) {
|
||||
const x0 = x;
|
||||
if (directed) {
|
||||
const subgroupIndex = range(~n + 1, n).filter(j => j < 0 ? matrix[~j * n + i] : matrix[i * n + j]);
|
||||
if (sortSubgroups) subgroupIndex.sort((a, b) => sortSubgroups(a < 0 ? -matrix[~a * n + i] : matrix[i * n + a], b < 0 ? -matrix[~b * n + i] : matrix[i * n + b]));
|
||||
for (const j of subgroupIndex) {
|
||||
if (j < 0) {
|
||||
const chord = chords[~j * n + i] || (chords[~j * n + i] = {source: null, target: null});
|
||||
chord.target = {index: i, startAngle: x, endAngle: x += matrix[~j * n + i] * k, value: matrix[~j * n + i]};
|
||||
} else {
|
||||
const chord = chords[i * n + j] || (chords[i * n + j] = {source: null, target: null});
|
||||
chord.source = {index: i, startAngle: x, endAngle: x += matrix[i * n + j] * k, value: matrix[i * n + j]};
|
||||
}
|
||||
}
|
||||
groups[i] = {index: i, startAngle: x0, endAngle: x, value: groupSums[i]};
|
||||
} else {
|
||||
const subgroupIndex = range(0, n).filter(j => matrix[i * n + j] || matrix[j * n + i]);
|
||||
if (sortSubgroups) subgroupIndex.sort((a, b) => sortSubgroups(matrix[i * n + a], matrix[i * n + b]));
|
||||
for (const j of subgroupIndex) {
|
||||
let chord;
|
||||
if (i < j) {
|
||||
chord = chords[i * n + j] || (chords[i * n + j] = {source: null, target: null});
|
||||
chord.source = {index: i, startAngle: x, endAngle: x += matrix[i * n + j] * k, value: matrix[i * n + j]};
|
||||
} else {
|
||||
chord = chords[j * n + i] || (chords[j * n + i] = {source: null, target: null});
|
||||
chord.target = {index: i, startAngle: x, endAngle: x += matrix[i * n + j] * k, value: matrix[i * n + j]};
|
||||
if (i === j) chord.source = chord.target;
|
||||
}
|
||||
if (chord.source && chord.target && chord.source.value < chord.target.value) {
|
||||
const source = chord.source;
|
||||
chord.source = chord.target;
|
||||
chord.target = source;
|
||||
}
|
||||
}
|
||||
groups[i] = {index: i, startAngle: x0, endAngle: x, value: groupSums[i]};
|
||||
}
|
||||
x += dx;
|
||||
}
|
||||
}
|
||||
|
||||
// Remove empty chords.
|
||||
chords = Object.values(chords);
|
||||
chords.groups = groups;
|
||||
return sortChords ? chords.sort(sortChords) : chords;
|
||||
}
|
||||
|
||||
chord.padAngle = function(_) {
|
||||
return arguments.length ? (padAngle = max(0, _), chord) : padAngle;
|
||||
};
|
||||
|
||||
chord.sortGroups = function(_) {
|
||||
return arguments.length ? (sortGroups = _, chord) : sortGroups;
|
||||
};
|
||||
|
||||
chord.sortSubgroups = function(_) {
|
||||
return arguments.length ? (sortSubgroups = _, chord) : sortSubgroups;
|
||||
};
|
||||
|
||||
chord.sortChords = function(_) {
|
||||
return arguments.length ? (_ == null ? sortChords = null : (sortChords = compareValue(_))._ = _, chord) : sortChords && sortChords._;
|
||||
};
|
||||
|
||||
return chord;
|
||||
}
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
export default function(x) {
|
||||
return function() {
|
||||
return x;
|
||||
};
|
||||
}
|
||||
+2
@@ -0,0 +1,2 @@
|
||||
export {default as chord, chordTranspose, chordDirected} from "./chord.js";
|
||||
export {default as ribbon, ribbonArrow} from "./ribbon.js";
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
export var abs = Math.abs;
|
||||
export var cos = Math.cos;
|
||||
export var sin = Math.sin;
|
||||
export var pi = Math.PI;
|
||||
export var halfPi = pi / 2;
|
||||
export var tau = pi * 2;
|
||||
export var max = Math.max;
|
||||
export var epsilon = 1e-12;
|
||||
+134
@@ -0,0 +1,134 @@
|
||||
import {path} from "d3-path";
|
||||
import {slice} from "./array.js";
|
||||
import constant from "./constant.js";
|
||||
import {abs, cos, epsilon, halfPi, sin} from "./math.js";
|
||||
|
||||
function defaultSource(d) {
|
||||
return d.source;
|
||||
}
|
||||
|
||||
function defaultTarget(d) {
|
||||
return d.target;
|
||||
}
|
||||
|
||||
function defaultRadius(d) {
|
||||
return d.radius;
|
||||
}
|
||||
|
||||
function defaultStartAngle(d) {
|
||||
return d.startAngle;
|
||||
}
|
||||
|
||||
function defaultEndAngle(d) {
|
||||
return d.endAngle;
|
||||
}
|
||||
|
||||
function defaultPadAngle() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
function defaultArrowheadRadius() {
|
||||
return 10;
|
||||
}
|
||||
|
||||
function ribbon(headRadius) {
|
||||
var source = defaultSource,
|
||||
target = defaultTarget,
|
||||
sourceRadius = defaultRadius,
|
||||
targetRadius = defaultRadius,
|
||||
startAngle = defaultStartAngle,
|
||||
endAngle = defaultEndAngle,
|
||||
padAngle = defaultPadAngle,
|
||||
context = null;
|
||||
|
||||
function ribbon() {
|
||||
var buffer,
|
||||
s = source.apply(this, arguments),
|
||||
t = target.apply(this, arguments),
|
||||
ap = padAngle.apply(this, arguments) / 2,
|
||||
argv = slice.call(arguments),
|
||||
sr = +sourceRadius.apply(this, (argv[0] = s, argv)),
|
||||
sa0 = startAngle.apply(this, argv) - halfPi,
|
||||
sa1 = endAngle.apply(this, argv) - halfPi,
|
||||
tr = +targetRadius.apply(this, (argv[0] = t, argv)),
|
||||
ta0 = startAngle.apply(this, argv) - halfPi,
|
||||
ta1 = endAngle.apply(this, argv) - halfPi;
|
||||
|
||||
if (!context) context = buffer = path();
|
||||
|
||||
if (ap > epsilon) {
|
||||
if (abs(sa1 - sa0) > ap * 2 + epsilon) sa1 > sa0 ? (sa0 += ap, sa1 -= ap) : (sa0 -= ap, sa1 += ap);
|
||||
else sa0 = sa1 = (sa0 + sa1) / 2;
|
||||
if (abs(ta1 - ta0) > ap * 2 + epsilon) ta1 > ta0 ? (ta0 += ap, ta1 -= ap) : (ta0 -= ap, ta1 += ap);
|
||||
else ta0 = ta1 = (ta0 + ta1) / 2;
|
||||
}
|
||||
|
||||
context.moveTo(sr * cos(sa0), sr * sin(sa0));
|
||||
context.arc(0, 0, sr, sa0, sa1);
|
||||
if (sa0 !== ta0 || sa1 !== ta1) {
|
||||
if (headRadius) {
|
||||
var hr = +headRadius.apply(this, arguments), tr2 = tr - hr, ta2 = (ta0 + ta1) / 2;
|
||||
context.quadraticCurveTo(0, 0, tr2 * cos(ta0), tr2 * sin(ta0));
|
||||
context.lineTo(tr * cos(ta2), tr * sin(ta2));
|
||||
context.lineTo(tr2 * cos(ta1), tr2 * sin(ta1));
|
||||
} else {
|
||||
context.quadraticCurveTo(0, 0, tr * cos(ta0), tr * sin(ta0));
|
||||
context.arc(0, 0, tr, ta0, ta1);
|
||||
}
|
||||
}
|
||||
context.quadraticCurveTo(0, 0, sr * cos(sa0), sr * sin(sa0));
|
||||
context.closePath();
|
||||
|
||||
if (buffer) return context = null, buffer + "" || null;
|
||||
}
|
||||
|
||||
if (headRadius) ribbon.headRadius = function(_) {
|
||||
return arguments.length ? (headRadius = typeof _ === "function" ? _ : constant(+_), ribbon) : headRadius;
|
||||
};
|
||||
|
||||
ribbon.radius = function(_) {
|
||||
return arguments.length ? (sourceRadius = targetRadius = typeof _ === "function" ? _ : constant(+_), ribbon) : sourceRadius;
|
||||
};
|
||||
|
||||
ribbon.sourceRadius = function(_) {
|
||||
return arguments.length ? (sourceRadius = typeof _ === "function" ? _ : constant(+_), ribbon) : sourceRadius;
|
||||
};
|
||||
|
||||
ribbon.targetRadius = function(_) {
|
||||
return arguments.length ? (targetRadius = typeof _ === "function" ? _ : constant(+_), ribbon) : targetRadius;
|
||||
};
|
||||
|
||||
ribbon.startAngle = function(_) {
|
||||
return arguments.length ? (startAngle = typeof _ === "function" ? _ : constant(+_), ribbon) : startAngle;
|
||||
};
|
||||
|
||||
ribbon.endAngle = function(_) {
|
||||
return arguments.length ? (endAngle = typeof _ === "function" ? _ : constant(+_), ribbon) : endAngle;
|
||||
};
|
||||
|
||||
ribbon.padAngle = function(_) {
|
||||
return arguments.length ? (padAngle = typeof _ === "function" ? _ : constant(+_), ribbon) : padAngle;
|
||||
};
|
||||
|
||||
ribbon.source = function(_) {
|
||||
return arguments.length ? (source = _, ribbon) : source;
|
||||
};
|
||||
|
||||
ribbon.target = function(_) {
|
||||
return arguments.length ? (target = _, ribbon) : target;
|
||||
};
|
||||
|
||||
ribbon.context = function(_) {
|
||||
return arguments.length ? ((context = _ == null ? null : _), ribbon) : context;
|
||||
};
|
||||
|
||||
return ribbon;
|
||||
}
|
||||
|
||||
export default function() {
|
||||
return ribbon();
|
||||
}
|
||||
|
||||
export function ribbonArrow() {
|
||||
return ribbon(defaultArrowheadRadius);
|
||||
}
|
||||
Reference in New Issue
Block a user