@daoyi/nmtl-ui 2.0.1-beta.44 → 2.0.1-beta.46
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.
- package/lib/components/Autocomplete-aa4a8d6c.js +335 -0
- package/lib/components/Autocomplete.js +13 -1
- package/lib/components/Avatar.js +49 -1
- package/lib/components/BackTop.js +109 -1
- package/lib/components/BarChart.js +762 -1
- package/lib/components/Breadcrumbs.js +122 -1
- package/lib/components/Button-2f8f0493.js +92 -0
- package/lib/components/Button.js +6 -1
- package/lib/components/Carousel.js +4713 -1
- package/lib/components/Checkbox.js +37 -1
- package/lib/components/CollapseContent.js +179 -1
- package/lib/components/ContactModal-c8240b19.js +10759 -0
- package/lib/components/ContactModal.js +22 -1
- package/lib/components/Drawer-dd8942f1.js +157 -0
- package/lib/components/Drawer.js +11 -1
- package/lib/components/Dropdown.js +134 -1
- package/lib/components/Empty-3637b766.js +45 -0
- package/lib/components/Empty.js +5 -1
- package/lib/components/ExportButton.js +112 -1
- package/lib/components/ExtraTools-55dad795.js +3479 -0
- package/lib/components/ExtraTools.js +10 -1
- package/lib/components/Filter.js +776 -1
- package/lib/components/Footer.js +271 -1
- package/lib/components/ForwardLink.js +105 -1
- package/lib/components/Header.js +187 -1
- package/lib/components/Image.js +61 -1
- package/lib/components/Input.js +77 -1
- package/lib/components/InputMethod.js +33963 -1
- package/lib/components/KeywordSearch-2d01266e.js +139 -0
- package/lib/components/KeywordSearch.js +15 -1
- package/lib/components/KeywordTicker.js +180 -1
- package/lib/components/Keywords.js +317 -1
- package/lib/components/Loading.js +28 -1
- package/lib/components/MUITheme.js +2627 -1
- package/lib/components/Modal-572e17ea.js +108 -0
- package/lib/components/Modal.js +9 -1
- package/lib/components/MoreButton-80996b5f.js +110 -0
- package/lib/components/MoreButton.js +6 -1
- package/lib/components/Radio.js +78 -1
- package/lib/components/SNA.js +1735 -1
- package/lib/components/Select-5533b506.js +115 -0
- package/lib/components/Select.js +8 -1
- package/lib/components/Spin-ebf79c17.js +75 -0
- package/lib/components/Spin.js +6 -1
- package/lib/components/Table.js +51 -1
- package/lib/components/Tooltip-907eaa2e.js +70 -0
- package/lib/components/Tooltip.js +7 -1
- package/lib/components/_commonjsHelpers-70de2c37.js +28 -0
- package/lib/components/_rollupPluginBabelHelpers-fde6d1c6.js +491 -1
- package/lib/components/createSvgIcon-48da8b6e.js +576 -0
- package/lib/components/dataExport-d55d6fa3.js +92 -0
- package/lib/components/debounce-127da66c.js +355 -0
- package/lib/components/defaultTheme-19a14721.js +1485 -0
- package/lib/components/globalConfig-40069b54.js +158 -0
- package/lib/components/hoist-non-react-statics.cjs-3f408ad2.js +105 -0
- package/lib/components/index-7b60a97d.js +481 -0
- package/lib/components/index-f491ebce.js +61 -0
- package/lib/components/isObjectLike-e111475d.js +190 -0
- package/lib/components/style-inject.es-1f59c1d0.js +28 -0
- package/lib/components/transform-3a04288b.js +5475 -0
- package/lib/globalConfig.js +186 -1
- package/lib/utils/_rollupPluginBabelHelpers-a6e0e6e3.js +139 -1
- package/lib/utils/arrayMerge.js +100 -1
- package/lib/utils/chunkArray.js +15 -1
- package/lib/utils/convert2HtmlEntities.js +42 -1
- package/lib/utils/domToImage.js +802 -1
- package/lib/utils/downloadGephi.js +106 -1
- package/lib/utils/exportXlsx.js +219 -1
- package/lib/utils/historyAppendSearch.js +502 -1
- package/lib/utils/isDevelopMode.js +5 -1
- package/lib/utils/parseYMD.js +36 -1
- package/lib/utils/removeDuplicateItem.js +11 -1
- package/lib/utils/sendEmail.js +39 -1
- package/lib/utils/snaDefine-6a2bcd94.js +5 -1
- package/lib/utils/snaDefine.js +1 -1
- package/lib/utils/snaPreProcess.js +84 -1
- package/package.json +1 -1
- package/lib/components/Autocomplete-5439ff22.js +0 -1
- package/lib/components/Button-63c7e9f3.js +0 -1
- package/lib/components/ContactModal-d852ae32.js +0 -1
- package/lib/components/Drawer-af3ed21a.js +0 -1
- package/lib/components/Empty-70f040a9.js +0 -1
- package/lib/components/ExtraTools-f10a66a8.js +0 -1
- package/lib/components/KeywordSearch-224f84c1.js +0 -1
- package/lib/components/Modal-a7591b98.js +0 -1
- package/lib/components/MoreButton-f15ca38e.js +0 -1
- package/lib/components/Select-98a8e973.js +0 -1
- package/lib/components/Spin-690a3597.js +0 -1
- package/lib/components/Tooltip-b7eb966d.js +0 -1
- package/lib/components/dataExport-f418e6fe.js +0 -1
- package/lib/components/globalConfig-63dfbe94.js +0 -1
- package/lib/components/vendor-851c6356.js +0 -63
- package/lib/utils/vendor-3ec75cc9.js +0 -1
|
@@ -1 +1,762 @@
|
|
|
1
|
-
import
|
|
1
|
+
import React__default, { useEffect } from 'react';
|
|
2
|
+
import { c as classNames } from './index-f491ebce.js';
|
|
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, s as slice$1, u as bisectRight, v as formatSpecifier, w as formatPrefix, x as format, d as d3Select } from './transform-3a04288b.js';
|
|
5
|
+
import { s as styleInject } from './style-inject.es-1f59c1d0.js';
|
|
6
|
+
|
|
7
|
+
function sequence(start, stop, step) {
|
|
8
|
+
start = +start, stop = +stop, step = (n = arguments.length) < 2 ? (stop = start, start = 0, 1) : n < 3 ? 1 : +step;
|
|
9
|
+
|
|
10
|
+
var i = -1,
|
|
11
|
+
n = Math.max(0, Math.ceil((stop - start) / step)) | 0,
|
|
12
|
+
range = new Array(n);
|
|
13
|
+
|
|
14
|
+
while (++i < n) {
|
|
15
|
+
range[i] = start + i * step;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
return range;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
var e10 = Math.sqrt(50),
|
|
22
|
+
e5 = Math.sqrt(10),
|
|
23
|
+
e2 = Math.sqrt(2);
|
|
24
|
+
|
|
25
|
+
function ticks(start, stop, count) {
|
|
26
|
+
var reverse,
|
|
27
|
+
i = -1,
|
|
28
|
+
n,
|
|
29
|
+
ticks,
|
|
30
|
+
step;
|
|
31
|
+
|
|
32
|
+
stop = +stop, start = +start, count = +count;
|
|
33
|
+
if (start === stop && count > 0) return [start];
|
|
34
|
+
if (reverse = stop < start) n = start, start = stop, stop = n;
|
|
35
|
+
if ((step = tickIncrement(start, stop, count)) === 0 || !isFinite(step)) return [];
|
|
36
|
+
|
|
37
|
+
if (step > 0) {
|
|
38
|
+
start = Math.ceil(start / step);
|
|
39
|
+
stop = Math.floor(stop / step);
|
|
40
|
+
ticks = new Array(n = Math.ceil(stop - start + 1));
|
|
41
|
+
while (++i < n) ticks[i] = (start + i) * step;
|
|
42
|
+
} else {
|
|
43
|
+
start = Math.floor(start * step);
|
|
44
|
+
stop = Math.ceil(stop * step);
|
|
45
|
+
ticks = new Array(n = Math.ceil(start - stop + 1));
|
|
46
|
+
while (++i < n) ticks[i] = (start - i) / step;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
if (reverse) ticks.reverse();
|
|
50
|
+
|
|
51
|
+
return ticks;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
function tickIncrement(start, stop, count) {
|
|
55
|
+
var step = (stop - start) / Math.max(0, count),
|
|
56
|
+
power = Math.floor(Math.log(step) / Math.LN10),
|
|
57
|
+
error = step / Math.pow(10, power);
|
|
58
|
+
return power >= 0
|
|
59
|
+
? (error >= e10 ? 10 : error >= e5 ? 5 : error >= e2 ? 2 : 1) * Math.pow(10, power)
|
|
60
|
+
: -Math.pow(10, -power) / (error >= e10 ? 10 : error >= e5 ? 5 : error >= e2 ? 2 : 1);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
function tickStep(start, stop, count) {
|
|
64
|
+
var step0 = Math.abs(stop - start) / Math.max(0, count),
|
|
65
|
+
step1 = Math.pow(10, Math.floor(Math.log(step0) / Math.LN10)),
|
|
66
|
+
error = step0 / step1;
|
|
67
|
+
if (error >= e10) step1 *= 10;
|
|
68
|
+
else if (error >= e5) step1 *= 5;
|
|
69
|
+
else if (error >= e2) step1 *= 2;
|
|
70
|
+
return stop < start ? -step1 : step1;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
var slice = Array.prototype.slice;
|
|
74
|
+
|
|
75
|
+
function identity$1(x) {
|
|
76
|
+
return x;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
var top = 1,
|
|
80
|
+
right = 2,
|
|
81
|
+
bottom = 3,
|
|
82
|
+
left = 4,
|
|
83
|
+
epsilon = 1e-6;
|
|
84
|
+
|
|
85
|
+
function translateX(x) {
|
|
86
|
+
return "translate(" + (x + 0.5) + ",0)";
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
function translateY(y) {
|
|
90
|
+
return "translate(0," + (y + 0.5) + ")";
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
function number$1(scale) {
|
|
94
|
+
return function(d) {
|
|
95
|
+
return +scale(d);
|
|
96
|
+
};
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
function center(scale) {
|
|
100
|
+
var offset = Math.max(0, scale.bandwidth() - 1) / 2; // Adjust for 0.5px offset.
|
|
101
|
+
if (scale.round()) offset = Math.round(offset);
|
|
102
|
+
return function(d) {
|
|
103
|
+
return +scale(d) + offset;
|
|
104
|
+
};
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
function entering() {
|
|
108
|
+
return !this.__axis;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
function axis(orient, scale) {
|
|
112
|
+
var tickArguments = [],
|
|
113
|
+
tickValues = null,
|
|
114
|
+
tickFormat = null,
|
|
115
|
+
tickSizeInner = 6,
|
|
116
|
+
tickSizeOuter = 6,
|
|
117
|
+
tickPadding = 3,
|
|
118
|
+
k = orient === top || orient === left ? -1 : 1,
|
|
119
|
+
x = orient === left || orient === right ? "x" : "y",
|
|
120
|
+
transform = orient === top || orient === bottom ? translateX : translateY;
|
|
121
|
+
|
|
122
|
+
function axis(context) {
|
|
123
|
+
var values = tickValues == null ? (scale.ticks ? scale.ticks.apply(scale, tickArguments) : scale.domain()) : tickValues,
|
|
124
|
+
format = tickFormat == null ? (scale.tickFormat ? scale.tickFormat.apply(scale, tickArguments) : identity$1) : tickFormat,
|
|
125
|
+
spacing = Math.max(tickSizeInner, 0) + tickPadding,
|
|
126
|
+
range = scale.range(),
|
|
127
|
+
range0 = +range[0] + 0.5,
|
|
128
|
+
range1 = +range[range.length - 1] + 0.5,
|
|
129
|
+
position = (scale.bandwidth ? center : number$1)(scale.copy()),
|
|
130
|
+
selection = context.selection ? context.selection() : context,
|
|
131
|
+
path = selection.selectAll(".domain").data([null]),
|
|
132
|
+
tick = selection.selectAll(".tick").data(values, scale).order(),
|
|
133
|
+
tickExit = tick.exit(),
|
|
134
|
+
tickEnter = tick.enter().append("g").attr("class", "tick"),
|
|
135
|
+
line = tick.select("line"),
|
|
136
|
+
text = tick.select("text");
|
|
137
|
+
|
|
138
|
+
path = path.merge(path.enter().insert("path", ".tick")
|
|
139
|
+
.attr("class", "domain")
|
|
140
|
+
.attr("stroke", "currentColor"));
|
|
141
|
+
|
|
142
|
+
tick = tick.merge(tickEnter);
|
|
143
|
+
|
|
144
|
+
line = line.merge(tickEnter.append("line")
|
|
145
|
+
.attr("stroke", "currentColor")
|
|
146
|
+
.attr(x + "2", k * tickSizeInner));
|
|
147
|
+
|
|
148
|
+
text = text.merge(tickEnter.append("text")
|
|
149
|
+
.attr("fill", "currentColor")
|
|
150
|
+
.attr(x, k * spacing)
|
|
151
|
+
.attr("dy", orient === top ? "0em" : orient === bottom ? "0.71em" : "0.32em"));
|
|
152
|
+
|
|
153
|
+
if (context !== selection) {
|
|
154
|
+
path = path.transition(context);
|
|
155
|
+
tick = tick.transition(context);
|
|
156
|
+
line = line.transition(context);
|
|
157
|
+
text = text.transition(context);
|
|
158
|
+
|
|
159
|
+
tickExit = tickExit.transition(context)
|
|
160
|
+
.attr("opacity", epsilon)
|
|
161
|
+
.attr("transform", function(d) { return isFinite(d = position(d)) ? transform(d) : this.getAttribute("transform"); });
|
|
162
|
+
|
|
163
|
+
tickEnter
|
|
164
|
+
.attr("opacity", epsilon)
|
|
165
|
+
.attr("transform", function(d) { var p = this.parentNode.__axis; return transform(p && isFinite(p = p(d)) ? p : position(d)); });
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
tickExit.remove();
|
|
169
|
+
|
|
170
|
+
path
|
|
171
|
+
.attr("d", orient === left || orient == right
|
|
172
|
+
? (tickSizeOuter ? "M" + k * tickSizeOuter + "," + range0 + "H0.5V" + range1 + "H" + k * tickSizeOuter : "M0.5," + range0 + "V" + range1)
|
|
173
|
+
: (tickSizeOuter ? "M" + range0 + "," + k * tickSizeOuter + "V0.5H" + range1 + "V" + k * tickSizeOuter : "M" + range0 + ",0.5H" + range1));
|
|
174
|
+
|
|
175
|
+
tick
|
|
176
|
+
.attr("opacity", 1)
|
|
177
|
+
.attr("transform", function(d) { return transform(position(d)); });
|
|
178
|
+
|
|
179
|
+
line
|
|
180
|
+
.attr(x + "2", k * tickSizeInner);
|
|
181
|
+
|
|
182
|
+
text
|
|
183
|
+
.attr(x, k * spacing)
|
|
184
|
+
.text(format);
|
|
185
|
+
|
|
186
|
+
selection.filter(entering)
|
|
187
|
+
.attr("fill", "none")
|
|
188
|
+
.attr("font-size", 10)
|
|
189
|
+
.attr("font-family", "sans-serif")
|
|
190
|
+
.attr("text-anchor", orient === right ? "start" : orient === left ? "end" : "middle");
|
|
191
|
+
|
|
192
|
+
selection
|
|
193
|
+
.each(function() { this.__axis = position; });
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
axis.scale = function(_) {
|
|
197
|
+
return arguments.length ? (scale = _, axis) : scale;
|
|
198
|
+
};
|
|
199
|
+
|
|
200
|
+
axis.ticks = function() {
|
|
201
|
+
return tickArguments = slice.call(arguments), axis;
|
|
202
|
+
};
|
|
203
|
+
|
|
204
|
+
axis.tickArguments = function(_) {
|
|
205
|
+
return arguments.length ? (tickArguments = _ == null ? [] : slice.call(_), axis) : tickArguments.slice();
|
|
206
|
+
};
|
|
207
|
+
|
|
208
|
+
axis.tickValues = function(_) {
|
|
209
|
+
return arguments.length ? (tickValues = _ == null ? null : slice.call(_), axis) : tickValues && tickValues.slice();
|
|
210
|
+
};
|
|
211
|
+
|
|
212
|
+
axis.tickFormat = function(_) {
|
|
213
|
+
return arguments.length ? (tickFormat = _, axis) : tickFormat;
|
|
214
|
+
};
|
|
215
|
+
|
|
216
|
+
axis.tickSize = function(_) {
|
|
217
|
+
return arguments.length ? (tickSizeInner = tickSizeOuter = +_, axis) : tickSizeInner;
|
|
218
|
+
};
|
|
219
|
+
|
|
220
|
+
axis.tickSizeInner = function(_) {
|
|
221
|
+
return arguments.length ? (tickSizeInner = +_, axis) : tickSizeInner;
|
|
222
|
+
};
|
|
223
|
+
|
|
224
|
+
axis.tickSizeOuter = function(_) {
|
|
225
|
+
return arguments.length ? (tickSizeOuter = +_, axis) : tickSizeOuter;
|
|
226
|
+
};
|
|
227
|
+
|
|
228
|
+
axis.tickPadding = function(_) {
|
|
229
|
+
return arguments.length ? (tickPadding = +_, axis) : tickPadding;
|
|
230
|
+
};
|
|
231
|
+
|
|
232
|
+
return axis;
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
function axisBottom(scale) {
|
|
236
|
+
return axis(bottom, scale);
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
function axisLeft(scale) {
|
|
240
|
+
return axis(left, scale);
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
function numberArray(a, b) {
|
|
244
|
+
if (!b) b = [];
|
|
245
|
+
var n = a ? Math.min(b.length, a.length) : 0,
|
|
246
|
+
c = b.slice(),
|
|
247
|
+
i;
|
|
248
|
+
return function(t) {
|
|
249
|
+
for (i = 0; i < n; ++i) c[i] = a[i] * (1 - t) + b[i] * t;
|
|
250
|
+
return c;
|
|
251
|
+
};
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
function isNumberArray(x) {
|
|
255
|
+
return ArrayBuffer.isView(x) && !(x instanceof DataView);
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
function genericArray(a, b) {
|
|
259
|
+
var nb = b ? b.length : 0,
|
|
260
|
+
na = a ? Math.min(nb, a.length) : 0,
|
|
261
|
+
x = new Array(na),
|
|
262
|
+
c = new Array(nb),
|
|
263
|
+
i;
|
|
264
|
+
|
|
265
|
+
for (i = 0; i < na; ++i) x[i] = interpolateValue(a[i], b[i]);
|
|
266
|
+
for (; i < nb; ++i) c[i] = b[i];
|
|
267
|
+
|
|
268
|
+
return function(t) {
|
|
269
|
+
for (i = 0; i < na; ++i) c[i] = x[i](t);
|
|
270
|
+
return c;
|
|
271
|
+
};
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
function date(a, b) {
|
|
275
|
+
var d = new Date;
|
|
276
|
+
return a = +a, b = +b, function(t) {
|
|
277
|
+
return d.setTime(a * (1 - t) + b * t), d;
|
|
278
|
+
};
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
function object(a, b) {
|
|
282
|
+
var i = {},
|
|
283
|
+
c = {},
|
|
284
|
+
k;
|
|
285
|
+
|
|
286
|
+
if (a === null || typeof a !== "object") a = {};
|
|
287
|
+
if (b === null || typeof b !== "object") b = {};
|
|
288
|
+
|
|
289
|
+
for (k in b) {
|
|
290
|
+
if (k in a) {
|
|
291
|
+
i[k] = interpolateValue(a[k], b[k]);
|
|
292
|
+
} else {
|
|
293
|
+
c[k] = b[k];
|
|
294
|
+
}
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
return function(t) {
|
|
298
|
+
for (k in i) c[k] = i[k](t);
|
|
299
|
+
return c;
|
|
300
|
+
};
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
function interpolateValue(a, b) {
|
|
304
|
+
var t = typeof b, c;
|
|
305
|
+
return b == null || t === "boolean" ? constant$1(b)
|
|
306
|
+
: (t === "number" ? interpolateNumber
|
|
307
|
+
: t === "string" ? ((c = color(b)) ? (b = c, interpolateRgb) : interpolateString)
|
|
308
|
+
: b instanceof color ? interpolateRgb
|
|
309
|
+
: b instanceof Date ? date
|
|
310
|
+
: isNumberArray(b) ? numberArray
|
|
311
|
+
: Array.isArray(b) ? genericArray
|
|
312
|
+
: typeof b.valueOf !== "function" && typeof b.toString !== "function" || isNaN(b) ? object
|
|
313
|
+
: interpolateNumber)(a, b);
|
|
314
|
+
}
|
|
315
|
+
|
|
316
|
+
function interpolateRound(a, b) {
|
|
317
|
+
return a = +a, b = +b, function(t) {
|
|
318
|
+
return Math.round(a * (1 - t) + b * t);
|
|
319
|
+
};
|
|
320
|
+
}
|
|
321
|
+
|
|
322
|
+
function precisionFixed(step) {
|
|
323
|
+
return Math.max(0, -exponent(Math.abs(step)));
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
function precisionPrefix(step, value) {
|
|
327
|
+
return Math.max(0, Math.max(-8, Math.min(8, Math.floor(exponent(value) / 3))) * 3 - exponent(Math.abs(step)));
|
|
328
|
+
}
|
|
329
|
+
|
|
330
|
+
function precisionRound(step, max) {
|
|
331
|
+
step = Math.abs(step), max = Math.abs(max) - step;
|
|
332
|
+
return Math.max(0, exponent(max) - exponent(step)) + 1;
|
|
333
|
+
}
|
|
334
|
+
|
|
335
|
+
function band() {
|
|
336
|
+
var scale = ordinal().unknown(undefined),
|
|
337
|
+
domain = scale.domain,
|
|
338
|
+
ordinalRange = scale.range,
|
|
339
|
+
range = [0, 1],
|
|
340
|
+
step,
|
|
341
|
+
bandwidth,
|
|
342
|
+
round = false,
|
|
343
|
+
paddingInner = 0,
|
|
344
|
+
paddingOuter = 0,
|
|
345
|
+
align = 0.5;
|
|
346
|
+
|
|
347
|
+
delete scale.unknown;
|
|
348
|
+
|
|
349
|
+
function rescale() {
|
|
350
|
+
var n = domain().length,
|
|
351
|
+
reverse = range[1] < range[0],
|
|
352
|
+
start = range[reverse - 0],
|
|
353
|
+
stop = range[1 - reverse];
|
|
354
|
+
step = (stop - start) / Math.max(1, n - paddingInner + paddingOuter * 2);
|
|
355
|
+
if (round) step = Math.floor(step);
|
|
356
|
+
start += (stop - start - step * (n - paddingInner)) * align;
|
|
357
|
+
bandwidth = step * (1 - paddingInner);
|
|
358
|
+
if (round) start = Math.round(start), bandwidth = Math.round(bandwidth);
|
|
359
|
+
var values = sequence(n).map(function(i) { return start + step * i; });
|
|
360
|
+
return ordinalRange(reverse ? values.reverse() : values);
|
|
361
|
+
}
|
|
362
|
+
|
|
363
|
+
scale.domain = function(_) {
|
|
364
|
+
return arguments.length ? (domain(_), rescale()) : domain();
|
|
365
|
+
};
|
|
366
|
+
|
|
367
|
+
scale.range = function(_) {
|
|
368
|
+
return arguments.length ? (range = [+_[0], +_[1]], rescale()) : range.slice();
|
|
369
|
+
};
|
|
370
|
+
|
|
371
|
+
scale.rangeRound = function(_) {
|
|
372
|
+
return range = [+_[0], +_[1]], round = true, rescale();
|
|
373
|
+
};
|
|
374
|
+
|
|
375
|
+
scale.bandwidth = function() {
|
|
376
|
+
return bandwidth;
|
|
377
|
+
};
|
|
378
|
+
|
|
379
|
+
scale.step = function() {
|
|
380
|
+
return step;
|
|
381
|
+
};
|
|
382
|
+
|
|
383
|
+
scale.round = function(_) {
|
|
384
|
+
return arguments.length ? (round = !!_, rescale()) : round;
|
|
385
|
+
};
|
|
386
|
+
|
|
387
|
+
scale.padding = function(_) {
|
|
388
|
+
return arguments.length ? (paddingInner = Math.min(1, paddingOuter = +_), rescale()) : paddingInner;
|
|
389
|
+
};
|
|
390
|
+
|
|
391
|
+
scale.paddingInner = function(_) {
|
|
392
|
+
return arguments.length ? (paddingInner = Math.min(1, _), rescale()) : paddingInner;
|
|
393
|
+
};
|
|
394
|
+
|
|
395
|
+
scale.paddingOuter = function(_) {
|
|
396
|
+
return arguments.length ? (paddingOuter = +_, rescale()) : paddingOuter;
|
|
397
|
+
};
|
|
398
|
+
|
|
399
|
+
scale.align = function(_) {
|
|
400
|
+
return arguments.length ? (align = Math.max(0, Math.min(1, _)), rescale()) : align;
|
|
401
|
+
};
|
|
402
|
+
|
|
403
|
+
scale.copy = function() {
|
|
404
|
+
return band(domain(), range)
|
|
405
|
+
.round(round)
|
|
406
|
+
.paddingInner(paddingInner)
|
|
407
|
+
.paddingOuter(paddingOuter)
|
|
408
|
+
.align(align);
|
|
409
|
+
};
|
|
410
|
+
|
|
411
|
+
return initRange.apply(rescale(), arguments);
|
|
412
|
+
}
|
|
413
|
+
|
|
414
|
+
function constant(x) {
|
|
415
|
+
return function() {
|
|
416
|
+
return x;
|
|
417
|
+
};
|
|
418
|
+
}
|
|
419
|
+
|
|
420
|
+
function number(x) {
|
|
421
|
+
return +x;
|
|
422
|
+
}
|
|
423
|
+
|
|
424
|
+
var unit = [0, 1];
|
|
425
|
+
|
|
426
|
+
function identity(x) {
|
|
427
|
+
return x;
|
|
428
|
+
}
|
|
429
|
+
|
|
430
|
+
function normalize(a, b) {
|
|
431
|
+
return (b -= (a = +a))
|
|
432
|
+
? function(x) { return (x - a) / b; }
|
|
433
|
+
: constant(isNaN(b) ? NaN : 0.5);
|
|
434
|
+
}
|
|
435
|
+
|
|
436
|
+
function clamper(domain) {
|
|
437
|
+
var a = domain[0], b = domain[domain.length - 1], t;
|
|
438
|
+
if (a > b) t = a, a = b, b = t;
|
|
439
|
+
return function(x) { return Math.max(a, Math.min(b, x)); };
|
|
440
|
+
}
|
|
441
|
+
|
|
442
|
+
// normalize(a, b)(x) takes a domain value x in [a,b] and returns the corresponding parameter t in [0,1].
|
|
443
|
+
// interpolate(a, b)(t) takes a parameter t in [0,1] and returns the corresponding range value x in [a,b].
|
|
444
|
+
function bimap(domain, range, interpolate) {
|
|
445
|
+
var d0 = domain[0], d1 = domain[1], r0 = range[0], r1 = range[1];
|
|
446
|
+
if (d1 < d0) d0 = normalize(d1, d0), r0 = interpolate(r1, r0);
|
|
447
|
+
else d0 = normalize(d0, d1), r0 = interpolate(r0, r1);
|
|
448
|
+
return function(x) { return r0(d0(x)); };
|
|
449
|
+
}
|
|
450
|
+
|
|
451
|
+
function polymap(domain, range, interpolate) {
|
|
452
|
+
var j = Math.min(domain.length, range.length) - 1,
|
|
453
|
+
d = new Array(j),
|
|
454
|
+
r = new Array(j),
|
|
455
|
+
i = -1;
|
|
456
|
+
|
|
457
|
+
// Reverse descending domains.
|
|
458
|
+
if (domain[j] < domain[0]) {
|
|
459
|
+
domain = domain.slice().reverse();
|
|
460
|
+
range = range.slice().reverse();
|
|
461
|
+
}
|
|
462
|
+
|
|
463
|
+
while (++i < j) {
|
|
464
|
+
d[i] = normalize(domain[i], domain[i + 1]);
|
|
465
|
+
r[i] = interpolate(range[i], range[i + 1]);
|
|
466
|
+
}
|
|
467
|
+
|
|
468
|
+
return function(x) {
|
|
469
|
+
var i = bisectRight(domain, x, 1, j) - 1;
|
|
470
|
+
return r[i](d[i](x));
|
|
471
|
+
};
|
|
472
|
+
}
|
|
473
|
+
|
|
474
|
+
function copy(source, target) {
|
|
475
|
+
return target
|
|
476
|
+
.domain(source.domain())
|
|
477
|
+
.range(source.range())
|
|
478
|
+
.interpolate(source.interpolate())
|
|
479
|
+
.clamp(source.clamp())
|
|
480
|
+
.unknown(source.unknown());
|
|
481
|
+
}
|
|
482
|
+
|
|
483
|
+
function transformer() {
|
|
484
|
+
var domain = unit,
|
|
485
|
+
range = unit,
|
|
486
|
+
interpolate = interpolateValue,
|
|
487
|
+
transform,
|
|
488
|
+
untransform,
|
|
489
|
+
unknown,
|
|
490
|
+
clamp = identity,
|
|
491
|
+
piecewise,
|
|
492
|
+
output,
|
|
493
|
+
input;
|
|
494
|
+
|
|
495
|
+
function rescale() {
|
|
496
|
+
piecewise = Math.min(domain.length, range.length) > 2 ? polymap : bimap;
|
|
497
|
+
output = input = null;
|
|
498
|
+
return scale;
|
|
499
|
+
}
|
|
500
|
+
|
|
501
|
+
function scale(x) {
|
|
502
|
+
return isNaN(x = +x) ? unknown : (output || (output = piecewise(domain.map(transform), range, interpolate)))(transform(clamp(x)));
|
|
503
|
+
}
|
|
504
|
+
|
|
505
|
+
scale.invert = function(y) {
|
|
506
|
+
return clamp(untransform((input || (input = piecewise(range, domain.map(transform), interpolateNumber)))(y)));
|
|
507
|
+
};
|
|
508
|
+
|
|
509
|
+
scale.domain = function(_) {
|
|
510
|
+
return arguments.length ? (domain = map.call(_, number), clamp === identity || (clamp = clamper(domain)), rescale()) : domain.slice();
|
|
511
|
+
};
|
|
512
|
+
|
|
513
|
+
scale.range = function(_) {
|
|
514
|
+
return arguments.length ? (range = slice$1.call(_), rescale()) : range.slice();
|
|
515
|
+
};
|
|
516
|
+
|
|
517
|
+
scale.rangeRound = function(_) {
|
|
518
|
+
return range = slice$1.call(_), interpolate = interpolateRound, rescale();
|
|
519
|
+
};
|
|
520
|
+
|
|
521
|
+
scale.clamp = function(_) {
|
|
522
|
+
return arguments.length ? (clamp = _ ? clamper(domain) : identity, scale) : clamp !== identity;
|
|
523
|
+
};
|
|
524
|
+
|
|
525
|
+
scale.interpolate = function(_) {
|
|
526
|
+
return arguments.length ? (interpolate = _, rescale()) : interpolate;
|
|
527
|
+
};
|
|
528
|
+
|
|
529
|
+
scale.unknown = function(_) {
|
|
530
|
+
return arguments.length ? (unknown = _, scale) : unknown;
|
|
531
|
+
};
|
|
532
|
+
|
|
533
|
+
return function(t, u) {
|
|
534
|
+
transform = t, untransform = u;
|
|
535
|
+
return rescale();
|
|
536
|
+
};
|
|
537
|
+
}
|
|
538
|
+
|
|
539
|
+
function continuous(transform, untransform) {
|
|
540
|
+
return transformer()(transform, untransform);
|
|
541
|
+
}
|
|
542
|
+
|
|
543
|
+
function tickFormat(start, stop, count, specifier) {
|
|
544
|
+
var step = tickStep(start, stop, count),
|
|
545
|
+
precision;
|
|
546
|
+
specifier = formatSpecifier(specifier == null ? ",f" : specifier);
|
|
547
|
+
switch (specifier.type) {
|
|
548
|
+
case "s": {
|
|
549
|
+
var value = Math.max(Math.abs(start), Math.abs(stop));
|
|
550
|
+
if (specifier.precision == null && !isNaN(precision = precisionPrefix(step, value))) specifier.precision = precision;
|
|
551
|
+
return formatPrefix(specifier, value);
|
|
552
|
+
}
|
|
553
|
+
case "":
|
|
554
|
+
case "e":
|
|
555
|
+
case "g":
|
|
556
|
+
case "p":
|
|
557
|
+
case "r": {
|
|
558
|
+
if (specifier.precision == null && !isNaN(precision = precisionRound(step, Math.max(Math.abs(start), Math.abs(stop))))) specifier.precision = precision - (specifier.type === "e");
|
|
559
|
+
break;
|
|
560
|
+
}
|
|
561
|
+
case "f":
|
|
562
|
+
case "%": {
|
|
563
|
+
if (specifier.precision == null && !isNaN(precision = precisionFixed(step))) specifier.precision = precision - (specifier.type === "%") * 2;
|
|
564
|
+
break;
|
|
565
|
+
}
|
|
566
|
+
}
|
|
567
|
+
return format(specifier);
|
|
568
|
+
}
|
|
569
|
+
|
|
570
|
+
function linearish(scale) {
|
|
571
|
+
var domain = scale.domain;
|
|
572
|
+
|
|
573
|
+
scale.ticks = function(count) {
|
|
574
|
+
var d = domain();
|
|
575
|
+
return ticks(d[0], d[d.length - 1], count == null ? 10 : count);
|
|
576
|
+
};
|
|
577
|
+
|
|
578
|
+
scale.tickFormat = function(count, specifier) {
|
|
579
|
+
var d = domain();
|
|
580
|
+
return tickFormat(d[0], d[d.length - 1], count == null ? 10 : count, specifier);
|
|
581
|
+
};
|
|
582
|
+
|
|
583
|
+
scale.nice = function(count) {
|
|
584
|
+
if (count == null) count = 10;
|
|
585
|
+
|
|
586
|
+
var d = domain(),
|
|
587
|
+
i0 = 0,
|
|
588
|
+
i1 = d.length - 1,
|
|
589
|
+
start = d[i0],
|
|
590
|
+
stop = d[i1],
|
|
591
|
+
step;
|
|
592
|
+
|
|
593
|
+
if (stop < start) {
|
|
594
|
+
step = start, start = stop, stop = step;
|
|
595
|
+
step = i0, i0 = i1, i1 = step;
|
|
596
|
+
}
|
|
597
|
+
|
|
598
|
+
step = tickIncrement(start, stop, count);
|
|
599
|
+
|
|
600
|
+
if (step > 0) {
|
|
601
|
+
start = Math.floor(start / step) * step;
|
|
602
|
+
stop = Math.ceil(stop / step) * step;
|
|
603
|
+
step = tickIncrement(start, stop, count);
|
|
604
|
+
} else if (step < 0) {
|
|
605
|
+
start = Math.ceil(start * step) / step;
|
|
606
|
+
stop = Math.floor(stop * step) / step;
|
|
607
|
+
step = tickIncrement(start, stop, count);
|
|
608
|
+
}
|
|
609
|
+
|
|
610
|
+
if (step > 0) {
|
|
611
|
+
d[i0] = Math.floor(start / step) * step;
|
|
612
|
+
d[i1] = Math.ceil(stop / step) * step;
|
|
613
|
+
domain(d);
|
|
614
|
+
} else if (step < 0) {
|
|
615
|
+
d[i0] = Math.ceil(start * step) / step;
|
|
616
|
+
d[i1] = Math.floor(stop * step) / step;
|
|
617
|
+
domain(d);
|
|
618
|
+
}
|
|
619
|
+
|
|
620
|
+
return scale;
|
|
621
|
+
};
|
|
622
|
+
|
|
623
|
+
return scale;
|
|
624
|
+
}
|
|
625
|
+
|
|
626
|
+
function linear() {
|
|
627
|
+
var scale = continuous(identity, identity);
|
|
628
|
+
|
|
629
|
+
scale.copy = function() {
|
|
630
|
+
return copy(scale, linear());
|
|
631
|
+
};
|
|
632
|
+
|
|
633
|
+
initRange.apply(scale, arguments);
|
|
634
|
+
|
|
635
|
+
return linearish(scale);
|
|
636
|
+
}
|
|
637
|
+
|
|
638
|
+
var css_248z = "#barChart {\n width: 100%; }\n";
|
|
639
|
+
styleInject(css_248z);
|
|
640
|
+
|
|
641
|
+
var BarChart = function BarChart(_ref) {
|
|
642
|
+
var className = _ref.className,
|
|
643
|
+
barChartData = _ref.barChartData,
|
|
644
|
+
setSelectedYear = _ref.setSelectedYear,
|
|
645
|
+
fontColor = _ref.fontColor,
|
|
646
|
+
barColor = _ref.barColor,
|
|
647
|
+
width = _ref.width,
|
|
648
|
+
scaleTicks = _ref.scaleTicks;
|
|
649
|
+
if (!barChartData || barChartData.length === 0) {
|
|
650
|
+
return null;
|
|
651
|
+
}
|
|
652
|
+
// set the dimensions and margins of the graph
|
|
653
|
+
var margin = {
|
|
654
|
+
top: 100,
|
|
655
|
+
right: 30,
|
|
656
|
+
bottom: 90,
|
|
657
|
+
left: 35
|
|
658
|
+
};
|
|
659
|
+
var height = window.innerWidth < 767 ? window.innerWidth * 2 - margin.top - margin.bottom : 700 - margin.top - margin.bottom;
|
|
660
|
+
|
|
661
|
+
// Parse the Data
|
|
662
|
+
var readData = function readData(data) {
|
|
663
|
+
var maxValue = 0;
|
|
664
|
+
data.forEach(function (item) {
|
|
665
|
+
if (parseInt(item.count, 10) > maxValue) {
|
|
666
|
+
maxValue = parseInt(item.count, 10);
|
|
667
|
+
}
|
|
668
|
+
});
|
|
669
|
+
d3Select('div#barChart').html('');
|
|
670
|
+
var svg = d3Select('#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
|
+
// X axis
|
|
672
|
+
var x = band().range([0, width]).domain(data.map(function (d) {
|
|
673
|
+
return d.year;
|
|
674
|
+
})).padding(0.2);
|
|
675
|
+
svg.append('g').attr('id', 'xaxis').attr('transform', "translate(0,".concat(height, ")")).call(axisBottom(x)).style('color', fontColor).selectAll('text').attr('transform', 'translate(-10,0)rotate(-45)').style('text-anchor', 'end').style('color', fontColor).style('font-size', 16).style('cursor', 'pointer').on('click', function (d) {
|
|
676
|
+
setSelectedYear(d);
|
|
677
|
+
});
|
|
678
|
+
|
|
679
|
+
// Add Y axis
|
|
680
|
+
var y = linear().domain([0, maxValue]).range([height, 0]);
|
|
681
|
+
|
|
682
|
+
// Bars
|
|
683
|
+
svg.selectAll('mybar').data(data).enter().append('rect').attr('x', function (d) {
|
|
684
|
+
return x(d.year);
|
|
685
|
+
}).attr('width', x.bandwidth()).attr('fill', barColor).attr('title', function (d) {
|
|
686
|
+
return d.count;
|
|
687
|
+
})
|
|
688
|
+
// no bar at the beginning thus:
|
|
689
|
+
.attr('height', function () {
|
|
690
|
+
return height - y(0);
|
|
691
|
+
}) // always equal to 0
|
|
692
|
+
.attr('y', function () {
|
|
693
|
+
return y(0);
|
|
694
|
+
}).style('cursor', 'pointer').on('click', function (d) {
|
|
695
|
+
return setSelectedYear(d.year);
|
|
696
|
+
}).append('svg:title').text(function (d) {
|
|
697
|
+
return "\u6578\u91CF:".concat(d.count);
|
|
698
|
+
});
|
|
699
|
+
|
|
700
|
+
// Animation
|
|
701
|
+
svg.selectAll('rect').transition().duration(800).attr('y', function (d) {
|
|
702
|
+
return y(d.count);
|
|
703
|
+
}).attr('height', function (d) {
|
|
704
|
+
return height - y(d.count);
|
|
705
|
+
}).delay(function (d, i) {
|
|
706
|
+
return i * 10;
|
|
707
|
+
});
|
|
708
|
+
svg.append('g').call(axisLeft(y).tickValues(sequence(y.domain()[0], y.domain()[1] + 1, scaleTicks)).tickFormat(function (d) {
|
|
709
|
+
return Math.round(d);
|
|
710
|
+
})).attr('id', 'yaxis').style('color', fontColor).style('font-size', 15);
|
|
711
|
+
};
|
|
712
|
+
function shiftYaxis() {
|
|
713
|
+
var element = document.getElementById('barChart__block');
|
|
714
|
+
if (element.scrollLeft === 0) {
|
|
715
|
+
document.getElementById('yaxis').setAttribute('transform', 'translate(0, 0 )');
|
|
716
|
+
}
|
|
717
|
+
if (element.scrollLeft > 0) {
|
|
718
|
+
document.getElementById('yaxis').setAttribute('transform', "translate(".concat(element.scrollLeft, ", 0)"));
|
|
719
|
+
}
|
|
720
|
+
}
|
|
721
|
+
useEffect(function () {
|
|
722
|
+
if (barChartData.length > 0) {
|
|
723
|
+
readData(barChartData);
|
|
724
|
+
}
|
|
725
|
+
document.getElementById('barChart__block').addEventListener('scroll', shiftYaxis);
|
|
726
|
+
}, [barChartData]);
|
|
727
|
+
return /*#__PURE__*/React__default.createElement("div", {
|
|
728
|
+
id: "barChart",
|
|
729
|
+
className: classNames('barChart', className)
|
|
730
|
+
});
|
|
731
|
+
};
|
|
732
|
+
BarChart.defaultProps = {
|
|
733
|
+
className: undefined,
|
|
734
|
+
barChartData: [],
|
|
735
|
+
setSelectedYear: function setSelectedYear() {
|
|
736
|
+
return null;
|
|
737
|
+
},
|
|
738
|
+
fontColor: '#000',
|
|
739
|
+
barColor: '#69b3a2',
|
|
740
|
+
width: 2000,
|
|
741
|
+
scaleTicks: 1
|
|
742
|
+
};
|
|
743
|
+
|
|
744
|
+
/* Write props detail information and 'npm run updateStory' will help you generate stories's argTypes */
|
|
745
|
+
BarChart.propTypes = {
|
|
746
|
+
/** Css Name */
|
|
747
|
+
className: PropTypes.string,
|
|
748
|
+
/** 資料來源 */
|
|
749
|
+
barChartData: PropTypes.arrayOf(PropTypes.any),
|
|
750
|
+
/** 設定點選年分 */
|
|
751
|
+
setSelectedYear: PropTypes.func,
|
|
752
|
+
/** X、Y尺度字的顏色 */
|
|
753
|
+
fontColor: PropTypes.string,
|
|
754
|
+
/** 長條圖的顏色 */
|
|
755
|
+
barColor: PropTypes.string,
|
|
756
|
+
/** 圖表的寬度,影響bar的粗度 */
|
|
757
|
+
width: PropTypes.number,
|
|
758
|
+
/** 刻度的級距,以一個刻度相差多少 */
|
|
759
|
+
scaleTicks: PropTypes.number
|
|
760
|
+
};
|
|
761
|
+
|
|
762
|
+
export { BarChart as default };
|