Debian Codegraph @

d3-sankey/test/sankey-test.js

raw
1 var tape = require("tape"),
2 d3 = require("../");
3
4 tape.skip("sankey(energy) returns the expected results", function(test) {
5 var sankey = d3.sankey().nodeWidth(15).nodePadding(10).extent([[1, 1], [959, 494]]),
6 energy = sankey(require("./energy"));
7 test.deepEqual(energy.nodes.map(nodePosition), require("./energy-nodes"));
8 test.deepEqual(energy.links.map(linkPosition), require("./energy-links"));
9 test.end();
10 });
11
12 function nodePosition(node) {
13 return {
14 x: round(node.x0),
15 dx: round(node.x1 - node.x0),
16 y: round(node.y0),
17 dy: round(node.y1 - node.y0)
18 };
19 }
20
21 function linkPosition(link) {
22 return {
23 source: nodePosition(link.source),
24 target: nodePosition(link.target),
25 dy: round(link.width),
26 sy: round(link.y0 - link.source.y0 - link.width / 2),
27 ty: round(link.y1 - link.target.y0 - link.width / 2)
28 };
29 }
30
31 function round(x) {
32 return Math.round(x * 10) / 10;
33 }