完成世界书、骰子、apiconfig页面处理
This commit is contained in:
8
frontend/node_modules/d3-hierarchy/src/accessors.js
generated
vendored
Normal file
8
frontend/node_modules/d3-hierarchy/src/accessors.js
generated
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
export function optional(f) {
|
||||
return f == null ? null : required(f);
|
||||
}
|
||||
|
||||
export function required(f) {
|
||||
if (typeof f !== "function") throw new Error;
|
||||
return f;
|
||||
}
|
||||
84
frontend/node_modules/d3-hierarchy/src/cluster.js
generated
vendored
Normal file
84
frontend/node_modules/d3-hierarchy/src/cluster.js
generated
vendored
Normal file
@@ -0,0 +1,84 @@
|
||||
function defaultSeparation(a, b) {
|
||||
return a.parent === b.parent ? 1 : 2;
|
||||
}
|
||||
|
||||
function meanX(children) {
|
||||
return children.reduce(meanXReduce, 0) / children.length;
|
||||
}
|
||||
|
||||
function meanXReduce(x, c) {
|
||||
return x + c.x;
|
||||
}
|
||||
|
||||
function maxY(children) {
|
||||
return 1 + children.reduce(maxYReduce, 0);
|
||||
}
|
||||
|
||||
function maxYReduce(y, c) {
|
||||
return Math.max(y, c.y);
|
||||
}
|
||||
|
||||
function leafLeft(node) {
|
||||
var children;
|
||||
while (children = node.children) node = children[0];
|
||||
return node;
|
||||
}
|
||||
|
||||
function leafRight(node) {
|
||||
var children;
|
||||
while (children = node.children) node = children[children.length - 1];
|
||||
return node;
|
||||
}
|
||||
|
||||
export default function() {
|
||||
var separation = defaultSeparation,
|
||||
dx = 1,
|
||||
dy = 1,
|
||||
nodeSize = false;
|
||||
|
||||
function cluster(root) {
|
||||
var previousNode,
|
||||
x = 0;
|
||||
|
||||
// First walk, computing the initial x & y values.
|
||||
root.eachAfter(function(node) {
|
||||
var children = node.children;
|
||||
if (children) {
|
||||
node.x = meanX(children);
|
||||
node.y = maxY(children);
|
||||
} else {
|
||||
node.x = previousNode ? x += separation(node, previousNode) : 0;
|
||||
node.y = 0;
|
||||
previousNode = node;
|
||||
}
|
||||
});
|
||||
|
||||
var left = leafLeft(root),
|
||||
right = leafRight(root),
|
||||
x0 = left.x - separation(left, right) / 2,
|
||||
x1 = right.x + separation(right, left) / 2;
|
||||
|
||||
// Second walk, normalizing x & y to the desired size.
|
||||
return root.eachAfter(nodeSize ? function(node) {
|
||||
node.x = (node.x - root.x) * dx;
|
||||
node.y = (root.y - node.y) * dy;
|
||||
} : function(node) {
|
||||
node.x = (node.x - x0) / (x1 - x0) * dx;
|
||||
node.y = (1 - (root.y ? node.y / root.y : 1)) * dy;
|
||||
});
|
||||
}
|
||||
|
||||
cluster.separation = function(x) {
|
||||
return arguments.length ? (separation = x, cluster) : separation;
|
||||
};
|
||||
|
||||
cluster.size = function(x) {
|
||||
return arguments.length ? (nodeSize = false, dx = +x[0], dy = +x[1], cluster) : (nodeSize ? null : [dx, dy]);
|
||||
};
|
||||
|
||||
cluster.nodeSize = function(x) {
|
||||
return arguments.length ? (nodeSize = true, dx = +x[0], dy = +x[1], cluster) : (nodeSize ? [dx, dy] : null);
|
||||
};
|
||||
|
||||
return cluster;
|
||||
}
|
||||
9
frontend/node_modules/d3-hierarchy/src/constant.js
generated
vendored
Normal file
9
frontend/node_modules/d3-hierarchy/src/constant.js
generated
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
export function constantZero() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
export default function(x) {
|
||||
return function() {
|
||||
return x;
|
||||
};
|
||||
}
|
||||
3
frontend/node_modules/d3-hierarchy/src/hierarchy/descendants.js
generated
vendored
Normal file
3
frontend/node_modules/d3-hierarchy/src/hierarchy/descendants.js
generated
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
export default function() {
|
||||
return Array.from(this);
|
||||
}
|
||||
91
frontend/node_modules/d3-hierarchy/src/hierarchy/index.js
generated
vendored
Normal file
91
frontend/node_modules/d3-hierarchy/src/hierarchy/index.js
generated
vendored
Normal file
@@ -0,0 +1,91 @@
|
||||
import node_count from "./count.js";
|
||||
import node_each from "./each.js";
|
||||
import node_eachBefore from "./eachBefore.js";
|
||||
import node_eachAfter from "./eachAfter.js";
|
||||
import node_find from "./find.js";
|
||||
import node_sum from "./sum.js";
|
||||
import node_sort from "./sort.js";
|
||||
import node_path from "./path.js";
|
||||
import node_ancestors from "./ancestors.js";
|
||||
import node_descendants from "./descendants.js";
|
||||
import node_leaves from "./leaves.js";
|
||||
import node_links from "./links.js";
|
||||
import node_iterator from "./iterator.js";
|
||||
|
||||
export default function hierarchy(data, children) {
|
||||
if (data instanceof Map) {
|
||||
data = [undefined, data];
|
||||
if (children === undefined) children = mapChildren;
|
||||
} else if (children === undefined) {
|
||||
children = objectChildren;
|
||||
}
|
||||
|
||||
var root = new Node(data),
|
||||
node,
|
||||
nodes = [root],
|
||||
child,
|
||||
childs,
|
||||
i,
|
||||
n;
|
||||
|
||||
while (node = nodes.pop()) {
|
||||
if ((childs = children(node.data)) && (n = (childs = Array.from(childs)).length)) {
|
||||
node.children = childs;
|
||||
for (i = n - 1; i >= 0; --i) {
|
||||
nodes.push(child = childs[i] = new Node(childs[i]));
|
||||
child.parent = node;
|
||||
child.depth = node.depth + 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return root.eachBefore(computeHeight);
|
||||
}
|
||||
|
||||
function node_copy() {
|
||||
return hierarchy(this).eachBefore(copyData);
|
||||
}
|
||||
|
||||
function objectChildren(d) {
|
||||
return d.children;
|
||||
}
|
||||
|
||||
function mapChildren(d) {
|
||||
return Array.isArray(d) ? d[1] : null;
|
||||
}
|
||||
|
||||
function copyData(node) {
|
||||
if (node.data.value !== undefined) node.value = node.data.value;
|
||||
node.data = node.data.data;
|
||||
}
|
||||
|
||||
export function computeHeight(node) {
|
||||
var height = 0;
|
||||
do node.height = height;
|
||||
while ((node = node.parent) && (node.height < ++height));
|
||||
}
|
||||
|
||||
export function Node(data) {
|
||||
this.data = data;
|
||||
this.depth =
|
||||
this.height = 0;
|
||||
this.parent = null;
|
||||
}
|
||||
|
||||
Node.prototype = hierarchy.prototype = {
|
||||
constructor: Node,
|
||||
count: node_count,
|
||||
each: node_each,
|
||||
eachAfter: node_eachAfter,
|
||||
eachBefore: node_eachBefore,
|
||||
find: node_find,
|
||||
sum: node_sum,
|
||||
sort: node_sort,
|
||||
path: node_path,
|
||||
ancestors: node_ancestors,
|
||||
descendants: node_descendants,
|
||||
leaves: node_leaves,
|
||||
links: node_links,
|
||||
copy: node_copy,
|
||||
[Symbol.iterator]: node_iterator
|
||||
};
|
||||
9
frontend/node_modules/d3-hierarchy/src/hierarchy/leaves.js
generated
vendored
Normal file
9
frontend/node_modules/d3-hierarchy/src/hierarchy/leaves.js
generated
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
export default function() {
|
||||
var leaves = [];
|
||||
this.eachBefore(function(node) {
|
||||
if (!node.children) {
|
||||
leaves.push(node);
|
||||
}
|
||||
});
|
||||
return leaves;
|
||||
}
|
||||
30
frontend/node_modules/d3-hierarchy/src/hierarchy/path.js
generated
vendored
Normal file
30
frontend/node_modules/d3-hierarchy/src/hierarchy/path.js
generated
vendored
Normal file
@@ -0,0 +1,30 @@
|
||||
export default function(end) {
|
||||
var start = this,
|
||||
ancestor = leastCommonAncestor(start, end),
|
||||
nodes = [start];
|
||||
while (start !== ancestor) {
|
||||
start = start.parent;
|
||||
nodes.push(start);
|
||||
}
|
||||
var k = nodes.length;
|
||||
while (end !== ancestor) {
|
||||
nodes.splice(k, 0, end);
|
||||
end = end.parent;
|
||||
}
|
||||
return nodes;
|
||||
}
|
||||
|
||||
function leastCommonAncestor(a, b) {
|
||||
if (a === b) return a;
|
||||
var aNodes = a.ancestors(),
|
||||
bNodes = b.ancestors(),
|
||||
c = null;
|
||||
a = aNodes.pop();
|
||||
b = bNodes.pop();
|
||||
while (a === b) {
|
||||
c = a;
|
||||
a = aNodes.pop();
|
||||
b = bNodes.pop();
|
||||
}
|
||||
return c;
|
||||
}
|
||||
123
frontend/node_modules/d3-hierarchy/src/pack/enclose.js
generated
vendored
Normal file
123
frontend/node_modules/d3-hierarchy/src/pack/enclose.js
generated
vendored
Normal file
@@ -0,0 +1,123 @@
|
||||
import {shuffle} from "../array.js";
|
||||
import lcg from "../lcg.js";
|
||||
|
||||
export default function(circles) {
|
||||
return packEncloseRandom(circles, lcg());
|
||||
}
|
||||
|
||||
export function packEncloseRandom(circles, random) {
|
||||
var i = 0, n = (circles = shuffle(Array.from(circles), random)).length, B = [], p, e;
|
||||
|
||||
while (i < n) {
|
||||
p = circles[i];
|
||||
if (e && enclosesWeak(e, p)) ++i;
|
||||
else e = encloseBasis(B = extendBasis(B, p)), i = 0;
|
||||
}
|
||||
|
||||
return e;
|
||||
}
|
||||
|
||||
function extendBasis(B, p) {
|
||||
var i, j;
|
||||
|
||||
if (enclosesWeakAll(p, B)) return [p];
|
||||
|
||||
// If we get here then B must have at least one element.
|
||||
for (i = 0; i < B.length; ++i) {
|
||||
if (enclosesNot(p, B[i])
|
||||
&& enclosesWeakAll(encloseBasis2(B[i], p), B)) {
|
||||
return [B[i], p];
|
||||
}
|
||||
}
|
||||
|
||||
// If we get here then B must have at least two elements.
|
||||
for (i = 0; i < B.length - 1; ++i) {
|
||||
for (j = i + 1; j < B.length; ++j) {
|
||||
if (enclosesNot(encloseBasis2(B[i], B[j]), p)
|
||||
&& enclosesNot(encloseBasis2(B[i], p), B[j])
|
||||
&& enclosesNot(encloseBasis2(B[j], p), B[i])
|
||||
&& enclosesWeakAll(encloseBasis3(B[i], B[j], p), B)) {
|
||||
return [B[i], B[j], p];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// If we get here then something is very wrong.
|
||||
throw new Error;
|
||||
}
|
||||
|
||||
function enclosesNot(a, b) {
|
||||
var dr = a.r - b.r, dx = b.x - a.x, dy = b.y - a.y;
|
||||
return dr < 0 || dr * dr < dx * dx + dy * dy;
|
||||
}
|
||||
|
||||
function enclosesWeak(a, b) {
|
||||
var dr = a.r - b.r + Math.max(a.r, b.r, 1) * 1e-9, dx = b.x - a.x, dy = b.y - a.y;
|
||||
return dr > 0 && dr * dr > dx * dx + dy * dy;
|
||||
}
|
||||
|
||||
function enclosesWeakAll(a, B) {
|
||||
for (var i = 0; i < B.length; ++i) {
|
||||
if (!enclosesWeak(a, B[i])) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
function encloseBasis(B) {
|
||||
switch (B.length) {
|
||||
case 1: return encloseBasis1(B[0]);
|
||||
case 2: return encloseBasis2(B[0], B[1]);
|
||||
case 3: return encloseBasis3(B[0], B[1], B[2]);
|
||||
}
|
||||
}
|
||||
|
||||
function encloseBasis1(a) {
|
||||
return {
|
||||
x: a.x,
|
||||
y: a.y,
|
||||
r: a.r
|
||||
};
|
||||
}
|
||||
|
||||
function encloseBasis2(a, b) {
|
||||
var x1 = a.x, y1 = a.y, r1 = a.r,
|
||||
x2 = b.x, y2 = b.y, r2 = b.r,
|
||||
x21 = x2 - x1, y21 = y2 - y1, r21 = r2 - r1,
|
||||
l = Math.sqrt(x21 * x21 + y21 * y21);
|
||||
return {
|
||||
x: (x1 + x2 + x21 / l * r21) / 2,
|
||||
y: (y1 + y2 + y21 / l * r21) / 2,
|
||||
r: (l + r1 + r2) / 2
|
||||
};
|
||||
}
|
||||
|
||||
function encloseBasis3(a, b, c) {
|
||||
var x1 = a.x, y1 = a.y, r1 = a.r,
|
||||
x2 = b.x, y2 = b.y, r2 = b.r,
|
||||
x3 = c.x, y3 = c.y, r3 = c.r,
|
||||
a2 = x1 - x2,
|
||||
a3 = x1 - x3,
|
||||
b2 = y1 - y2,
|
||||
b3 = y1 - y3,
|
||||
c2 = r2 - r1,
|
||||
c3 = r3 - r1,
|
||||
d1 = x1 * x1 + y1 * y1 - r1 * r1,
|
||||
d2 = d1 - x2 * x2 - y2 * y2 + r2 * r2,
|
||||
d3 = d1 - x3 * x3 - y3 * y3 + r3 * r3,
|
||||
ab = a3 * b2 - a2 * b3,
|
||||
xa = (b2 * d3 - b3 * d2) / (ab * 2) - x1,
|
||||
xb = (b3 * c2 - b2 * c3) / ab,
|
||||
ya = (a3 * d2 - a2 * d3) / (ab * 2) - y1,
|
||||
yb = (a2 * c3 - a3 * c2) / ab,
|
||||
A = xb * xb + yb * yb - 1,
|
||||
B = 2 * (r1 + xa * xb + ya * yb),
|
||||
C = xa * xa + ya * ya - r1 * r1,
|
||||
r = -(Math.abs(A) > 1e-6 ? (B + Math.sqrt(B * B - 4 * A * C)) / (2 * A) : C / B);
|
||||
return {
|
||||
x: x1 + xa + xb * r,
|
||||
y: y1 + ya + yb * r,
|
||||
r: r
|
||||
};
|
||||
}
|
||||
94
frontend/node_modules/d3-hierarchy/src/treemap/index.js
generated
vendored
Normal file
94
frontend/node_modules/d3-hierarchy/src/treemap/index.js
generated
vendored
Normal file
@@ -0,0 +1,94 @@
|
||||
import roundNode from "./round.js";
|
||||
import squarify from "./squarify.js";
|
||||
import {required} from "../accessors.js";
|
||||
import constant, {constantZero} from "../constant.js";
|
||||
|
||||
export default function() {
|
||||
var tile = squarify,
|
||||
round = false,
|
||||
dx = 1,
|
||||
dy = 1,
|
||||
paddingStack = [0],
|
||||
paddingInner = constantZero,
|
||||
paddingTop = constantZero,
|
||||
paddingRight = constantZero,
|
||||
paddingBottom = constantZero,
|
||||
paddingLeft = constantZero;
|
||||
|
||||
function treemap(root) {
|
||||
root.x0 =
|
||||
root.y0 = 0;
|
||||
root.x1 = dx;
|
||||
root.y1 = dy;
|
||||
root.eachBefore(positionNode);
|
||||
paddingStack = [0];
|
||||
if (round) root.eachBefore(roundNode);
|
||||
return root;
|
||||
}
|
||||
|
||||
function positionNode(node) {
|
||||
var p = paddingStack[node.depth],
|
||||
x0 = node.x0 + p,
|
||||
y0 = node.y0 + p,
|
||||
x1 = node.x1 - p,
|
||||
y1 = node.y1 - p;
|
||||
if (x1 < x0) x0 = x1 = (x0 + x1) / 2;
|
||||
if (y1 < y0) y0 = y1 = (y0 + y1) / 2;
|
||||
node.x0 = x0;
|
||||
node.y0 = y0;
|
||||
node.x1 = x1;
|
||||
node.y1 = y1;
|
||||
if (node.children) {
|
||||
p = paddingStack[node.depth + 1] = paddingInner(node) / 2;
|
||||
x0 += paddingLeft(node) - p;
|
||||
y0 += paddingTop(node) - p;
|
||||
x1 -= paddingRight(node) - p;
|
||||
y1 -= paddingBottom(node) - p;
|
||||
if (x1 < x0) x0 = x1 = (x0 + x1) / 2;
|
||||
if (y1 < y0) y0 = y1 = (y0 + y1) / 2;
|
||||
tile(node, x0, y0, x1, y1);
|
||||
}
|
||||
}
|
||||
|
||||
treemap.round = function(x) {
|
||||
return arguments.length ? (round = !!x, treemap) : round;
|
||||
};
|
||||
|
||||
treemap.size = function(x) {
|
||||
return arguments.length ? (dx = +x[0], dy = +x[1], treemap) : [dx, dy];
|
||||
};
|
||||
|
||||
treemap.tile = function(x) {
|
||||
return arguments.length ? (tile = required(x), treemap) : tile;
|
||||
};
|
||||
|
||||
treemap.padding = function(x) {
|
||||
return arguments.length ? treemap.paddingInner(x).paddingOuter(x) : treemap.paddingInner();
|
||||
};
|
||||
|
||||
treemap.paddingInner = function(x) {
|
||||
return arguments.length ? (paddingInner = typeof x === "function" ? x : constant(+x), treemap) : paddingInner;
|
||||
};
|
||||
|
||||
treemap.paddingOuter = function(x) {
|
||||
return arguments.length ? treemap.paddingTop(x).paddingRight(x).paddingBottom(x).paddingLeft(x) : treemap.paddingTop();
|
||||
};
|
||||
|
||||
treemap.paddingTop = function(x) {
|
||||
return arguments.length ? (paddingTop = typeof x === "function" ? x : constant(+x), treemap) : paddingTop;
|
||||
};
|
||||
|
||||
treemap.paddingRight = function(x) {
|
||||
return arguments.length ? (paddingRight = typeof x === "function" ? x : constant(+x), treemap) : paddingRight;
|
||||
};
|
||||
|
||||
treemap.paddingBottom = function(x) {
|
||||
return arguments.length ? (paddingBottom = typeof x === "function" ? x : constant(+x), treemap) : paddingBottom;
|
||||
};
|
||||
|
||||
treemap.paddingLeft = function(x) {
|
||||
return arguments.length ? (paddingLeft = typeof x === "function" ? x : constant(+x), treemap) : paddingLeft;
|
||||
};
|
||||
|
||||
return treemap;
|
||||
}
|
||||
6
frontend/node_modules/d3-hierarchy/src/treemap/sliceDice.js
generated
vendored
Normal file
6
frontend/node_modules/d3-hierarchy/src/treemap/sliceDice.js
generated
vendored
Normal file
@@ -0,0 +1,6 @@
|
||||
import dice from "./dice.js";
|
||||
import slice from "./slice.js";
|
||||
|
||||
export default function(parent, x0, y0, x1, y1) {
|
||||
(parent.depth & 1 ? slice : dice)(parent, x0, y0, x1, y1);
|
||||
}
|
||||
66
frontend/node_modules/d3-hierarchy/src/treemap/squarify.js
generated
vendored
Normal file
66
frontend/node_modules/d3-hierarchy/src/treemap/squarify.js
generated
vendored
Normal file
@@ -0,0 +1,66 @@
|
||||
import treemapDice from "./dice.js";
|
||||
import treemapSlice from "./slice.js";
|
||||
|
||||
export var phi = (1 + Math.sqrt(5)) / 2;
|
||||
|
||||
export function squarifyRatio(ratio, parent, x0, y0, x1, y1) {
|
||||
var rows = [],
|
||||
nodes = parent.children,
|
||||
row,
|
||||
nodeValue,
|
||||
i0 = 0,
|
||||
i1 = 0,
|
||||
n = nodes.length,
|
||||
dx, dy,
|
||||
value = parent.value,
|
||||
sumValue,
|
||||
minValue,
|
||||
maxValue,
|
||||
newRatio,
|
||||
minRatio,
|
||||
alpha,
|
||||
beta;
|
||||
|
||||
while (i0 < n) {
|
||||
dx = x1 - x0, dy = y1 - y0;
|
||||
|
||||
// Find the next non-empty node.
|
||||
do sumValue = nodes[i1++].value; while (!sumValue && i1 < n);
|
||||
minValue = maxValue = sumValue;
|
||||
alpha = Math.max(dy / dx, dx / dy) / (value * ratio);
|
||||
beta = sumValue * sumValue * alpha;
|
||||
minRatio = Math.max(maxValue / beta, beta / minValue);
|
||||
|
||||
// Keep adding nodes while the aspect ratio maintains or improves.
|
||||
for (; i1 < n; ++i1) {
|
||||
sumValue += nodeValue = nodes[i1].value;
|
||||
if (nodeValue < minValue) minValue = nodeValue;
|
||||
if (nodeValue > maxValue) maxValue = nodeValue;
|
||||
beta = sumValue * sumValue * alpha;
|
||||
newRatio = Math.max(maxValue / beta, beta / minValue);
|
||||
if (newRatio > minRatio) { sumValue -= nodeValue; break; }
|
||||
minRatio = newRatio;
|
||||
}
|
||||
|
||||
// Position and record the row orientation.
|
||||
rows.push(row = {value: sumValue, dice: dx < dy, children: nodes.slice(i0, i1)});
|
||||
if (row.dice) treemapDice(row, x0, y0, x1, value ? y0 += dy * sumValue / value : y1);
|
||||
else treemapSlice(row, x0, y0, value ? x0 += dx * sumValue / value : x1, y1);
|
||||
value -= sumValue, i0 = i1;
|
||||
}
|
||||
|
||||
return rows;
|
||||
}
|
||||
|
||||
export default (function custom(ratio) {
|
||||
|
||||
function squarify(parent, x0, y0, x1, y1) {
|
||||
squarifyRatio(ratio, parent, x0, y0, x1, y1);
|
||||
}
|
||||
|
||||
squarify.ratio = function(x) {
|
||||
return custom((x = +x) > 1 ? x : 1);
|
||||
};
|
||||
|
||||
return squarify;
|
||||
})(phi);
|
||||
Reference in New Issue
Block a user