{"name":"d3-chord","version":"2.0.0-rc.1","publishConfig":{"tag":"next"},"description":"Visualize relationships or network flow with an aesthetically-pleasing circular layout.","keywords":["d3","d3-module","chord","radial","network","flow"],"homepage":"https://d3js.org/d3-chord/","license":"BSD-3-Clause","author":{"name":"Mike Bostock","url":"http://bost.ocks.org/mike"},"main":"dist/d3-chord.js","unpkg":"dist/d3-chord.min.js","jsdelivr":"dist/d3-chord.min.js","module":"src/index.js","repository":{"type":"git","url":"git+https://github.com/d3/d3-chord.git"},"scripts":{"pretest":"rollup -c","test":"tape 'test/**/*-test.js' && eslint src","prepublishOnly":"rm -rf dist && yarn test"},"dependencies":{"d3-path":"1"},"devDependencies":{"eslint":"6","rollup":"1","rollup-plugin-terser":"5","tape":"4"},"readme":"# d3-chord\n\nVisualize relationships or network flow with an aesthetically-pleasing circular layout.\n\n[<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)\n\n## Installing\n\nIf you use NPM, `npm install d3-chord`. Otherwise, download the [latest release](https://github.com/d3/d3-chord/releases/latest). You can also load directly from [d3js.org](https://d3js.org), either as a [standalone library](https://d3js.org/d3-chord.v2.min.js) or as part of [D3](https://github.com/d3/d3). AMD, CommonJS, and vanilla environments are supported. In vanilla, a `d3` global is exported:\n\n```html\n<script src=\"https://d3js.org/d3-path.v1.min.js\"></script>\n<script src=\"https://d3js.org/d3-chord.v2.min.js\"></script>\n<script>\n\nvar chord = d3.chord();\n\n</script>\n```\n\n## API Reference\n\n<a href=\"#chord\" name=\"chord\">#</a> d3.<b>chord</b>() [<>](https://github.com/d3/d3-chord/blob/master/src/chord.js \"Source\")\n\nConstructs a new chord layout with the default settings.\n\n<a href=\"#_chord\" name=\"_chord\">#</a> <i>chord</i>(<i>matrix</i>) [<>](https://github.com/d3/d3-chord/blob/master/src/chord.js \"Source\")\n\nComputes 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/):\n\n```js\nvar matrix = [\n  [11975,  5871, 8916, 2868],\n  [ 1951, 10048, 2060, 6171],\n  [ 8010, 16145, 8090, 8045],\n  [ 1013,   990,  940, 6907]\n];\n```\n\nThe 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:\n\n* `source` - the source subgroup\n* `target` - the target subgroup\n\nEach source and target subgroup is also an object with the following properties:\n\n* `startAngle` - the start angle in radians\n* `endAngle` - the end angle in radians\n* `value` - the flow value *matrix*[*i*][*j*]\n* `index` - the node index *i*\n* `subindex` - the node index *j*\n\nThe 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*]. In other words, *chord*.source.index equals *chord*.target.subindex, *chord*.source.subindex equals *chord*.target.index, *chord*.source.value is greater than or equal to *chord*.target.value, and *chord*.source.value is always greater than zero.\n\nThe *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:\n\n* `startAngle` - the start angle in radians\n* `endAngle` - the end angle in radians\n* `value` - the total outgoing flow value for node *i*\n* `index` - the node index *i*\n\nThe 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.\n\n<a href=\"#chord_padAngle\" name=\"#chord_padAngle\">#</a> <i>chord</i>.<b>padAngle</b>([<i>angle</i>]) [<>](https://github.com/d3/d3-chord/blob/master/src/chord.js \"Source\")\n\nIf *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.\n\n<a href=\"#chord_sortGroups\" name=\"#chord_sortGroups\">#</a> <i>chord</i>.<b>sortGroups</b>([<i>compare</i>]) [<>](https://github.com/d3/d3-chord/blob/master/src/chord.js \"Source\")\n\nIf *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).\n\n<a href=\"#chord_sortSubgroups\" name=\"#chord_sortSubgroups\">#</a> <i>chord</i>.<b>sortSubgroups</b>([<i>compare</i>]) [<>](https://github.com/d3/d3-chord/blob/master/src/chord.js \"Source\")\n\nIf *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).\n\n<a href=\"#chord_sortChords\" name=\"#chord_sortChords\">#</a> <i>chord</i>.<b>sortChords</b>([<i>compare</i>]) [<>](https://github.com/d3/d3-chord/blob/master/src/chord.js \"Source\")\n\nIf *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).\n\n<a href=\"#ribbon\" name=\"ribbon\">#</a> d3.<b>ribbon</b>() [<>](https://github.com/d3/d3-chord/blob/master/src/ribbon.js \"Source\")\n\nCreates a new ribbon generator with the default settings.\n\n<a href=\"#_ribbon\" name=\"_ribbon\">#</a> <i>ribbon</i>(<i>arguments…</i>) [<>](https://github.com/d3/d3-chord/blob/master/src/ribbon.js \"Source\")\n\nGenerates 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:\n\n```js\nvar ribbon = d3.ribbon();\n\nribbon({\n  source: {startAngle: 0.7524114, endAngle: 1.1212972, radius: 240},\n  target: {startAngle: 1.8617078, endAngle: 1.9842927, radius: 240}\n}); // \"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\"\n```\n\nOr equivalently if the radius is instead defined as a constant:\n\n```js\nvar ribbon = d3.ribbon()\n    .radius(240);\n\nribbon({\n  source: {startAngle: 0.7524114, endAngle: 1.1212972},\n  target: {startAngle: 1.8617078, endAngle: 1.9842927}\n}); // \"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\"\n```\n\nIf 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.\n\n<a href=\"#ribbon_source\" name=\"ribbon_source\">#</a> <i>ribbon</i>.<b>source</b>([<i>source</i>]) [<>](https://github.com/d3/d3-chord/blob/master/src/ribbon.js \"Source\")\n\nIf *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:\n\n```js\nfunction source(d) {\n  return d.source;\n}\n```\n\n<a href=\"#ribbon_target\" name=\"ribbon_target\">#</a> <i>ribbon</i>.<b>target</b>([<i>target</i>]) [<>](https://github.com/d3/d3-chord/blob/master/src/ribbon.js \"Source\")\n\nIf *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:\n\n```js\nfunction target(d) {\n  return d.target;\n}\n```\n\n<a href=\"#ribbon_radius\" name=\"ribbon_radius\">#</a> <i>ribbon</i>.<b>radius</b>([<i>radius</i>]) [<>](https://github.com/d3/d3-chord/blob/master/src/ribbon.js \"Source\")\n\nIf *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:\n\n```js\nfunction radius(d) {\n  return d.radius;\n}\n```\n\n<a href=\"#ribbon_sourceRadius\" name=\"ribbon_sourceRadius\">#</a> <i>ribbon</i>.<b>sourceRadius</b>([<i>radius</i>]) [<>](https://github.com/d3/d3-chord/blob/master/src/ribbon.js \"Source\")\n\nIf *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:\n\n```js\nfunction radius(d) {\n  return d.radius;\n}\n```\n\n<a href=\"#ribbon_targetRadius\" name=\"ribbon_targetRadius\">#</a> <i>ribbon</i>.<b>targetRadius</b>([<i>radius</i>]) [<>](https://github.com/d3/d3-chord/blob/master/src/ribbon.js \"Source\")\n\nIf *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:\n\n```js\nfunction radius(d) {\n  return d.radius;\n}\n```\n\nBy 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.\n\n<a href=\"#ribbon_startAngle\" name=\"ribbon_startAngle\">#</a> <i>ribbon</i>.<b>startAngle</b>([<i>angle</i>]) [<>](https://github.com/d3/d3-chord/blob/master/src/ribbon.js \"Source\")\n\nIf *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:\n\n```js\nfunction startAngle(d) {\n  return d.startAngle;\n}\n```\n\nThe *angle* is specified in radians, with 0 at -*y* (12 o’clock) and positive angles proceeding clockwise.\n\n<a href=\"#ribbon_endAngle\" name=\"ribbon_endAngle\">#</a> <i>ribbon</i>.<b>endAngle</b>([<i>angle</i>]) [<>](https://github.com/d3/d3-chord/blob/master/src/ribbon.js \"Source\")\n\nIf *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:\n\n```js\nfunction endAngle(d) {\n  return d.endAngle;\n}\n```\n\nThe *angle* is specified in radians, with 0 at -*y* (12 o’clock) and positive angles proceeding clockwise.\n\n<a href=\"#ribbon_context\" name=\"ribbon_context\">#</a> <i>ribbon</i>.<b>context</b>([<i>context</i>]) [<>](https://github.com/d3/d3-chord/blob/master/src/ribbon.js \"Source\")\n\nIf *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).\n\n<a href=\"#ribbonArrow\" name=\"ribbonArrow\">#</a> d3.<b>ribbonArrow</b>() [<>](https://github.com/d3/d3-chord/blob/master/src/ribbon.js \"Source\")\n\nCreates a new arrow ribbon generator with the default settings.\n\n<a href=\"#ribbonArrow_headRadius\" name=\"ribbonArrow_headRadius\">#</a> <i>ribbonArrow</i>.<b>headRadius</b>([<i>radius</i>]) [<>](https://github.com/d3/d3-chord/blob/master/src/ribbon.js \"Source\")\n\nIf *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:\n\n```js\nfunction headRadius() {\n  return 10;\n}\n```\n","readmeFilename":"README.md","gitHead":"982e658c76a8c37c3980798678356efd1f69688e","bugs":{"url":"https://github.com/d3/d3-chord/issues"},"_id":"d3-chord@2.0.0-rc.1","_nodeVersion":"10.16.3","_npmVersion":"6.9.0","dist":{"integrity":"sha512-UTXXhec7WAfxMfXjBGSMOuVw1b0AMKcjPZOW1DVn8vom9v78xhWh3YZEzemmN91U1mycSSmPPz/yZ2xsyOrKKg==","shasum":"0581a8bd53384fd3610dd16365bb6f9e0e6f306b","tarball":"http://registry-npm.ywwl.com/d3-chord/download/d3-chord-2.0.0-rc.1.tgz","fileCount":11,"unpackedSize":32666,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJd2r4rCRA9TVsSAnZWagAAsqcP/07cbka5Wrh0TeCOaAsJ\nMy07MQV5XXTBhcQVrdQPpXspnARXJrNcPkZ6lDgwbqQXlleZsdw0ci+ym5si\nZrK0bMzaa10Bm459lfVLzj0QabUfcbC15AgBB1s91x+gZqwFGtLeIOcma8iS\nJzd9FEwHMPRzkikIOsDPBV+cTJ9Y0zLvWqzo9/+aC374Jqr6iqy5QeD/i+LM\nY6yw17ndSR3IbAb+Z7Lpm/0OBsdchsP5EvpefoqU48EefQ9F5PyXzsGw0mcn\nQnu7TLC2AL3FdzyWhsmJL4bVKOoOegb4QaFaUa3a/fgrgBqMQjDp3Nljk4Jk\nC15vGqlDySSqc1MAUmZQijnU3FpzhNYaPCWHqFKMAfLlRLZo7OeSrT+7uJlB\nx960sYP46773chVNHzlyTdvfQnaOpANvJNqVIjrLOIwkXc6IOG4Ox8FQdYdx\nFepY1fH0Fwc0jD0/ISnqmfWFde19oYt0s4mxYNUkCe/eWMgR6iR44kh9sIxG\nYYzK+r/hltwLgCa37ZYrDHoNAYDitcUSHYhuA7Sqb7hTyLqa7d17X18IDr5a\nrl4t8q68uvnazWUsrkmMhwlGALEMBnU49+yMonM7CjmsEqPJ7fMtL04zK3IV\n6ENlyWwGIpzNY6UUn67Khd4fgsjBwOq+5lFRDA7iUHUpvwXk2oOfeIMCxg1T\nMwQ5\r\n=wwG6\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIBGofcN2W+gFp77edb+i6QZ+vpsKLQD0qZMm9/+gdow+AiEAiqOLPB21Q8qQA112/p8j2a91ARC7t2IQqejAdm4rwOU="}],"size":7978,"noattachment":false,"key":"/d3-chord/-/d3-chord-2.0.0-rc.1.tgz"},"maintainers":[{"name":"mbostock","email":"mike@ocks.org"}],"_npmUser":{"name":"mbostock","email":"mike@ocks.org"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/d3-chord_2.0.0-rc.1_1574616619365_0.7809758961821205"},"_hasShrinkwrap":false,"publish_time":1574616619453,"_cnpm_publish_time":1574616619453,"dist-tags":{"latest":"3.0.2"}}