UNPKG

@dfnivo/sankey

Version:

<a href="https://nivo.rocks"><img alt="nivo" src="https://raw.githubusercontent.com/plouc/nivo/master/nivo.png" width="216" height="68"/></a>

117 lines (116 loc) 3.34 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); function _export(target, all) { for(var name in all)Object.defineProperty(target, name, { enumerable: true, get: all[name] }); } _export(exports, { sankeyLinkHorizontal: function() { return sankeyLinkHorizontal; }, sankeyLinkVertical: function() { return sankeyLinkVertical; } }); var _d3Shape = require("d3-shape"); var sankeyLinkHorizontal = function() { var lineGenerator = (0, _d3Shape.line)().curve(_d3Shape.curveMonotoneX); return function(link, contract) { var thickness = Math.max(1, link.thickness - contract * 2); var halfThickness = thickness / 2; var linkLength = link.target.x0 - link.source.x1; var padLength = linkLength * 0.12; var dots = [ [ link.source.x1, link.pos0 - halfThickness ], [ link.source.x1 + padLength, link.pos0 - halfThickness ], [ link.target.x0 - padLength, link.pos1 - halfThickness ], [ link.target.x0, link.pos1 - halfThickness ], [ link.target.x0, link.pos1 + halfThickness ], [ link.target.x0 - padLength, link.pos1 + halfThickness ], [ link.source.x1 + padLength, link.pos0 + halfThickness ], [ link.source.x1, link.pos0 + halfThickness ], [ link.source.x1, link.pos0 - halfThickness ] ]; return lineGenerator(dots) + "Z"; }; }; var sankeyLinkVertical = function() { var lineGenerator = (0, _d3Shape.line)().curve(_d3Shape.curveMonotoneY); return function(link, contract) { var thickness = Math.max(1, link.thickness - contract * 2); var halfThickness = thickness / 2; var linkLength = link.target.y0 - link.source.y1; var padLength = linkLength * 0.12; var dots = [ [ link.pos0 + halfThickness, link.source.y1 ], [ link.pos0 + halfThickness, link.source.y1 + padLength ], [ link.pos1 + halfThickness, link.target.y0 - padLength ], [ link.pos1 + halfThickness, link.target.y0 ], [ link.pos1 - halfThickness, link.target.y0 ], [ link.pos1 - halfThickness, link.target.y0 - padLength ], [ link.pos0 - halfThickness, link.source.y1 + padLength ], [ link.pos0 - halfThickness, link.source.y1 ], [ link.pos0 + halfThickness, link.source.y1 ] ]; return lineGenerator(dots) + "Z"; }; }; //# sourceMappingURL=links.js.map