完成世界书、骰子、apiconfig页面处理
This commit is contained in:
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