@daoyi/nmtl-ui 2.0.1-beta.128 → 2.0.1-beta.129
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React__default, { useEffect } from 'react';
|
|
2
2
|
import { c as classNames } from './index-b76a85f4.js';
|
|
3
3
|
import PropTypes from 'prop-types';
|
|
4
|
-
import { g as constant$1, h as interpolateNumber, j as color, k as interpolateRgb, l as interpolateString, n as exponent, o as ordinal, p as initRange, r as map,
|
|
4
|
+
import { g as constant$1, h as interpolateNumber, j as color, k as interpolateRgb, l as interpolateString, n as exponent, o as ordinal, p as initRange, r as map, u as slice$1, v as bisectRight, w as formatSpecifier, x as formatPrefix, y as format, s as select } from './transform-849a452c.js';
|
|
5
5
|
import { s as styleInject } from './style-inject.es-1f59c1d0.js';
|
|
6
6
|
|
|
7
7
|
function sequence(start, stop, step) {
|
|
@@ -666,8 +666,8 @@ var BarChart = function BarChart(_ref) {
|
|
|
666
666
|
maxValue = parseInt(item.count, 10);
|
|
667
667
|
}
|
|
668
668
|
});
|
|
669
|
-
|
|
670
|
-
var svg =
|
|
669
|
+
select('div#barChart').html('');
|
|
670
|
+
var svg = select('#barChart').append('svg').attr('width', width + margin.left + margin.right).attr('height', height + margin.top + margin.bottom).append('g').attr('transform', "translate(".concat(margin.left, ",").concat(margin.top, ")"));
|
|
671
671
|
// X axis
|
|
672
672
|
var x = band().range([0, width]).domain(data.map(function (d) {
|
|
673
673
|
return d.year;
|
package/lib/components/SNA.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React__default, { useMemo, useEffect } from 'react';
|
|
2
2
|
import PropTypes from 'prop-types';
|
|
3
3
|
import { c as classNames } from './index-b76a85f4.js';
|
|
4
|
-
import {
|
|
4
|
+
import { s as select, c as creator, e as event, d as dispatch, a as customEvent, D as DragEvent, q as quadtree, m as map, t as timer, T as Transform, i as identity, b as interrupt, o as ordinal, f as category10 } from './transform-849a452c.js';
|
|
5
5
|
import { E as ExtraTools } from './ExtraTools-2691c13e.js';
|
|
6
6
|
import { getIntl } from './globalConfig';
|
|
7
7
|
import { s as styleInject } from './style-inject.es-1f59c1d0.js';
|
|
@@ -11,6 +11,10 @@ import '@material-ui/core';
|
|
|
11
11
|
import './Tooltip-6ebfa9c1.js';
|
|
12
12
|
import './dataExport-a9e3fae1.js';
|
|
13
13
|
|
|
14
|
+
function d3Create(name) {
|
|
15
|
+
return select(creator(name).call(document.documentElement));
|
|
16
|
+
}
|
|
17
|
+
|
|
14
18
|
function sourceEvent() {
|
|
15
19
|
var current = event, source;
|
|
16
20
|
while (source = current.sourceEvent) current = source;
|
|
@@ -60,7 +64,7 @@ function noevent$1() {
|
|
|
60
64
|
|
|
61
65
|
function dragDisable(view) {
|
|
62
66
|
var root = view.document.documentElement,
|
|
63
|
-
selection =
|
|
67
|
+
selection = select(view).on("dragstart.drag", noevent$1, true);
|
|
64
68
|
if ("onselectstart" in root) {
|
|
65
69
|
selection.on("selectstart.drag", noevent$1, true);
|
|
66
70
|
} else {
|
|
@@ -71,7 +75,7 @@ function dragDisable(view) {
|
|
|
71
75
|
|
|
72
76
|
function yesdrag(view, noclick) {
|
|
73
77
|
var root = view.document.documentElement,
|
|
74
|
-
selection =
|
|
78
|
+
selection = select(view).on("dragstart.drag", null);
|
|
75
79
|
if (noclick) {
|
|
76
80
|
selection.on("click.drag", noevent$1, true);
|
|
77
81
|
setTimeout(function() { selection.on("click.drag", null); }, 0);
|
|
@@ -136,7 +140,7 @@ function drag() {
|
|
|
136
140
|
if (touchending || !filter.apply(this, arguments)) return;
|
|
137
141
|
var gesture = beforestart("mouse", container.apply(this, arguments), mouse, this, arguments);
|
|
138
142
|
if (!gesture) return;
|
|
139
|
-
|
|
143
|
+
select(event.view).on("mousemove.drag", mousemoved, true).on("mouseup.drag", mouseupped, true);
|
|
140
144
|
dragDisable(event.view);
|
|
141
145
|
nopropagation$1();
|
|
142
146
|
mousemoving = false;
|
|
@@ -155,7 +159,7 @@ function drag() {
|
|
|
155
159
|
}
|
|
156
160
|
|
|
157
161
|
function mouseupped() {
|
|
158
|
-
|
|
162
|
+
select(event.view).on("mousemove.drag mouseup.drag", null);
|
|
159
163
|
yesdrag(event.view, mousemoving);
|
|
160
164
|
noevent$1();
|
|
161
165
|
gestures.mouse("end");
|
|
@@ -1228,7 +1232,7 @@ function zoom() {
|
|
|
1228
1232
|
function mousedowned() {
|
|
1229
1233
|
if (touchending || !filter.apply(this, arguments)) return;
|
|
1230
1234
|
var g = gesture(this, arguments, true),
|
|
1231
|
-
v =
|
|
1235
|
+
v = select(event.view).on("mousemove.zoom", mousemoved, true).on("mouseup.zoom", mouseupped, true),
|
|
1232
1236
|
p = mouse(this),
|
|
1233
1237
|
x0 = event.clientX,
|
|
1234
1238
|
y0 = event.clientY;
|
|
@@ -1265,8 +1269,8 @@ function zoom() {
|
|
|
1265
1269
|
t1 = constrain(translate(scale(t0, k1), p0, p1), extent.apply(this, arguments), translateExtent);
|
|
1266
1270
|
|
|
1267
1271
|
noevent();
|
|
1268
|
-
if (duration > 0)
|
|
1269
|
-
else
|
|
1272
|
+
if (duration > 0) select(this).transition().duration(duration).call(schedule, t1, p0);
|
|
1273
|
+
else select(this).call(zoom.transform, t1);
|
|
1270
1274
|
}
|
|
1271
1275
|
|
|
1272
1276
|
function touchstarted() {
|
|
@@ -1342,7 +1346,7 @@ function zoom() {
|
|
|
1342
1346
|
g.end();
|
|
1343
1347
|
// If this was a dbltap, reroute to the (optional) dblclick.zoom handler.
|
|
1344
1348
|
if (g.taps === 2) {
|
|
1345
|
-
var p =
|
|
1349
|
+
var p = select(this).on("dblclick.zoom");
|
|
1346
1350
|
if (p) p.apply(this, arguments);
|
|
1347
1351
|
}
|
|
1348
1352
|
}
|
|
@@ -1520,7 +1524,13 @@ var SNA = function SNA(props) {
|
|
|
1520
1524
|
}).distance(50)).force('charge', manyBody().strength(-200).distanceMax(1000)).force('center', center(contentWidth / 2, contentHeight / 2)).force('collide', collide().radius(function () {
|
|
1521
1525
|
return nodeRadius + 5;
|
|
1522
1526
|
}).strength(1).iterations(10)).force('x', x(contentWidth / 2)).force('y', y(contentHeight / 2)).force('radial', radial(100, contentWidth / 1.5, contentHeight / 1.5));
|
|
1523
|
-
|
|
1527
|
+
|
|
1528
|
+
/* 效能:SVG 先建在未掛上文件的節點,全部節點/標籤/連線建好後才一次掛進 #sna-graph(見 init 結尾)。
|
|
1529
|
+
Adobe Fonts 動態子集 kit(abo/ada/hr/ra 的 index.html 載入)在 body 掛 MutationObserver,
|
|
1530
|
+
每筆 mutation 都用 TreeWalker 重掃目標整棵子樹收集文字;d3 逐一 append 進 live DOM 時,
|
|
1531
|
+
每加一個節點就產生一筆以父層 <g> 為目標的紀錄 → O(n²),ra 1,428 個節點首次載入主執行緒凍結 39–73 秒。
|
|
1532
|
+
離線建好再掛上,kit 只收到一筆紀錄、只掃一次 */
|
|
1533
|
+
var svg = d3Create('svg').attr('viewBox', [0, 0, contentWidth, contentHeight]).style('background-color', backgroundColor);
|
|
1524
1534
|
svg.append('defs').append('marker').attr('id', 'arrowhead').attr('viewBox', arrowViewBox).attr('refX', nodeRadius * 2 + nodeRadius * arrowPercent).attr('refY', 0).attr('orient', 'auto').attr('markerWidth', nodeRadius * (1 + arrowPercent)).attr('markerHeight', nodeRadius * (1 + arrowPercent)).attr('xoverflow', 'visible').append('svg:path').attr('d', arrowPath).attr('fill', '#999').style('stroke', 'none');
|
|
1525
1535
|
// 增加一層g用來包住所有的物件,並對此g加入縮放功能
|
|
1526
1536
|
g = svg.append('g');
|
|
@@ -1624,6 +1634,10 @@ var SNA = function SNA(props) {
|
|
|
1624
1634
|
return getLineCurve(d.source, d.target, lineRaduis);
|
|
1625
1635
|
});
|
|
1626
1636
|
});
|
|
1637
|
+
|
|
1638
|
+
// 一次掛上(原因見上方建立 svg 處);simulation 的 tick 由 d3-timer 排在之後的 frame,掛上前不會跑
|
|
1639
|
+
var container = document.getElementById('sna-graph');
|
|
1640
|
+
if (container) container.appendChild(svg.node());
|
|
1627
1641
|
};
|
|
1628
1642
|
var renderSNA = function renderSNA() {
|
|
1629
1643
|
if (SNAData && SNAData.nodes && SNAData.nodes.length > 0) {
|
|
@@ -988,7 +988,7 @@ Selection$1.prototype = selection.prototype = {
|
|
|
988
988
|
dispatch: selection_dispatch
|
|
989
989
|
};
|
|
990
990
|
|
|
991
|
-
function
|
|
991
|
+
function select(selector) {
|
|
992
992
|
return typeof selector === "string"
|
|
993
993
|
? new Selection$1([[document.querySelector(selector)]], [document.documentElement])
|
|
994
994
|
: new Selection$1([[selector]], root);
|
|
@@ -5472,4 +5472,4 @@ Transform.prototype = {
|
|
|
5472
5472
|
|
|
5473
5473
|
var identity = new Transform(1, 0, 0);
|
|
5474
5474
|
|
|
5475
|
-
export { DragEvent as D, Transform as T,
|
|
5475
|
+
export { DragEvent as D, Transform as T, customEvent as a, interrupt as b, creator as c, dispatch as d, event as e, category10 as f, constant as g, interpolateNumber as h, identity as i, color as j, interpolateRgb as k, interpolateString as l, map$2 as m, exponent as n, ordinal as o, initRange as p, quadtree as q, map as r, select as s, timer as t, slice as u, bisectRight as v, formatSpecifier as w, formatPrefix as x, format as y };
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@daoyi/nmtl-ui",
|
|
3
3
|
"packageManager": "pnpm@10.34.5",
|
|
4
|
-
"version": "2.0.1-beta.
|
|
4
|
+
"version": "2.0.1-beta.129",
|
|
5
5
|
"description": "This project is to be used as a starter kit for building React component using Storybook and Rollup",
|
|
6
6
|
"author": "daoyi",
|
|
7
7
|
"main": "lib/index.js",
|