MCPcopy Create free account
hub / github.com/idank/explainshell / relayout

Function relayout

explainshell/web/static/js/d3.v3.js:5047–5112  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

5045 d3.layout.chord = function() {
5046 var chord = {}, chords, groups, matrix, n, padding = 0, sortGroups, sortSubgroups, sortChords;
5047 function relayout() {
5048 var subgroups = {}, groupSums = [], groupIndex = d3.range(n), subgroupIndex = [], k, x, x0, i, j;
5049 chords = [];
5050 groups = [];
5051 k = 0, i = -1;
5052 while (++i < n) {
5053 x = 0, j = -1;
5054 while (++j < n) {
5055 x += matrix[i][j];
5056 }
5057 groupSums.push(x);
5058 subgroupIndex.push(d3.range(n));
5059 k += x;
5060 }
5061 if (sortGroups) {
5062 groupIndex.sort(function(a, b) {
5063 return sortGroups(groupSums[a], groupSums[b]);
5064 });
5065 }
5066 if (sortSubgroups) {
5067 subgroupIndex.forEach(function(d, i) {
5068 d.sort(function(a, b) {
5069 return sortSubgroups(matrix[i][a], matrix[i][b]);
5070 });
5071 });
5072 }
5073 k = (2 * π - padding * n) / k;
5074 x = 0, i = -1;
5075 while (++i < n) {
5076 x0 = x, j = -1;
5077 while (++j < n) {
5078 var di = groupIndex[i], dj = subgroupIndex[di][j], v = matrix[di][dj], a0 = x, a1 = x += v * k;
5079 subgroups[di + "-" + dj] = {
5080 index: di,
5081 subindex: dj,
5082 startAngle: a0,
5083 endAngle: a1,
5084 value: v
5085 };
5086 }
5087 groups[di] = {
5088 index: di,
5089 startAngle: x0,
5090 endAngle: x,
5091 value: (x - x0) / k
5092 };
5093 x += padding;
5094 }
5095 i = -1;
5096 while (++i < n) {
5097 j = i - 1;
5098 while (++j < n) {
5099 var source = subgroups[i + "-" + j], target = subgroups[j + "-" + i];
5100 if (source.value || target.value) {
5101 chords.push(source.value < target.value ? {
5102 source: target,
5103 target: source
5104 } : {

Callers 1

d3.v3.jsFile · 0.85

Calls 1

resortFunction · 0.85

Tested by

no test coverage detected