@plotdb/chart 3.0.1 → 3.1.0
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/CHANGELOG.md +43 -0
- package/index.js +267 -8
- package/index.min.js +1 -1
- package/package.json +1 -1
- package/utils/axis.min.js +1 -1
- package/utils/config.js +18 -0
- package/utils/config.min.js +1 -1
- package/utils/data.min.js +1 -1
- package/utils/legend.js +44 -0
- package/utils/legend.min.js +1 -1
- package/utils/tick.min.js +1 -1
- package/utils/tint.min.js +1 -1
- package/utils/tip.min.js +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,48 @@
|
|
|
1
1
|
# Change Logs
|
|
2
2
|
|
|
3
|
+
## v3.1.0
|
|
4
|
+
|
|
5
|
+
- add subset channel. a host ( a dashboard, say ) often has two results for the same query:
|
|
6
|
+
the complete raw and the subset left after filtering. both share the same schema, so they
|
|
7
|
+
share the same binding — a chart doesn't have to learn any extra field to know the
|
|
8
|
+
filtering state. `setRaw` now takes `{raw, binding, subset}`, and core aligns the subset
|
|
9
|
+
by the same binding and attaches `d.subset` to each datum before `mod.parse` runs, so mods
|
|
10
|
+
that rebuild data ( pie's rings, for one ) carry it along. how to present it is the chart's
|
|
11
|
+
own business, configured by `cfg.common.subset.mode`: `dim`, `partial` or `shrink`
|
|
12
|
+
( `shrink` is done by core — it overwrites the numeric dimensions with the subset, so the
|
|
13
|
+
mod doesn't have to know subset exists at all ). charts that are never given a subset are
|
|
14
|
+
unaffected: `d.subset` simply isn't there.
|
|
15
|
+
- add instance scopes. `chart.scopes` is the registry of namespaces core installs on every
|
|
16
|
+
instance, bound to it at construction; today it holds `subset` ( `set`, `mode`, `ratio`,
|
|
17
|
+
`color` ). a mod may override individual functions of a scope via `mod.<scope>.<fn>` —
|
|
18
|
+
merged at construction, so there is nothing to check at run time. only core can declare a
|
|
19
|
+
scope: opening a new one means editing core, and that friction is deliberate. `local` is
|
|
20
|
+
reserved for the chart's own helpers — core guarantees the name is not taken by anyone
|
|
21
|
+
else and manages nothing inside it. this replaces patching the instance from the outside,
|
|
22
|
+
and lets a mod's own helpers be called as `@local.fn()` rather than
|
|
23
|
+
`self.mod.fn.call self, ...`.
|
|
24
|
+
- add `filterDims()` / `canFilter()`. a chart declares which binding dimensions it emits
|
|
25
|
+
filters for via `mod.filterDims`; core falls back to `['name']` when a mod has `filter`
|
|
26
|
+
but no declaration. a host uses this to decide which dimension still needs the `select`
|
|
27
|
+
event to stand in for a filter.
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
## v3.0.2
|
|
31
|
+
|
|
32
|
+
- fix bug: chart never inits in a background tab. init waited for the first resizeObserver
|
|
33
|
+
callback, but chrome skips the whole "update the rendering" step for a non-rendered
|
|
34
|
+
document, so ResizeObserver ( and rAF ) never fire there — `attach` simply never resolved.
|
|
35
|
+
measured: RO 0 calls in 1.2s while getBoundingClientRect returned the correct size all
|
|
36
|
+
along; the notification was missing, the size never was. init now measures the root
|
|
37
|
+
first and only waits when the measurement tells it nothing. the measurement uses
|
|
38
|
+
offsetWidth / offsetHeight rather than getBoundingClientRect: the latter is the visual
|
|
39
|
+
box, so an in-flight ancestor transform ( a dashboard revealing panels with a rotate
|
|
40
|
+
transition, say ) reports a squeezed or even zero width.
|
|
41
|
+
- fix bug: force-init charts ( and charts on invisible nodes ) were never observed for
|
|
42
|
+
resize at all — `resizeObserver.add` lives inside the lock, and those paths returned
|
|
43
|
+
before running it, so the node was never registered for the rest of its life.
|
|
44
|
+
|
|
45
|
+
|
|
3
46
|
## v3.0.1
|
|
4
47
|
|
|
5
48
|
- fix bug: mod.resize / mod.render may be called before mod.init when set-raw or resize
|
package/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
(function(){
|
|
2
|
-
var svgns, _np, _nparse, parent, aniloop, visibilityObserver, resizeObserver, withDefault, defaultConfig, chart;
|
|
2
|
+
var svgns, _np, _nparse, _snum, _isNumeric, _alignDim, _parseSubset, _rgb, bindScope, parent, aniloop, visibilityObserver, resizeObserver, withDefault, defaultConfig, chart;
|
|
3
3
|
svgns = "http://www.w3.org/2000/svg";
|
|
4
4
|
_np = function(lc){
|
|
5
5
|
var format, parts, numerals, index;
|
|
@@ -35,6 +35,159 @@
|
|
|
35
35
|
return NaN;
|
|
36
36
|
}
|
|
37
37
|
};
|
|
38
|
+
_snum = function(v){
|
|
39
|
+
if (typeof v === 'number') {
|
|
40
|
+
return v;
|
|
41
|
+
} else {
|
|
42
|
+
if ((!v && v !== 0) || isNaN(+v)) {
|
|
43
|
+
return 0;
|
|
44
|
+
} else {
|
|
45
|
+
return +v;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
_isNumeric = function(d){
|
|
50
|
+
d == null && (d = {});
|
|
51
|
+
return !!(/[RIT]/.exec(d.type || '') && !/[CN]/.exec(d.type || ''));
|
|
52
|
+
};
|
|
53
|
+
_alignDim = function(dim){
|
|
54
|
+
var ks, res$, k, i$, ref$, len$;
|
|
55
|
+
dim == null && (dim = {});
|
|
56
|
+
res$ = [];
|
|
57
|
+
for (k in dim) {
|
|
58
|
+
res$.push(k);
|
|
59
|
+
}
|
|
60
|
+
ks = res$;
|
|
61
|
+
for (i$ = 0, len$ = (ref$ = ['name', 'order']).length; i$ < len$; ++i$) {
|
|
62
|
+
k = ref$[i$];
|
|
63
|
+
if (dim[k] && !_isNumeric(dim[k])) {
|
|
64
|
+
return k;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
return ks.filter(function(k){
|
|
68
|
+
return !_isNumeric(dim[k]);
|
|
69
|
+
})[0];
|
|
70
|
+
};
|
|
71
|
+
_parseSubset = function(){
|
|
72
|
+
var dim, kd, rows, hash, this$ = this;
|
|
73
|
+
dim = (this.mod || {}).dimension || {};
|
|
74
|
+
if (!this._subset) {
|
|
75
|
+
this.data.map(function(it){
|
|
76
|
+
var ref$;
|
|
77
|
+
return ref$ = it.subset, delete it.subset, ref$;
|
|
78
|
+
});
|
|
79
|
+
return;
|
|
80
|
+
}
|
|
81
|
+
kd = _alignDim(dim);
|
|
82
|
+
rows = this._subset.map(function(r){
|
|
83
|
+
var ret, k, ref$, v, b;
|
|
84
|
+
ret = {};
|
|
85
|
+
for (k in ref$ = dim) {
|
|
86
|
+
v = ref$[k];
|
|
87
|
+
if (!(b = this$.binding[k])) {
|
|
88
|
+
continue;
|
|
89
|
+
}
|
|
90
|
+
ret[k] = !v.multiple
|
|
91
|
+
? r[b.key]
|
|
92
|
+
: (b.map
|
|
93
|
+
? b
|
|
94
|
+
: [b]).map(fn$);
|
|
95
|
+
if (_isNumeric(v)) {
|
|
96
|
+
ret[k] = Array.isArray(ret[k])
|
|
97
|
+
? ret[k].map(_snum)
|
|
98
|
+
: _snum(ret[k]);
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
return ret;
|
|
102
|
+
function fn$(it){
|
|
103
|
+
return r[it.key];
|
|
104
|
+
}
|
|
105
|
+
});
|
|
106
|
+
hash = {};
|
|
107
|
+
if (kd) {
|
|
108
|
+
rows.map(function(r){
|
|
109
|
+
return hash[r[kd] + ""] = r;
|
|
110
|
+
});
|
|
111
|
+
}
|
|
112
|
+
this.data.map(function(d, i){
|
|
113
|
+
var src, subset, k, ref$, v;
|
|
114
|
+
src = kd
|
|
115
|
+
? hash[d[kd] + ""]
|
|
116
|
+
: rows[i];
|
|
117
|
+
subset = {};
|
|
118
|
+
for (k in ref$ = dim) {
|
|
119
|
+
v = ref$[k];
|
|
120
|
+
if (!_isNumeric(v)) {
|
|
121
|
+
continue;
|
|
122
|
+
}
|
|
123
|
+
subset[k] = v.multiple
|
|
124
|
+
? (d[k] || []).map(fn$)
|
|
125
|
+
: src ? _snum(src[k]) : 0;
|
|
126
|
+
}
|
|
127
|
+
return d.subset = subset;
|
|
128
|
+
function fn$(x, j){
|
|
129
|
+
if (src) {
|
|
130
|
+
return _snum((src[k] || [])[j]);
|
|
131
|
+
} else {
|
|
132
|
+
return 0;
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
});
|
|
136
|
+
if ((((this.cfg || {}).common || {}).subset || {}).mode === 'shrink') {
|
|
137
|
+
return this.data.map(function(d){
|
|
138
|
+
var k, ref$, v, results$ = [];
|
|
139
|
+
for (k in ref$ = dim) {
|
|
140
|
+
v = ref$[k];
|
|
141
|
+
if (_isNumeric(v)) {
|
|
142
|
+
results$.push(d[k] = d.subset[k]);
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
return results$;
|
|
146
|
+
});
|
|
147
|
+
}
|
|
148
|
+
};
|
|
149
|
+
_rgb = function(c){
|
|
150
|
+
var m, x, v;
|
|
151
|
+
if (typeof c !== 'string') {
|
|
152
|
+
return null;
|
|
153
|
+
}
|
|
154
|
+
c = c.trim();
|
|
155
|
+
if (m = /^#([0-9a-f]{3})$/i.exec(c)) {
|
|
156
|
+
return (function(){
|
|
157
|
+
var i$, ref$, len$, results$ = [];
|
|
158
|
+
for (i$ = 0, len$ = (ref$ = m[1].split('')).length; i$ < len$; ++i$) {
|
|
159
|
+
x = ref$[i$];
|
|
160
|
+
results$.push(parseInt(x + x, 16));
|
|
161
|
+
}
|
|
162
|
+
return results$;
|
|
163
|
+
}());
|
|
164
|
+
}
|
|
165
|
+
if (m = /^#([0-9a-f]{6})$/i.exec(c)) {
|
|
166
|
+
return [0, 1, 2].map(function(i){
|
|
167
|
+
return parseInt(m[1].substr(i * 2, 2), 16);
|
|
168
|
+
});
|
|
169
|
+
}
|
|
170
|
+
if (m = /^rgba?\(([^)]+)\)$/i.exec(c)) {
|
|
171
|
+
v = m[1].split(',').slice(0, 3).map(function(it){
|
|
172
|
+
return parseFloat(it.trim());
|
|
173
|
+
});
|
|
174
|
+
return v.length === 3 && v.every(function(it){
|
|
175
|
+
return !isNaN(it);
|
|
176
|
+
}) ? v : null;
|
|
177
|
+
}
|
|
178
|
+
return null;
|
|
179
|
+
};
|
|
180
|
+
bindScope = function(self, tbl, over){
|
|
181
|
+
var ret, k, ref$, f;
|
|
182
|
+
tbl == null && (tbl = {});
|
|
183
|
+
over == null && (over = {});
|
|
184
|
+
ret = {};
|
|
185
|
+
for (k in ref$ = import$(import$({}, tbl), over || {})) {
|
|
186
|
+
f = ref$[k];
|
|
187
|
+
ret[k] = typeof f === 'function' ? f.bind(self) : f;
|
|
188
|
+
}
|
|
189
|
+
return ret;
|
|
190
|
+
};
|
|
38
191
|
parent = function(n, s, e){
|
|
39
192
|
var m;
|
|
40
193
|
m = n;
|
|
@@ -246,7 +399,7 @@
|
|
|
246
399
|
return _(cfg);
|
|
247
400
|
};
|
|
248
401
|
chart = function(opt){
|
|
249
|
-
var this$ = this;
|
|
402
|
+
var name, ref$, tbl, this$ = this;
|
|
250
403
|
opt == null && (opt = {});
|
|
251
404
|
this.root = typeof opt.root === 'string'
|
|
252
405
|
? document.querySelector(opt.root)
|
|
@@ -274,6 +427,18 @@
|
|
|
274
427
|
this.binding = opt.binding || {};
|
|
275
428
|
this._normalizeBinding();
|
|
276
429
|
this.evtHandler = {};
|
|
430
|
+
this._subset = opt.subset || null;
|
|
431
|
+
for (name in ref$ = chart.scopes) {
|
|
432
|
+
tbl = ref$[name];
|
|
433
|
+
if (this[name] != null) {
|
|
434
|
+
throw new Error("[@plotdb/chart] scope name `" + name + "` is already taken.");
|
|
435
|
+
}
|
|
436
|
+
this[name] = bindScope(this, tbl, this.mod[name]);
|
|
437
|
+
}
|
|
438
|
+
if (this.local != null) {
|
|
439
|
+
throw new Error("[@plotdb/chart] scope name `local` is already taken.");
|
|
440
|
+
}
|
|
441
|
+
this.local = bindScope(this, {}, this.mod.local);
|
|
277
442
|
this.init = proxise.once(function(){
|
|
278
443
|
return this$._init();
|
|
279
444
|
});
|
|
@@ -337,7 +502,8 @@
|
|
|
337
502
|
});
|
|
338
503
|
return p = Promise.resolve().then(function(){
|
|
339
504
|
var defcfg, ret;
|
|
340
|
-
this$.
|
|
505
|
+
this$.mod.config = withDefault(this$.mod.config || {}, chart.commonConfig);
|
|
506
|
+
this$._defcfg = defcfg = defaultConfig(this$.mod.config);
|
|
341
507
|
withDefault(this$.cfg, defcfg);
|
|
342
508
|
if (this$.raw && Array.isArray(this$.raw)) {
|
|
343
509
|
return {
|
|
@@ -356,7 +522,7 @@
|
|
|
356
522
|
var ref$;
|
|
357
523
|
return this$.raw = (ref$ = it || {}).raw, this$.binding = ref$.binding, this$;
|
|
358
524
|
}).then(function(){
|
|
359
|
-
var ref$, _resizeLock;
|
|
525
|
+
var ref$, _resizeLock, lock;
|
|
360
526
|
if (!this$.raw) {
|
|
361
527
|
this$.raw = [];
|
|
362
528
|
}
|
|
@@ -380,13 +546,14 @@
|
|
|
380
546
|
resizeObserver.add(this$.root, this$);
|
|
381
547
|
return null;
|
|
382
548
|
});
|
|
383
|
-
if (this$.forceInit || !this$.root.offsetParent || window.getComputedStyle(this$.root).display === 'none') {
|
|
384
|
-
return;
|
|
385
|
-
}
|
|
386
549
|
this$._resize = function(){
|
|
387
550
|
return _resizeLock.resolve();
|
|
388
551
|
};
|
|
389
|
-
|
|
552
|
+
lock = _resizeLock();
|
|
553
|
+
if (this$.forceInit || !this$.root.offsetParent || window.getComputedStyle(this$.root).display === 'none' || (this$.root.offsetWidth && this$.root.offsetHeight)) {
|
|
554
|
+
_resizeLock.resolve();
|
|
555
|
+
}
|
|
556
|
+
return lock;
|
|
390
557
|
}).then(function(){
|
|
391
558
|
return this$._resize = function(){};
|
|
392
559
|
}).then(function(){
|
|
@@ -473,6 +640,7 @@
|
|
|
473
640
|
return _nparse(it);
|
|
474
641
|
}
|
|
475
642
|
});
|
|
643
|
+
_parseSubset.apply(this);
|
|
476
644
|
if (this.mod.parse) {
|
|
477
645
|
return this.mod.parse.apply(this);
|
|
478
646
|
}
|
|
@@ -594,6 +762,9 @@
|
|
|
594
762
|
var ref$;
|
|
595
763
|
reinit == null && (reinit = false);
|
|
596
764
|
if (!Array.isArray(raw)) {
|
|
765
|
+
if (raw && 'subset' in raw) {
|
|
766
|
+
this._subset = raw.subset || null;
|
|
767
|
+
}
|
|
597
768
|
ref$ = raw, raw = ref$.raw, binding = ref$.binding, reinit = ref$.reinit;
|
|
598
769
|
}
|
|
599
770
|
if (raw != null) {
|
|
@@ -689,8 +860,96 @@
|
|
|
689
860
|
binding: {}
|
|
690
861
|
};
|
|
691
862
|
}
|
|
863
|
+
},
|
|
864
|
+
filterDims: function(){
|
|
865
|
+
var that;
|
|
866
|
+
if (that = (this.mod || {}).filterDims) {
|
|
867
|
+
return that.call(this);
|
|
868
|
+
} else if ((this.mod || {}).filter) {
|
|
869
|
+
return ['name'];
|
|
870
|
+
} else {
|
|
871
|
+
return [];
|
|
872
|
+
}
|
|
873
|
+
},
|
|
874
|
+
canFilter: function(){
|
|
875
|
+
return !!this.filterDims().length;
|
|
692
876
|
}
|
|
693
877
|
});
|
|
878
|
+
chart.commonConfig = {
|
|
879
|
+
common: {
|
|
880
|
+
subset: {
|
|
881
|
+
mode: {
|
|
882
|
+
type: 'choice',
|
|
883
|
+
values: ['dim', 'partial', 'shrink'],
|
|
884
|
+
'default': 'dim'
|
|
885
|
+
},
|
|
886
|
+
opacity: {
|
|
887
|
+
type: 'number',
|
|
888
|
+
'default': 0.2,
|
|
889
|
+
min: 0,
|
|
890
|
+
max: 1,
|
|
891
|
+
step: 0.05
|
|
892
|
+
},
|
|
893
|
+
fade: {
|
|
894
|
+
type: 'number',
|
|
895
|
+
'default': 0.72,
|
|
896
|
+
min: 0,
|
|
897
|
+
max: 1,
|
|
898
|
+
step: 0.01
|
|
899
|
+
}
|
|
900
|
+
}
|
|
901
|
+
}
|
|
902
|
+
};
|
|
903
|
+
chart.scopes = {
|
|
904
|
+
subset: {
|
|
905
|
+
set: function(raw){
|
|
906
|
+
this._subset = raw || null;
|
|
907
|
+
if (!this._inited) {
|
|
908
|
+
return;
|
|
909
|
+
}
|
|
910
|
+
this.parse();
|
|
911
|
+
this.bind();
|
|
912
|
+
this.resize();
|
|
913
|
+
return this.render();
|
|
914
|
+
},
|
|
915
|
+
mode: function(){
|
|
916
|
+
return (((this.cfg || {}).common || {}).subset || {}).mode || 'dim';
|
|
917
|
+
},
|
|
918
|
+
ratio: function(d, k, i){
|
|
919
|
+
var ref$, v, p, r;
|
|
920
|
+
if (!(d && d.subset)) {
|
|
921
|
+
return null;
|
|
922
|
+
}
|
|
923
|
+
ref$ = i != null
|
|
924
|
+
? [(d[k] || [])[i], (d.subset[k] || [])[i]]
|
|
925
|
+
: [d[k], d.subset[k]], v = ref$[0], p = ref$[1];
|
|
926
|
+
if (!v) {
|
|
927
|
+
return 0;
|
|
928
|
+
}
|
|
929
|
+
r = p / v;
|
|
930
|
+
if (r < 0) {
|
|
931
|
+
return 0;
|
|
932
|
+
} else if (r > 1) {
|
|
933
|
+
return 1;
|
|
934
|
+
} else {
|
|
935
|
+
return r;
|
|
936
|
+
}
|
|
937
|
+
},
|
|
938
|
+
color: function(color, fade){
|
|
939
|
+
var rgb, g, f, v;
|
|
940
|
+
if (!(rgb = _rgb(color))) {
|
|
941
|
+
return color;
|
|
942
|
+
}
|
|
943
|
+
g = 0.3 * rgb[0] + 0.59 * rgb[1] + 0.11 * rgb[2];
|
|
944
|
+
f = fade != null
|
|
945
|
+
? fade
|
|
946
|
+
: (((this.cfg || {}).common || {}).subset || {}).fade;
|
|
947
|
+
f = f != null ? f : 0.72;
|
|
948
|
+
v = Math.round(g + (255 - g) * f);
|
|
949
|
+
return "rgb(" + v + "," + v + "," + v + ")";
|
|
950
|
+
}
|
|
951
|
+
}
|
|
952
|
+
};
|
|
694
953
|
if (typeof module != 'undefined' && module !== null) {
|
|
695
954
|
module.exports = chart;
|
|
696
955
|
} else if (typeof window != 'undefined' && window !== null) {
|
package/index.min.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
!function(){var e,c,n,r,o,s,u,a,t;function l(t,e,d){function f(t,e){return n.call(t,e)}var p={}.toString,n={}.hasOwnProperty,m=!0;return function t(e,n,i){var r,o,s,u,a,l,h,c;if(null==e||null==n)return e===n;if(e.__placeholder__||n.__placeholder__)return!0;if(e===n)return 0!==e||1/e==1/n;r=p.call(e);if(p.call(n)!=r)return!1;switch(r){case"[object String]":return e==String(n);case"[object Number]":return e!=+e?n!=+n:0==e?1/e==1/n:e==+n;case"[object Date]":case"[object Boolean]":return+e==+n;case"[object RegExp]":return e.source==n.source&&e.global==n.global&&e.multiline==n.multiline&&e.ignoreCase==n.ignoreCase}if("object"!=typeof e||"object"!=typeof n)return!1;o=i.length;for(;o--;)if(i[o]==e)return!0;i.push(e);s=0;u=!0;if("[object Array]"==r){if(a=e.length,l=n.length,m){switch(d){case"===":u=a===l;break;case"<==":u=a<=l;break;case"<<=":u=a<l}s=a,m=!1}else u=a===l,s=a;if(u)for(;s--&&(u=s in e==s in n&&t(e[s],n[s],i)););}else{if("constructor"in e!="constructor"in n||e.constructor!=n.constructor)return!1;for(h in e)if(f(e,h)&&(s++,!(u=f(n,h)&&t(e[h],n[h],i))))break;if(u){for(h in c=0,n)f(n,h)&&++c;u=m?"<<="===d?s<c:"<=="===d?s<=c:s===c:(m=!1,s===c)}}i.pop();return u}(t,e,[])}function h(t,e){var n,i={}.hasOwnProperty;for(n in e)i.call(e,n)&&(t[n]=e[n]);return t}e=new function(t){var n=new Intl.NumberFormat(t),e=n.formatToParts(12345.6),t=Array.from({length:10}).map(function(t,e){return n.format(e)}),i=new Map(t.map(function(t,e){return[t,e]}));return this._group=new RegExp("["+e.find(function(t){return l(t.type,"group","===")}).value+"]","g"),this._decimal=new RegExp("["+e.find(function(t){return l(t.type,"decimal","===")}).value+"]"),this._numeral=new RegExp("["+t.join("")+"]","g"),this._index=function(t){return i.get(t)},this}("en-US"),c=function(t){return(t=((t=null==t?"":t)+"").trim().replace(e._group,"").replace(e._decimal,".").replace(e._numeral,e._index))?+t:NaN},n=function(t,e,n){for(var i=t;t&&t!==n;)t=t.parentNode;if(t!==n)return null;if(!e)return t;for(t=i;t&&t!==n&&(!t.matches||t.matches&&!t.matches(e));)t=t.parentNode;return t!==n||n.matches&&n.matches(e)?t:null},(r=function(){return this.running=!1,this.time={now:0,last:0},this.fps(60),this.evtHandler={},this}).prototype=h(Object.create(Object.prototype),{on:function(t,n){var i=this;return(Array.isArray(t)?t:[t]).map(function(t){var e;return((e=i.evtHandler)[t]||(e[t]=[])).push(n)})},fire:function(t){for(var e,n,i,r,o=[],s=[],u=1,a=arguments.length;u<a;++u)s.push(arguments[u]);for(e=s,u=0,i=(n=this.evtHandler[t]||[]).length;u<i;++u)r=n[u],o.push(r.apply(this,e));return o},reset:function(){return this.time={now:0}},setTime:function(t){return this.time.now=t},getTime:function(){return this.time.now},isRunning:function(){return this.running},toggle:function(t){return null!=t&&(this.running=!t),this.running?this.pause():this.run()},pause:function(){return this.running=!1},render:function(){return this.fire("tick",this.time.now)},run:function(t){var e=this;if(null!=t&&this.fps(t),!this.running)return this.running=!0,requestAnimationFrame(function(t){return e.handler(e.time.last=t,!0)})},throttle:function(t){return this.isThrottled=t=null==t?!0:t},fps:function(t){return null==t?this._fps_val:(this._fps_val=.01<t?t:.01,this._fps_delay=1e3/this._fps_val)},handler:function(t,e){var n,i=this;if(null==e&&(e=!1),this.running)return this.time.now=t,n=this.isThrottled?1e3<(n=this._fps_delay)?n:1e3:this._fps_delay,(e||this.time.now-this.time.last>=n)&&(this.time.last=t,this.render()),requestAnimationFrame(function(t){return i.handler(t,!1)})}}),o={list:[],init:function(){var t,n,i=this;return this.inited=!0,t=null==document.hidden&&null==document.msHidden&&null!=document.webkiHidden?["webkitHidden","webkitvisibilitychange"]:["hidden","visibilitychange"],n=t[0],document.addEventListener(t[1],debounce(150,function(){var e=!!document[n];return i.list.map(function(t){return t.throttle(e)})},!1))},add:function(t){return this.inited||this.init(),this.list.push(t)}},s={wm:new WeakMap,ro:new ResizeObserver(function(t){return t.map(function(t){return s.wm.get(t.target)._resize()})}),add:function(t,e){return this.wm.set(t,e),this.ro.observe(t)},delete:function(t){return this.ro.unobserve(t),this.wm.delete(t)}},u=function(t,e,n){return null==e&&(e={}),null==n&&(n={}),function(t,e,n){var i,r;for(i in e)r=e[i],null==t[i]?t[i]=r:"object"!=typeof t[i]||"object"!=typeof r||n[i]&&n[i].type||u(t[i],e[i],n[i]);return t}(t=null==t?{}:t,e=JSON.parse(JSON.stringify(e)),n)},a=function(t){var o=function(t,e){var n,i,r;for(i in null==e&&(e={}),n=t.child,t)(r=t[i]).type?r.default&&(e[i]=r.default):o(r,e[i]||(e[i]={}));return e};return o(t)},(t=function(t){var e=this;return this.root="string"==typeof(t=null==t?{}:t).root?document.querySelector(t.root):t.root,this.useSample=null==t.useSample||t.useSample,this.autoSelect=null==t.autoSelect||t.autoSelect,this.forceInit=t.forceInit||!1,this.prepareSvg=null==t.prepareSvg||t.prepareSvg,this.layoutOpt=null==t.layout||t.layout,this.delayRender=t.delayRender||!1,this.dataAccessor=null!=t.dataAccessor?t.dataAccessor:function(t){return t?t.data._raw:null},this.data=[],this.raw=t.raw||null,this.mod=t.mod||{},this.cfg=t.config||{},this.seed=t.seed||Math.random(),this.binding=t.binding||{},this._normalizeBinding(),this.evtHandler={},this.init=proxise.once(function(){return e._init()}),this._resize=null,this._inited=!1,this.autoSelect&&(this.root.addEventListener("click",this._select=function(t){if(t=n(t.target,".data",e.root))return e.fire("select",[{data:e.dataAccessor(t),node:t}])}),this.root.addEventListener("mouseover",this._hover=function(t){if(t=ld$.parent(t.target,".data",e.root))return e.fire("hover",[{data:e.dataAccessor(t),node:t}])})),this}).prototype=h(Object.create(Object.prototype),{_init:function(){var n,t,e,i=this;return"static"===window.getComputedStyle(this.root).position&&(this.root.style.position="relative"),n=this.layoutOpt?"object"!=typeof this.layoutOpt?this.root.querySelector(".pdl-layout"):"string"==typeof this.layoutOpt.root?this.root.querySelector(this.layoutOpt.root):this.layoutOpt.root||null:null,this.prepareSvg&&!(this.svg=this.root.querySelector("svg"))&&(this.svg=document.createElementNS("http://www.w3.org/2000/svg","svg"),(t=this.svg.style).width="100%",t.height="100%",this.layoutOpt&&(n||console.error("[@plotdb/chart] layout enabled yet layout root isn't configured properly. "),(e=n.querySelector("[data-type=render]"))||console.warn("[@plotdb/chart] prepareSvg and layout is configured at the same time,\nyet render container for layout is not found. svg is thus appended in the root.")),(e||this.root).appendChild(this.svg)),this._aniloop=new r,o.add(this._aniloop),this._aniloop.on("tick",function(){return i.tick()}),Promise.resolve().then(function(){var t;return i._defcfg=t=a(i.mod.config||{}),u(i.cfg,t),i.raw&&Array.isArray(i.raw)?{raw:i.raw,binding:i.binding}:i.useSample&&i.mod.sample?(t=i.mod.sample.apply(i)).then?t.then():Promise.resolve(t):void 0}).then(function(t){return i.raw=(t=t||{}).raw,i.binding=t.binding,i}).then(function(){var t,e;if(i.raw||(i.raw=[]),i.layoutOpt&&("undefined"==typeof layout||null===layout?console.warn("[@plotdb/chart] layout-opt is set yet @plotdb/layout is not found."):(n||(console.error("[@plotdb/chart] cannot determine root node for @plotdb/layout."),console.error("[@plotdb/chart] config layout properly or disable layout by setting layout to false")),i.layout=new layout("object"==typeof i.layoutOpt?((t=h({},i.layoutOpt)).watchResize=!1,t):{root:n,watchResize:!1}))),e=proxise(function(){return s.add(i.root,i),null}),!i.forceInit&&i.root.offsetParent&&"none"!==window.getComputedStyle(i.root).display)return i._resize=function(){return e.resolve()},e()}).then(function(){return i._resize=function(){}}).then(function(){var t,e=function(){if(i.mod.init)return i.mod.init.apply(i)};return i.layout?(t=proxise(function(){return Promise.resolve(i.layout.init(e)),null}),i._layout=function(){return t.resolve()},i.layout.on("render",function(){return i._layout()}),t()):e()}).then(function(){i._layout=function(){},Promise.resolve().then(function(){if(i.delayRender&&!i._pendingRaw)return i.renderLock=proxise(function(){}),i.renderLock()}).then(function(){return i._inited=!0,i._resize=function(){return i.resize(),i.render()},i._layout=function(){return i.parse(),i.bind(),i.resize(),i.render()},i.parse(),i.bind(),i.resize(),i.render()})})},parse:function(){var t,l=(t=this.mod).dimension||(t.dimension={}),h=this.binding;if(this.data=this.raw.map(function(e,t){var n,i,r,o,s={};for(n in i=l)r=i[n],(o=h[n])?(s[n]=r.multiple?(o.map?o:[o]).map(u):e[o.key],/[RIT]/.exec(r.type)&&!/[CN]/.exec(r.type)&&(s[n]=Array.isArray(s[n])?s[n].map(a):c(s[n]))):r.multiple&&(s[n]=[]);return s._raw=e,s._idx=t,s;function u(t){return e[t.key]}function a(t){return c(t)}}),this.mod.parse)return this.mod.parse.apply(this)},bind:function(){if(this.mod.bind)return this.mod.bind.apply(this)},start:function(){if(this._aniloop.run(),this.mod.start)return this.mod.start.apply(this)},stop:function(){if(this._aniloop.pause(),this.mod.stop)return this.mod.stop.apply(this)},resize:function(){if(this._inited)return this.layout&&this.layout.update(!1),this.box=this.root.getBoundingClientRect(),this.mod.resize?this.mod.resize.apply(this):void 0},tick:function(){if(this.mod.tick)return this.mod.tick.apply(this)},render:function(){if(this._inited)return this.mod.render?this.mod.render.apply(this):void 0},destroy:function(){var t=this;return Promise.resolve().then(function(){if(t._select&&t.root.removeEventListener("click",t._select),t._hover&&t.root.removeEventListener("mouseover",t._hover),s.delete(t.root),t.layout&&t.layout.destroy(),t.stop(),t.mod.destroy)return t.mod.destroy.apply(t)})},config:function(){var t,e,n;if(!arguments.length)return this.cfg;for(t={},e=0,n=arguments.length;e<n;++e)u(t,arguments[e],this.mod.config);return u(t,this.cfg,this.mod.config),u(t,this._defcfg,this.mod.config),h(this.cfg,t)},_normalizeBinding:function(t){var e,n,i,r,o,s,u,a=[];if(null==t){for(t in e=[],this.mod.dimension||{})e.push(t);t=e}for(n=0,i=(t=!Array.isArray(t)?[t]:t).length;n<i;++n)r=t[n],o=(this.mod.dimension||{})[r]||{},s=this.binding[r],u=Array.isArray(s),!o.multiple!=!u&&(o.multiple||u)&&a.push(this.binding[r]=u?s[0]:s?[s]:[]);return a},setBind:function(t,e){if(this.binding[t]=e,this._normalizeBinding([t]),this._inited)return this.parse(),this.bind(),this.resize(),this.render()},setRaw:function(t,e,n){var i;return null==n&&(n=!1),Array.isArray(t)||(t=(i=t).raw,e=i.binding,n=i.reinit),null!=t&&(this.raw=t),null!=e&&(this.binding=e,this._normalizeBinding()),this.renderLock?(this.renderLock.resolve(),this.renderLock=null):this._inited?(n&&this.mod.init&&this.mod.init.apply(this),this.parse(),this.bind(),this.resize(),this.render()):this._pendingRaw=!0},on:function(t,n){var i=this;return(Array.isArray(t)?t:[t]).map(function(t){var e;return((e=i.evtHandler)[t]||(e[t]=[])).push(n)})},fire:function(t){for(var e,n,i,r,o=[],s=[],u=1,a=arguments.length;u<a;++u)s.push(arguments[u]);for(e=s,u=0,i=(n=this.evtHandler[t]||[]).length;u<i;++u)r=n[u],o.push(r.apply(this,e));return o},filter:function(t,e){var n,i,r,o,s;for(i in null==t&&(t={}),null==e&&(e=!1),n=[],r=this.binding)o=r[i],s=(s=Array.isArray(o)?o:[o]).map(u),n=n.concat(s);for(i in t)o=t[i],n.filter(a).map(l);return e&&this.fire("filter",t),this.mod.filter&&this.mod.filter.apply(this,[t,e]),this.parse(),this.bind(),this.resize(),this.render();function u(t){return{k:i,v:t}}function a(t){return t.k===i}function l(t){return t.v.filter=o}},sample:function(){return this.mod.sample?this.mod.sample.apply(this):{raw:[],binding:{}}}}),"undefined"!=typeof module&&null!==module?module.exports=t:"undefined"!=typeof window&&null!==window&&(window.chart=t)}.call(this);
|
|
1
|
+
!function(){var e,c,f,d,t,n,r,o,s,i,u,a,l,h,p;function m(t,e,f){function d(t,e){return n.call(t,e)}var p={}.toString,n={}.hasOwnProperty,m=!0;return function t(e,n,r){var i,o,s,u,a,l,h,c;if(null==e||null==n)return e===n;if(e.__placeholder__||n.__placeholder__)return!0;if(e===n)return 0!==e||1/e==1/n;i=p.call(e);if(p.call(n)!=i)return!1;switch(i){case"[object String]":return e==String(n);case"[object Number]":return e!=+e?n!=+n:0==e?1/e==1/n:e==+n;case"[object Date]":case"[object Boolean]":return+e==+n;case"[object RegExp]":return e.source==n.source&&e.global==n.global&&e.multiline==n.multiline&&e.ignoreCase==n.ignoreCase}if("object"!=typeof e||"object"!=typeof n)return!1;o=r.length;for(;o--;)if(r[o]==e)return!0;r.push(e);s=0;u=!0;if("[object Array]"==i){if(a=e.length,l=n.length,m){switch(f){case"===":u=a===l;break;case"<==":u=a<=l;break;case"<<=":u=a<l}s=a,m=!1}else u=a===l,s=a;if(u)for(;s--&&(u=s in e==s in n&&t(e[s],n[s],r)););}else{if("constructor"in e!="constructor"in n||e.constructor!=n.constructor)return!1;for(h in e)if(d(e,h)&&(s++,!(u=d(n,h)&&t(e[h],n[h],r))))break;if(u){for(h in c=0,n)d(n,h)&&++c;u=m?"<<="===f?s<c:"<=="===f?s<=c:s===c:(m=!1,s===c)}}r.pop();return u}(t,e,[])}function y(t,e){var n,r={}.hasOwnProperty;for(n in e)r.call(e,n)&&(t[n]=e[n]);return t}e=new function(t){var n=new Intl.NumberFormat(t),t=n.formatToParts(12345.6),e=Array.from({length:10}).map(function(t,e){return n.format(e)}),r=new Map(e.map(function(t,e){return[t,e]}));return this._group=new RegExp("["+t.find(function(t){return m(t.type,"group","===")}).value+"]","g"),this._decimal=new RegExp("["+t.find(function(t){return m(t.type,"decimal","===")}).value+"]"),this._numeral=new RegExp("["+e.join("")+"]","g"),this._index=function(t){return r.get(t)},this}("en-US"),c=function(t){return(t=((t=null==t?"":t)+"").trim().replace(e._group,"").replace(e._decimal,".").replace(e._numeral,e._index))?+t:NaN},f=function(t){return"number"==typeof t?t:!t&&0!==t||isNaN(+t)?0:+t},d=function(t){return!(!/[RIT]/.exec((t=null==t?{}:t).type||"")||/[CN]/.exec(t.type||""))},t=function(e){var t,n,r,i,o,s=[];for(n in e=null==e?{}:e)s.push(n);for(t=s,r=0,o=(i=["name","order"]).length;r<o;++r)if(e[n=i[r]]&&!d(e[n]))return n;return t.filter(function(t){return!d(e[t])})[0]},n=function(){var a,l,h,u=this,c=(this.mod||{}).dimension||{};if(this._subset)return a=t(c),l=this._subset.map(function(e){var t,n,r,i,o={};for(t in n=c)r=n[t],(i=u.binding[t])&&(o[t]=r.multiple?(i.map?i:[i]).map(s):e[i.key],d(r))&&(o[t]=Array.isArray(o[t])?o[t].map(f):f(o[t]));return o;function s(t){return e[t.key]}}),h={},a&&l.map(function(t){return h[t[a]+""]=t}),this.data.map(function(t,e){var n,r,i,o=a?h[t[a]+""]:l[e],s={};for(n in r=c)i=r[n],d(i)&&(s[n]=i.multiple?(t[n]||[]).map(u):o?f(o[n]):0);return t.subset=s;function u(t,e){return o?f((o[n]||[])[e]):0}}),"shrink"===(((this.cfg||{}).common||{}).subset||{}).mode?this.data.map(function(t){var e,n,r,i=[];for(e in n=c)r=n[e],d(r)&&i.push(t[e]=t.subset[e]);return i}):void 0;this.data.map(function(t){var e=t.subset;return delete t.subset,e})},r=function(t){var e,n;if("string"!=typeof t)return null;if(t=t.trim(),e=/^#([0-9a-f]{3})$/i.exec(t)){for(var r,i=[],o=0,s=(r=e[1].split("")).length;o<s;++o)n=r[o],i.push(parseInt(n+n,16));return i}return(e=/^#([0-9a-f]{6})$/i.exec(t))?[0,1,2].map(function(t){return parseInt(e[1].substr(2*t,2),16)}):(e=/^rgba?\(([^)]+)\)$/i.exec(t))&&3===(t=e[1].split(",").slice(0,3).map(function(t){return parseFloat(t.trim())})).length&&t.every(function(t){return!isNaN(t)})?t:null},o=function(t,e,n){var r,i,o,s;for(i in null==n&&(n={}),r={},o=y(y({},e=null==e?{}:e),n||{}))s=o[i],r[i]="function"==typeof s?s.bind(t):s;return r},s=function(t,e,n){for(var r=t;t&&t!==n;)t=t.parentNode;if(t!==n)return null;if(!e)return t;for(t=r;t&&t!==n&&(!t.matches||(t.matches,!t.matches(e)));)t=t.parentNode;return t!==n||n.matches&&n.matches(e)?t:null},(i=function(){return this.running=!1,this.time={now:0,last:0},this.fps(60),this.evtHandler={},this}).prototype=y(Object.create(Object.prototype),{on:function(t,n){var r=this;return(Array.isArray(t)?t:[t]).map(function(t){var e;return((e=r.evtHandler)[t]||(e[t]=[])).push(n)})},fire:function(t){for(var e,n,r,i,o=[],s=[],u=1,a=arguments.length;u<a;++u)s.push(arguments[u]);for(e=s,u=0,r=(n=this.evtHandler[t]||[]).length;u<r;++u)i=n[u],o.push(i.apply(this,e));return o},reset:function(){return this.time={now:0}},setTime:function(t){return this.time.now=t},getTime:function(){return this.time.now},isRunning:function(){return this.running},toggle:function(t){return null!=t&&(this.running=!t),this.running?this.pause():this.run()},pause:function(){return this.running=!1},render:function(){return this.fire("tick",this.time.now)},run:function(t){var e=this;if(null!=t&&this.fps(t),!this.running)return this.running=!0,requestAnimationFrame(function(t){return e.handler(e.time.last=t,!0)})},throttle:function(t){return this.isThrottled=t=null==t?!0:t},fps:function(t){return null==t?this._fps_val:(this._fps_val=.01<t?t:.01,this._fps_delay=1e3/this._fps_val)},handler:function(t,e){var n,r=this;if(null==e&&(e=!1),this.running)return this.time.now=t,n=this.isThrottled?1e3<(n=this._fps_delay)?n:1e3:this._fps_delay,(e||this.time.now-this.time.last>=n)&&(this.time.last=t,this.render()),requestAnimationFrame(function(t){return r.handler(t,!1)})}}),u={list:[],init:function(){var t,n,r=this;return this.inited=!0,t=null==document.hidden&&null==document.msHidden&&null!=document.webkiHidden?["webkitHidden","webkitvisibilitychange"]:["hidden","visibilitychange"],n=t[0],document.addEventListener(t[1],debounce(150,function(){var e=!!document[n];return r.list.map(function(t){return t.throttle(e)})},!1))},add:function(t){return this.inited||this.init(),this.list.push(t)}},a={wm:new WeakMap,ro:new ResizeObserver(function(t){return t.map(function(t){return a.wm.get(t.target)._resize()})}),add:function(t,e){return this.wm.set(t,e),this.ro.observe(t)},delete:function(t){return this.ro.unobserve(t),this.wm.delete(t)}},l=function(t,e,n){return null==e&&(e={}),null==n&&(n={}),function(t,e,n){var r,i;for(r in e)i=e[r],null==t[r]?t[r]=i:"object"!=typeof t[r]||"object"!=typeof i||n[r]&&n[r].type||l(t[r],e[r],n[r]);return t}(t=null==t?{}:t,e=JSON.parse(JSON.stringify(e)),n)},h=function(t){var i=function(t,e){var n,r;for(n in null==e&&(e={}),t.child,t)(r=t[n]).type?r.default&&(e[n]=r.default):i(r,e[n]||(e[n]={}));return e};return i(t)},(p=function(t){var e,n,r,i=this;for(e in this.root="string"==typeof(t=null==t?{}:t).root?document.querySelector(t.root):t.root,this.useSample=null==t.useSample||t.useSample,this.autoSelect=null==t.autoSelect||t.autoSelect,this.forceInit=t.forceInit||!1,this.prepareSvg=null==t.prepareSvg||t.prepareSvg,this.layoutOpt=null==t.layout||t.layout,this.delayRender=t.delayRender||!1,this.dataAccessor=null!=t.dataAccessor?t.dataAccessor:function(t){return t?t.data._raw:null},this.data=[],this.raw=t.raw||null,this.mod=t.mod||{},this.cfg=t.config||{},this.seed=t.seed||Math.random(),this.binding=t.binding||{},this._normalizeBinding(),this.evtHandler={},this._subset=t.subset||null,n=p.scopes){if(r=n[e],null!=this[e])throw new Error("[@plotdb/chart] scope name `"+e+"` is already taken.");this[e]=o(this,r,this.mod[e])}if(null!=this.local)throw new Error("[@plotdb/chart] scope name `local` is already taken.");return this.local=o(this,{},this.mod.local),this.init=proxise.once(function(){return i._init()}),this._resize=null,this._inited=!1,this.autoSelect&&(this.root.addEventListener("click",this._select=function(t){if(t=s(t.target,".data",i.root))return i.fire("select",[{data:i.dataAccessor(t),node:t}])}),this.root.addEventListener("mouseover",this._hover=function(t){if(t=ld$.parent(t.target,".data",i.root))return i.fire("hover",[{data:i.dataAccessor(t),node:t}])})),this}).prototype=y(Object.create(Object.prototype),{_init:function(){var n,t,e,r=this;return"static"===window.getComputedStyle(this.root).position&&(this.root.style.position="relative"),n=this.layoutOpt?"object"!=typeof this.layoutOpt?this.root.querySelector(".pdl-layout"):"string"==typeof this.layoutOpt.root?this.root.querySelector(this.layoutOpt.root):this.layoutOpt.root||null:null,this.prepareSvg&&!(this.svg=this.root.querySelector("svg"))&&(this.svg=document.createElementNS("http://www.w3.org/2000/svg","svg"),(t=this.svg.style).width="100%",t.height="100%",!this.layoutOpt||(n||console.error("[@plotdb/chart] layout enabled yet layout root isn't configured properly. "),e=n.querySelector("[data-type=render]"))||console.warn("[@plotdb/chart] prepareSvg and layout is configured at the same time,\nyet render container for layout is not found. svg is thus appended in the root."),(e||this.root).appendChild(this.svg)),this._aniloop=new i,u.add(this._aniloop),this._aniloop.on("tick",function(){return r.tick()}),Promise.resolve().then(function(){var t;return r.mod.config=l(r.mod.config||{},p.commonConfig),r._defcfg=t=h(r.mod.config),l(r.cfg,t),r.raw&&Array.isArray(r.raw)?{raw:r.raw,binding:r.binding}:r.useSample&&r.mod.sample?(t=r.mod.sample.apply(r)).then?t.then():Promise.resolve(t):void 0}).then(function(t){return r.raw=(t=t||{}).raw,r.binding=t.binding,r}).then(function(){var t,e;return r.raw||(r.raw=[]),r.layoutOpt&&("undefined"==typeof layout||null===layout?console.warn("[@plotdb/chart] layout-opt is set yet @plotdb/layout is not found."):(n||(console.error("[@plotdb/chart] cannot determine root node for @plotdb/layout."),console.error("[@plotdb/chart] config layout properly or disable layout by setting layout to false")),r.layout=new layout("object"==typeof r.layoutOpt?((e=y({},r.layoutOpt)).watchResize=!1,e):{root:n,watchResize:!1}))),t=proxise(function(){return a.add(r.root,r),null}),r._resize=function(){return t.resolve()},e=t(),(r.forceInit||!r.root.offsetParent||"none"===window.getComputedStyle(r.root).display||r.root.offsetWidth&&r.root.offsetHeight)&&t.resolve(),e}).then(function(){return r._resize=function(){}}).then(function(){var t,e=function(){if(r.mod.init)return r.mod.init.apply(r)};return(r.layout?(t=proxise(function(){return Promise.resolve(r.layout.init(e)),null}),r._layout=function(){return t.resolve()},r.layout.on("render",function(){return r._layout()}),t):e)()}).then(function(){r._layout=function(){},Promise.resolve().then(function(){if(r.delayRender&&!r._pendingRaw)return r.renderLock=proxise(function(){}),r.renderLock()}).then(function(){return r._inited=!0,r._resize=function(){return r.resize(),r.render()},r._layout=function(){return r.parse(),r.bind(),r.resize(),r.render()},r.parse(),r.bind(),r.resize(),r.render()})})},parse:function(){var t,l=(t=this.mod).dimension||(t.dimension={}),h=this.binding;if(this.data=this.raw.map(function(e,t){var n,r,i,o,s={};for(n in r=l)i=r[n],(o=h[n])?(s[n]=i.multiple?(o.map?o:[o]).map(u):e[o.key],/[RIT]/.exec(i.type)&&!/[CN]/.exec(i.type)&&(s[n]=Array.isArray(s[n])?s[n].map(a):c(s[n]))):i.multiple&&(s[n]=[]);return s._raw=e,s._idx=t,s;function u(t){return e[t.key]}function a(t){return c(t)}}),n.apply(this),this.mod.parse)return this.mod.parse.apply(this)},bind:function(){if(this.mod.bind)return this.mod.bind.apply(this)},start:function(){if(this._aniloop.run(),this.mod.start)return this.mod.start.apply(this)},stop:function(){if(this._aniloop.pause(),this.mod.stop)return this.mod.stop.apply(this)},resize:function(){if(this._inited)return this.layout&&this.layout.update(!1),this.box=this.root.getBoundingClientRect(),this.mod.resize?this.mod.resize.apply(this):void 0},tick:function(){if(this.mod.tick)return this.mod.tick.apply(this)},render:function(){return this._inited&&this.mod.render?this.mod.render.apply(this):void 0},destroy:function(){var t=this;return Promise.resolve().then(function(){if(t._select&&t.root.removeEventListener("click",t._select),t._hover&&t.root.removeEventListener("mouseover",t._hover),a.delete(t.root),t.layout&&t.layout.destroy(),t.stop(),t.mod.destroy)return t.mod.destroy.apply(t)})},config:function(){var t,e,n;if(!arguments.length)return this.cfg;for(t={},e=0,n=arguments.length;e<n;++e)l(t,arguments[e],this.mod.config);return l(t,this.cfg,this.mod.config),l(t,this._defcfg,this.mod.config),y(this.cfg,t)},_normalizeBinding:function(t){var e,n,r,i,o,s,u,a=[];if(null==t){for(t in e=[],this.mod.dimension||{})e.push(t);t=e}for(n=0,r=(t=Array.isArray(t)?t:[t]).length;n<r;++n)i=t[n],o=(this.mod.dimension||{})[i]||{},s=this.binding[i],u=Array.isArray(s),!o.multiple!=!u&&(o.multiple||u)&&a.push(this.binding[i]=u?s[0]:s?[s]:[]);return a},setBind:function(t,e){if(this.binding[t]=e,this._normalizeBinding([t]),this._inited)return this.parse(),this.bind(),this.resize(),this.render()},setRaw:function(t,e,n){var r;return null==n&&(n=!1),Array.isArray(t)||(t&&"subset"in t&&(this._subset=t.subset||null),t=(r=t).raw,e=r.binding,n=r.reinit),null!=t&&(this.raw=t),null!=e&&(this.binding=e,this._normalizeBinding()),this.renderLock?(this.renderLock.resolve(),this.renderLock=null):this._inited?(n&&this.mod.init&&this.mod.init.apply(this),this.parse(),this.bind(),this.resize(),this.render()):this._pendingRaw=!0},on:function(t,n){var r=this;return(Array.isArray(t)?t:[t]).map(function(t){var e;return((e=r.evtHandler)[t]||(e[t]=[])).push(n)})},fire:function(t){for(var e,n,r,i,o=[],s=[],u=1,a=arguments.length;u<a;++u)s.push(arguments[u]);for(e=s,u=0,r=(n=this.evtHandler[t]||[]).length;u<r;++u)i=n[u],o.push(i.apply(this,e));return o},filter:function(t,e){var n,r,i,o,s;for(r in null==t&&(t={}),null==e&&(e=!1),n=[],i=this.binding)o=i[r],s=(s=Array.isArray(o)?o:[o]).map(u),n=n.concat(s);for(r in t)o=t[r],n.filter(a).map(l);return e&&this.fire("filter",t),this.mod.filter&&this.mod.filter.apply(this,[t,e]),this.parse(),this.bind(),this.resize(),this.render();function u(t){return{k:r,v:t}}function a(t){return t.k===r}function l(t){return t.v.filter=o}},sample:function(){return this.mod.sample?this.mod.sample.apply(this):{raw:[],binding:{}}},filterDims:function(){var t;return(t=(this.mod||{}).filterDims)?t.call(this):(this.mod||{}).filter?["name"]:[]},canFilter:function(){return!!this.filterDims().length}}),p.commonConfig={common:{subset:{mode:{type:"choice",values:["dim","partial","shrink"],default:"dim"},opacity:{type:"number",default:.2,min:0,max:1,step:.05},fade:{type:"number",default:.72,min:0,max:1,step:.01}}}},p.scopes={subset:{set:function(t){if(this._subset=t||null,this._inited)return this.parse(),this.bind(),this.resize(),this.render()},mode:function(){return(((this.cfg||{}).common||{}).subset||{}).mode||"dim"},ratio:function(t,e,n){return t&&t.subset?!(t=(n=null!=n?[(t[e]||[])[n],(t.subset[e]||[])[n]]:[t[e],t.subset[e]])[0])||(e=n[1]/t)<0?0:1<e?1:e:null},color:function(t,e){var n;return(n=r(t))?(n=.3*n[0]+.59*n[1]+.11*n[2],e=null!=e?e:(((this.cfg||{}).common||{}).subset||{}).fade,"rgb("+(n=Math.round(n+(255-n)*(null!=e?e:.72)))+","+n+","+n+")"):t}}},"undefined"!=typeof module&&null!==module?module.exports=p:"undefined"!=typeof window&&null!==window&&(window.chart=p)}.call(this);
|
package/package.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"author":"zbryikt","name":"@plotdb/chart","license":"MIT","description":"plotdb charts","style":"index.min.css","browser":"index.min.js","main":"index.min.js","version":"3.0
|
|
1
|
+
{"author":"zbryikt","name":"@plotdb/chart","license":"MIT","description":"plotdb charts","style":"index.min.css","browser":"index.min.js","main":"index.min.js","version":"3.1.0","homepage":"https://github.com/plotdb/chart","repository":{"type":"git","url":"https://github.com/plotdb/chart"},"engines":{"node":">=10.14.1","npm":">=6.4.1"},"scripts":{"start":"npx server -r web -o true -p 3457"},"devDependencies":{"@loadingio/bootstrap.ext":"^0.0.12","@loadingio/ldquery":"^3.0.6","@loadingio/loading.css":"^3.2.1","@loadingio/vscroll":"^0.0.11","@plotdb/layout":"^0.0.12","@plotdb/pdmap-world":"^0.0.5","@plotdb/semver":"^0.0.3","@plotdb/sheet":"^0.7.0","@xlfont/choose":"^0.0.32","@xlfont/load":"^2.1.5","@zbryikt/template":"^2.4.3","bootstrap":"^4.6.1","bootstrap.native":"^3.0.15","fedep":"^1.9.0","jsdom":"^22.1.0","ldbutton":"^2.0.5","ldfile":"^2.0.1","ldiconfont":"^0.2.8","ldloader":"^3.0.3","ldview":"^1.5.1","livescript":"^1.6.0","pdmaptw":"2.2.1","uglify-js":"^3.13.1","uglifycss":"^0.0.29","zmgr":"^2.2.3"},"frontendDependencies":{"root":"web/static/assets/lib","modules":["bootstrap","bootstrap.native","@loadingio/bootstrap.ext","@loadingio/ldquery","@loadingio/loading.css","@loadingio/ldcolorpicker","@loadingio/debounce.js","@loadingio/vscroll","@plotdb/pdmap-world","@plotdb/block","@plotdb/csscope","@plotdb/rescope","@plotdb/layout","@plotdb/sheet","@plotdb/konfig","@plotdb/semver","@xlfont/choose","@xlfont/load","@zbryikt/voronoijs","d3","d3-array","d3-axis","d3-brush","d3-color","d3-dispatch","d3-drag","d3-ease","d3-force","d3-force-boundary","d3-format","d3-hierarchy","d3-interpolate","d3-path","d3-quadtree","d3-random","d3-scale-chromatic","d3-selection","d3-shape","d3-timer","d3-transition","choosefont.js","pdmaptw","proxise","ldiconfont","ldloader","ldbutton","ldcover","ldcolor","ldfile","ldslider","wrap-svg-text","ldpalettepicker","zmgr","ldview"]},"dependencies":{"@loadingio/debounce.js":"^1.0.1","@loadingio/ldcolorpicker":"^3.0.5","@plotdb/block":"^5.2.2","@plotdb/csscope":"^5.0.3","@plotdb/konfig":"^4.8.12","@plotdb/rescope":"^5.0.9","@zbryikt/voronoijs":"^1.0.0","choosefont.js":"^0.0.1","d3":"^7.9.0","d3-force-boundary":"^0.0.2","ldcolor":"^1.1.3","ldcover":"^3.5.1","ldpalettepicker":"^4.0.4","ldslider":"^3.1.1","proxise":"^1.0.1","wrap-svg-text":"^0.0.7"}}
|
package/utils/axis.min.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
!function(){var l,t;function c(t,e){var n,i={}.hasOwnProperty;for(n in e)i.call(e,n)&&(t[n]=e[n]);return t}l=function(t){return document.createElementNS("http://www.w3.org/2000/svg",t)},(t=function(t){var i,e=this;return this.dir={bottom:0,left:2}[(t=null==t?{}:t).direction||"bottom"],this.name=t.name||"axis",this.layout=t.layout||new layout({root:this.root}),this._ticks=[],this._scale=t.scale||function(t){return t},this._format=chart.utils.format.simple,this._config(t.cfg),this._map={},this._n=i={root:l("g"),layout:this.layout.getNode(this.name),render:this.layout.getGroup(this.name),wrap:null,domain:l("path")},i.render.appendChild(i.root),i.root.appendChild(i.domain),i.label=l("text"),i.label.textContent="",(t=i.label).setAttribute("dominant-baseline","hanging"),t.setAttribute("text-anchor","middle"),i.root.appendChild(i.label),i.sideNote=[0,1].map(function(t){var e,n=l("text");return n.textContent="",(e=n).setAttribute("dominant-baseline","hanging"),e.setAttribute("text-anchor",["start","end"][t]),i.root.appendChild(n)}),this.wrapper(),(t=this.layout).on("update",function(){return e.update()}),t.on("render",function(){return e.render()}),this}).prototype=c(Object.create(Object.prototype),{wrapper:function(){var t,e=this._n;return e.wrap&&e.wrap.parentNode&&e.wrap.parentNode.removeChild(e.wrap),e.wrap=document.createElement("div"),c(((t=e.wrap.style).visibility="hidden",t.position="absolute",t.top=0,t.left=0,t.pointerEvents="none",t.userSelect="none",t.zIndex=0,t.wordBreak="break-all",t.lineHeight=".95em",t),this.dir<2&&null!=this.cfg.textWidth?{whiteSpace:"wrap",width:(1<(t=this.cfg.textWidth)?t:1)+"em"}:{whiteSpace:"pre",width:"4em"}),e.layout.appendChild(e.wrap)},_config:function(e){var t,n=this;return null==e&&(e={}),this.cfg={tick:{inner:8},baseline:{},label:{padding:1},caption:{padding:1},enabled:e.enabled,sideNoteStart:{padding:1},sideNoteEnd:{padding:1}},["tick","baseline","label","caption","sideNoteStart","sideNoteEnd"].map(function(t){return c(n.cfg[t],e[t]||{})}),(t=this.cfg.label).font||(t.font={}),(t=this.cfg.caption).font||(t.font={}),(t=this.cfg.sideNoteStart).font||(t.font={}),(t=this.cfg.sideNoteEnd).font||(t.font={}),this.format(this.cfg.label.format)},config:function(t){return null==t?this.cfg:(this._config(t),this.wrapper())},format:function(t){return null==t?this._format:this._format="string"==typeof t?chart.utils.format.from(t):t||chart.utils.format.simple},scale:function(t){return null!=t?this._scale=t:this._scale},caption:function(t){return arguments.length&&(this._caption=t),!this.cfg.enabled||null!=this.cfg.caption.show&&!this.cfg.caption.show?this._n.label.textContent="":this._n.label.textContent=this.cfg.caption.text||this._caption||""},update:function(){},ticks:function(n){var t,e,i,a=this,o={},r=this._n.layout.getBoundingClientRect()[this.dir<2?"width":"height"],r=Math.round(r/25),s=1<(t=Math.round(n.length/(1<r?r:1)))?t:1;for(e in this._ticks=n.filter(function(t,e){return!(e%s)||e===n.length-1}).map(function(t){var e,n;return o[(t="object"!=typeof t?{v:t}:t).v]=c((e=a._map)[n=t.v]||(e[n]={}),t)}),t=this._map)i=t[e],o[e]||i.n.g.parentNode.removeChild(i.n.g);return this._map=o,this._ticks.filter(function(t){return!t.n}).map(function(t){if(t.n={g:l("g"),p:l("path"),t:l("g")},t.n.g.appendChild(t.n.p),t.n.g.appendChild(t.n.t),a._n.root.appendChild(t.n.g),isNaN(+t.v))return t.t=t.v})},render:function(){var i,t,a,e,n,o,r,s=this,l=this._n,c=this.dir<2,d=l.wrap;
|
|
1
|
+
!function(){var l,t;function c(t,e){var n,i={}.hasOwnProperty;for(n in e)i.call(e,n)&&(t[n]=e[n]);return t}l=function(t){return document.createElementNS("http://www.w3.org/2000/svg",t)},(t=function(t){var i,e=this;return this.dir={bottom:0,left:2}[(t=null==t?{}:t).direction||"bottom"],this.name=t.name||"axis",this.layout=t.layout||new layout({root:this.root}),this._ticks=[],this._scale=t.scale||function(t){return t},this._format=chart.utils.format.simple,this._config(t.cfg),this._map={},this._n=i={root:l("g"),layout:this.layout.getNode(this.name),render:this.layout.getGroup(this.name),wrap:null,domain:l("path")},i.render.appendChild(i.root),i.root.appendChild(i.domain),i.label=l("text"),i.label.textContent="",(t=i.label).setAttribute("dominant-baseline","hanging"),t.setAttribute("text-anchor","middle"),i.root.appendChild(i.label),i.sideNote=[0,1].map(function(t){var e,n=l("text");return n.textContent="",(e=n).setAttribute("dominant-baseline","hanging"),e.setAttribute("text-anchor",["start","end"][t]),i.root.appendChild(n)}),this.wrapper(),(t=this.layout).on("update",function(){return e.update()}),t.on("render",function(){return e.render()}),this}).prototype=c(Object.create(Object.prototype),{wrapper:function(){var t,e=this._n;return e.wrap&&e.wrap.parentNode&&e.wrap.parentNode.removeChild(e.wrap),e.wrap=document.createElement("div"),c(((t=e.wrap.style).visibility="hidden",t.position="absolute",t.top=0,t.left=0,t.pointerEvents="none",t.userSelect="none",t.zIndex=0,t.wordBreak="break-all",t.lineHeight=".95em",t),this.dir<2&&null!=this.cfg.textWidth?{whiteSpace:"wrap",width:(1<(t=this.cfg.textWidth)?t:1)+"em"}:{whiteSpace:"pre",width:"4em"}),e.layout.appendChild(e.wrap)},_config:function(e){var t,n=this;return null==e&&(e={}),this.cfg={tick:{inner:8},baseline:{},label:{padding:1},caption:{padding:1},enabled:e.enabled,sideNoteStart:{padding:1},sideNoteEnd:{padding:1}},["tick","baseline","label","caption","sideNoteStart","sideNoteEnd"].map(function(t){return c(n.cfg[t],e[t]||{})}),(t=this.cfg.label).font||(t.font={}),(t=this.cfg.caption).font||(t.font={}),(t=this.cfg.sideNoteStart).font||(t.font={}),(t=this.cfg.sideNoteEnd).font||(t.font={}),this.format(this.cfg.label.format)},config:function(t){return null==t?this.cfg:(this._config(t),this.wrapper())},format:function(t){return null==t?this._format:this._format="string"==typeof t?chart.utils.format.from(t):t||chart.utils.format.simple},scale:function(t){return null!=t?this._scale=t:this._scale},caption:function(t){return arguments.length&&(this._caption=t),!this.cfg.enabled||null!=this.cfg.caption.show&&!this.cfg.caption.show?this._n.label.textContent="":this._n.label.textContent=this.cfg.caption.text||this._caption||""},update:function(){},ticks:function(n){var t,e,i,a=this,o={},r=this._n.layout.getBoundingClientRect()[this.dir<2?"width":"height"],r=Math.round(r/25),s=1<(t=Math.round(n.length/(1<r?r:1)))?t:1;for(e in this._ticks=n.filter(function(t,e){return!(e%s)||e===n.length-1}).map(function(t){var e,n;return o[(t="object"!=typeof t?{v:t}:t).v]=c((e=a._map)[n=t.v]||(e[n]={}),t)}),t=this._map)i=t[e],o[e]||i.n.g.parentNode.removeChild(i.n.g);return this._map=o,this._ticks.filter(function(t){return!t.n}).map(function(t){if(t.n={g:l("g"),p:l("path"),t:l("g")},t.n.g.appendChild(t.n.p),t.n.g.appendChild(t.n.t),a._n.root.appendChild(t.n.g),isNaN(+t.v))return t.t=t.v})},render:function(){var i,t,a,e,n,o,r,s=this,l=this._n,c=this.dir<2,d=l.wrap;if(d.style.fontSize=this.cfg.label.font.size?this.cfg.label.font.size+""||"":void 0,d.setAttribute("class",(this.cfg.label.font.family||{}).className||""),i=this._ticks,null==this.cfg.enabled||this.cfg.enabled)return c?((t=l.layout.style).height="",t.paddingTop="",t.paddingBottom=""):((t=l.layout.style).width="",t.paddingLeft="",t.paddingRight=""),l.domain.style.display="",i.map(function(t){return t.n.g.style.display=""}),a=getComputedStyle(d).fontSize,e=l.layout.getBoundingClientRect(),(t=l.domain.style).strokeWidth=1,t.stroke="currentColor",t.fill="none",i.map(function(t,e){var n,e=e?e===i.length-1?2:1:0;return t._c=null!=t.c?t.c:s._scale(t.v)+(s._scale.bandwidth?s._scale.bandwidth()/2:0),t._t=null!=t.t?t.t:s._format(t.v),(n=t.n.p.style).strokeWidth=1,n.stroke="currentColor",n.fill="none",d.textContent=t._t,d.style.textAlign=c?["left","center","right"][e]:["right","left"][s.dir-2],t.n.tt=wrapSvgText({node:d}),t.n.t.style.fontSize=a,t.n.t.style.fill=s.cfg.label.color,t.n.t.textContent="",t.n.t.appendChild(t.n.tt),t.n.t.setAttribute("class",(s.cfg.label.font||{}).className||"")}),i.sort(function(t,e){return t._c-e._c}),l.domain.style.stroke=this.cfg.baseline.show?this.cfg.baseline.color:"none",n=(this.cfg.caption.position||0)%3,o=Math.floor((this.cfg.caption.position||0)/3),(r=l.label).setAttribute("text-anchor",["start","middle","end"][n]),r.setAttribute("dominant-baseline",["baseline","hanging"][o]),l.sideNote.map(function(t,e){e=(s.cfg[["sideNoteStart","sideNoteEnd"][e]]||{}).position||0;return t.setAttribute("dominant-baseline",["baseline","hanging"][e])}),c?(l.domain.setAttribute("d","M0 0L"+e.width+" 0Z"),l.label.setAttribute("x",e.width/2),l.label.setAttribute("x",[2,e.width/2,e.width-2][n])):(l.domain.setAttribute("d","M0 0L0 "+e.height+"Z"),r=[2,e.height/2,e.height-2][n],l.label.setAttribute("transform","translate(0,"+r+") rotate(90)")),i.map(function(t){return t.box=t.n.t.getBBox()}),this.adjust();c?((t=l.layout.style).height="0px",t.paddingTop="0",t.paddingBottom="0"):((t=l.layout.style).width="0px",t.paddingLeft="0",t.paddingRight="0"),l.domain.style.display="none",i.map(function(t){return t.n.g.style.display="none"})},adjust:function(){var t,e,n,i,a,o,r,s,l,c,d,h,u=this,f=this._ticks,p=this.dir<2,g=function(t,e,n){var i,a,o,r,s,l,c,d;if(!n.checked[t])return n.checked[t]=!0,i=f[t],s=t?t===f.length-1?2:1:0,a=[i._c,i._t][0],r={x:-(o=i.box).x,y:-o.y},s=!u._scale.bandwidth&&(null!=u.cfg.tick.boundaryOffset?!!u.cfg.tick.boundaryOffset:u.dir<2)?s/2:.5,p?r.x-=o.width*s:r.y-=o.height*s,i.n.tt.setAttribute("transform","translate("+r.x+","+r.y+")"),(o={size:o[p?"width":"height"],sizeAlt:o[p?"height":"width"],lv:e,tick:i,idx:t}).coord=a-o.size*s,p?(i.n.g.setAttribute("transform","translate("+a+",0)"),i.n.p.setAttribute("d","M0 0L0 "+u.cfg.tick.inner),i.n.t.setAttribute("transform","translate(0,"+(u.cfg.tick.inner+u.cfg.label.padding)+")")):(i.n.g.setAttribute("transform","translate(0,"+a+")"),i.n.p.setAttribute("d","M0 0L-"+u.cfg.tick.inner+" 0"),i.n.t.setAttribute("transform","translate("+(-u.cfg.tick.inner-o.sizeAlt-1-u.cfg.label.padding)+",0)")),c=(r=[(l=(r=[o.coord,o.coord+o.size])[0])-2,r[1]+2])[0],d=r[1],e=n.picked.filter(function(t){var t=[t.coord,t.coord+t.size],e=t[0];return(t=[e-2,t[1]+2])[0]<l&&l<t[1]||c<e&&e<d}).length,i.n.t.style.opacity=e?0:1,i.n.p.style.stroke=u.cfg.tick.color||"",n.picked.push(o),!e},b=5;for(null==b&&(b=1),t=[{checked:{},picked:[],node:u._n.wrap},[]],e=t[0],n=t[1],e.fontSize=getComputedStyle(e.node).fontSize,f.map(function(t){return t.n.t.style.opacity=0}),f.length&&(n.push([0,f.length-1,0]),[0,f.length-1].map(function(t){return g(t,0,e)}));n.length;)i=(t=n.splice(0,1)[0])[0],a=t[1],b<=(o=t[2])||(r=Math.floor((i+a)/2),g(r,o,e),i+1<r&&n.push([i,r,o+1]),r+1<a&&n.push([r,a,o+1]));return u._n.label.style.fill=u.cfg.caption.color,u._n.label.style.fontSize=u.cfg.caption.font.size?u.cfg.caption.font.size+""||"":void 0,u._n.label.setAttribute("class",(u.cfg.caption.font.family||{}).className||""),u.caption(),u._n.sideNote.map(function(t,e){var e=u.cfg[["sideNoteStart","sideNoteEnd"][e]]||{},n=e.font||{};return t.textContent=e.show&&e.text||"",t.style.fill=e.color,t.style.fontSize=n.size?n.size+""||"":void 0,t.setAttribute("class",(n.family||{}).className||"")}),s=(u.cfg.caption.position||0)%3,l=Math.floor((u.cfg.caption.position||0)/3),h=Math.max.apply(Math,[0].concat(e.picked.map(function(t){return t.sizeAlt}))),c=u.cfg.tick.inner+u.cfg.label.padding+u.cfg.caption.padding+h,u.dir<2?(u._n.label.setAttribute("y",[-2,c][l]),u._n.layout.style.height=c+u._n.label.getBoundingClientRect().height+"px",d=u._n.layout.getBoundingClientRect(),u._n.sideNote.map(function(t,e){var n=u.cfg[["sideNoteStart","sideNoteEnd"][e]]||{},i=n.position||0;return t.setAttribute("x",[2,d.width-2][e]),t.setAttribute("y",[-2-n.padding,c+n.padding][i])})):(u._n.label.setAttribute("x",0),u._n.label.setAttribute("y",0),u._n.layout.style.width=c+u._n.label.getBoundingClientRect().width+"px",h=[2,(d=u._n.layout.getBoundingClientRect()).height/2,d.height-2][s],u._n.label.setAttribute("transform","translate("+[2,-c-2][l]+","+h+") rotate(90)"),u._n.root.setAttribute("transform","translate("+(d.width-1)+",0)"),u._n.sideNote.map(function(t,e){var n=u.cfg[["sideNoteStart","sideNoteEnd"][e]]||{},i=n.position||0,e=[2,d.height-2][e];return t.setAttribute("transform","translate("+[2+n.padding,-c-2-n.padding][i]+","+e+") rotate(90)")}))}}),"undefined"!=typeof chart&&null!==chart&&((chart.utils||(chart.utils={})).axis=t)}.call(this);
|
package/utils/config.js
CHANGED
|
@@ -106,6 +106,24 @@
|
|
|
106
106
|
values: ['label', 'value', 'none'],
|
|
107
107
|
'default': 'value'
|
|
108
108
|
}
|
|
109
|
+
},
|
|
110
|
+
subset: {
|
|
111
|
+
mode: {
|
|
112
|
+
type: 'choice',
|
|
113
|
+
values: ['shrink', 'dim', 'partial'],
|
|
114
|
+
'default': 'shrink'
|
|
115
|
+
},
|
|
116
|
+
opacity: {
|
|
117
|
+
type: 'number',
|
|
118
|
+
'default': 0.2,
|
|
119
|
+
min: 0,
|
|
120
|
+
max: 1,
|
|
121
|
+
step: 0.05
|
|
122
|
+
}
|
|
123
|
+
},
|
|
124
|
+
crossfilter: {
|
|
125
|
+
type: 'boolean',
|
|
126
|
+
'default': false
|
|
109
127
|
}
|
|
110
128
|
},
|
|
111
129
|
axis: {
|
package/utils/config.min.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
!function(){var e;e={from:function(e){var
|
|
1
|
+
!function(){var e;e={from:function(e){var i=this,p=function(e,t){var a,o;if(t.preset){var l,n=e,r=JSON.parse(JSON.stringify(i.preset[t.preset])),u={}.hasOwnProperty;for(l in r)u.call(r,l)&&(n[l]=r[l])}for(a in t)o=t[a],"preset"!==a&&("string"==typeof o?e[a]=JSON.parse(JSON.stringify(i.preset[o]))||{}:p(e[a]||(e[a]={}),o));return e};return p({},e)},preset:{default:{margin:{type:"number"},font:e={family:{type:"font"},size:{type:"quantity",default:"1em",units:[{name:"em",max:10,step:.01,default:1},{name:"px",max:256,step:1,default:16}]}},color:{type:"color",default:"currentColor"},palette:{type:"palette"},background:{type:"color",default:"transparent"}},font:e,tip:{enabled:{type:"boolean",default:!0},format:{type:"format",default:".3s"}},label:{format:{type:"format",default:".3s"}},legend:{selectable:{type:"boolean",default:!0},enabled:{type:"boolean",default:!0},position:{type:"choice",values:["bottom","right"],default:"right"},sort:{direction:{type:"choice",values:["asc","desc"],default:"desc"},mode:{type:"choice",values:["label","value","none"],default:"value"}},subset:{mode:{type:"choice",values:["shrink","dim","partial"],default:"shrink"},opacity:{type:"number",default:.2,min:0,max:1,step:.05}},crossfilter:{type:"boolean",default:!1}},axis:{enabled:{type:"boolean",default:!0},center:{type:"boolean",default:!1},tick:{inner:{type:"number",name:"Inner Tick Size",default:8,min:0,max:40,step:.1},color:{type:"color",default:"currentColor"},count:{type:"number",default:4,min:1,max:40},boundaryOffset:{type:"boolean",default:!0}},baseline:{show:{type:"boolean",default:!0},color:{type:"color",default:"currentColor"}},label:{color:{type:"color",default:"currentColor"},format:{type:"format",default:".3s"},direction:{type:"choice",default:"horizontal",values:["horizontal","vertical"]},padding:{type:"number",default:1,min:0,max:100,step:.5},font:e},caption:{color:{type:"color",default:"currentColor"},text:{type:"text",default:""},show:{type:"boolean",default:!0},padding:{type:"number",default:1,min:0,max:100,step:.5},position:{type:"choice",default:4,values:[{name:"in / start",value:0},{name:"in / middle",value:1},{name:"in / end",value:2},{name:"out / start",value:3},{name:"out / middle",value:4},{name:"out / end",value:5}]},font:e},sideNoteStart:{show:{type:"boolean",default:!1},text:{type:"text",default:""},position:{type:"choice",default:0,values:[{name:"in",value:0},{name:"out",value:1}]},font:e,color:{type:"color",default:"currentColor"},padding:{type:"number",default:1,min:0,max:100,step:.5}},sideNoteEnd:{show:{type:"boolean",default:!1},text:{type:"text",default:""},position:{type:"choice",default:0,values:[{name:"in",value:0},{name:"out",value:1}]},font:e,color:{type:"color",default:"currentColor"},padding:{type:"number",default:1,min:0,max:100,step:.5}}}}},"undefined"!=typeof chart&&null!==chart&&((chart.utils||(chart.utils={})).config=e)}.call(this);
|
package/utils/data.min.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
!function(){var h={number:function(t){return(t=(t=null==t?{}:t).data.filter(function(t){return!(!t||""===(t+"").trim())})).filter(function(t){return!isNaN(parseFloat(t))}).length/t.length},serial:function(t){var n,r,e,u,i,
|
|
1
|
+
!function(){var h={number:function(t){return(t=(t=null==t?{}:t).data.filter(function(t){return!(!t||""===(t+"").trim())})).filter(function(t){return!isNaN(parseFloat(t))}).length/t.length},serial:function(t){var n,r,e,u,a,i,o;for((n=[].concat((t=null==t?{}:t).data)).sort(function(t,n){return n-t}),r={},e=1,u=n.length;e<u;++e)a=e,isNaN(n[a])||isNaN(n[a-1])?r[n[a]>n[a-1]?n[a]+":"+n[a-1]:n[a-1]+":"+n[a]]=!0:i=n[a]-n[a-1],r[i]=!0;return 1/((()=>{var t=[];for(o in r)t.push(o);return t})().filter(function(t){return"0"!==t}).length||2)},text:function(t){return 1-this.number(t=null==t?{}:t)},category:function(t){var n;return null==t&&(t={}),n=(n=0<(n=1-(0<(n=Array.from(new Set(t.data)).length-2)?n:0)/(n=t.data.length)-1/n)?n:0)<1?n:1,this.number(t)&&(n*=.9),n},parse:function(t){var n,r;return Array.isArray(t)?(n=t.slice(0,1)[0],r=(r=t.slice(1)).map(function(r,t){var e={};return n.map(function(t,n){return e[t]=r[n]}),e}),{head:n,body:r}):t},autotype:function(t){var n,r,e,u,a,i,o,l,s=[];for(r in(t=null==t?[]:t)[0]||{})s.push(r);for(e=[],u=0,a=(n=s).length;u<a;++u)i=n[u],l=t.map(f),o={key:i,types:{R:h.number({data:l}),O:h.serial({data:l}),N:h.text({data:l}),C:h.category({data:l})}},(l=["R","O","N","C"].map(p)).sort(c),o.type=l[0][0],e.push(o);return e;function f(t){return t[i]}function p(t){return[t,o.types[t]]}function c(t,n){return n[1]-t[1]}},autobind:function(t,r){var n,e,u,a,i,o,l,s,f,p,c,h,y,d,v;for(null==r&&(r={}),n=this.autotype(t=null==t?[]:t),(e=(()=>{var t,n=[];for(u in t=r)a=t[u],n.push({k:u,v:a});return n})().filter(function(t){return!t.v.passive})).sort(function(t,n){var r=(t.v.priority||100)-(n.v.priority||100);return 0!=r?r:(r=[t.v.type||"R",n.v.type||"R"].map(function(e){return Math.min.apply(Math,(()=>{for(var t=[],n=0,r=e.length;n<r;++n)t.push(n);return t})().map(function(t){return"CONR".indexOf(e[t])}))}))[0]-r[1]}),i=0,o=e.length;i<o;++i)for((l=e[i]).bind=null,f=0,p=(s=l.v.type||"RNOC").length;f<p;++f)for(c=s[f],n.sort(g),h=0,y=n.length;h<y;++h)if(!((d=n[h]).types[c]<.5||d.used||"C"===c&&.5<d.types.R)){l.bind=l.v.multiple?[d]:d,d.used=!0;break}for(i=0,o=e.length;i<o;++i)if((l=e[i]).v.multiple)for(f=0,p=(s=l.v.type||"RNOC").length;f<p;++f)for(c=s[f],n.sort(m),h=0,y=n.length;h<y;++h)(d=n[h]).types[c]<.5||d.used||"C"===c&&.5<d.types.R||(l.bind.push(d),d.used=!0);for(v={},i=0,o=e.length;i<o;++i)(l=e[i]).bind&&(v[l.k]=l.bind,(Array.isArray(l.bind)?l.bind:[l.bind]).map(b));return v;function g(t,n){var r=(n.types[c]||0)-(t.types[c]||0);return n.types[c]===t.types[c]&&"R"===c?(t.types.O||0)-(n.types.O||0):r}function m(t,n){var r=(n[c]||0)-(t[c]||0);return n[c]===t[c]&&"R"===c?(t.O||0)-(n.O||0):r}function b(t){var n=t.used;return delete t.used,n}}};"undefined"!=typeof chart&&null!==chart&&((chart.utils||(chart.utils={})).data=h)}.call(this);
|
package/utils/legend.js
CHANGED
|
@@ -302,6 +302,50 @@
|
|
|
302
302
|
return !!this._range.filter(function(it){
|
|
303
303
|
return key >= it.ext[0] && key < it.ext[1] && this$._picked[it.key];
|
|
304
304
|
}).length;
|
|
305
|
+
},
|
|
306
|
+
mode: function(){
|
|
307
|
+
if (((this.cfg.subset || {}).mode || 'shrink') === 'shrink') {
|
|
308
|
+
return 'shrink';
|
|
309
|
+
} else {
|
|
310
|
+
return 'dim';
|
|
311
|
+
}
|
|
312
|
+
},
|
|
313
|
+
opacity: function(){
|
|
314
|
+
var ref$;
|
|
315
|
+
return (ref$ = (this.cfg.subset || {}).opacity) != null ? ref$ : 0.2;
|
|
316
|
+
},
|
|
317
|
+
isVisible: function(key){
|
|
318
|
+
return this.mode() !== 'shrink' || this.isSelected(key);
|
|
319
|
+
},
|
|
320
|
+
select: function(keys){
|
|
321
|
+
var hash;
|
|
322
|
+
if (!(keys != null)) {
|
|
323
|
+
this._picked = Object.fromEntries(this._data.map(function(d){
|
|
324
|
+
return [d.key, true];
|
|
325
|
+
}));
|
|
326
|
+
} else {
|
|
327
|
+
hash = Object.fromEntries(keys.map(function(it){
|
|
328
|
+
return [it, true];
|
|
329
|
+
}));
|
|
330
|
+
this._picked = Object.fromEntries(this._data.map(function(d){
|
|
331
|
+
return [d.key, !!hash[d.key]];
|
|
332
|
+
}));
|
|
333
|
+
}
|
|
334
|
+
this.view.render.render('legend');
|
|
335
|
+
return this;
|
|
336
|
+
},
|
|
337
|
+
selected: function(){
|
|
338
|
+
var ks, this$ = this;
|
|
339
|
+
ks = this._data.filter(function(d){
|
|
340
|
+
return !!this$._picked[d.key];
|
|
341
|
+
}).map(function(d){
|
|
342
|
+
return d.key;
|
|
343
|
+
});
|
|
344
|
+
if (ks.length === this._data.length) {
|
|
345
|
+
return null;
|
|
346
|
+
} else {
|
|
347
|
+
return ks;
|
|
348
|
+
}
|
|
305
349
|
}
|
|
306
350
|
});
|
|
307
351
|
if (typeof chart != 'undefined' && chart !== null) {
|
package/utils/legend.min.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
!function(){var
|
|
1
|
+
!function(){var u,t;u="http://www.w3.org/2000/svg",(t=function(a){var t,e,n,i,l=this;return null==a&&(a={}),this._data=a.data||[],this.name=a.name||"legend",this.cfg=a.cfg||{},this.root="string"==typeof a.root?document.querySelector(a.root):a.root,this.dir=a.direction||"vertical",this.evtHandler={},this._picked=Object.fromEntries(this._data.map(function(t){return[t.key,!0]})),this.layout=a.layout||new layout({root:this.root}),(e=this.layout).on("update",function(){return l.update()}),e.on("render",function(){return l.render()}),this.id=Math.random().toString(36).substring(2),e=this.layout.getNode(this.name),t=this.layout.getGroup(this.name),e.querySelector("[ld-each=legend]")||(e.innerHTML='<div class="pdlg '+this.dir+'">\n <div ld-each="legend">\n <div class="pdl-cell" ld="shape" data-only></div>\n <div class="pdl-cell" ld="text" data-only></div>\n </div>\n</div>'),t.querySelector("[ld-each=legend]")||(e=document.createElementNS(u,"g"),n=document.createElementNS(u,"g"),i=document.createElementNS(u,"g"),e.classList.add("pdlg-g"),e.setAttribute("ld-each","legend"),n.setAttribute("ld","shape"),i.setAttribute("ld","text"),e.appendChild(n),e.appendChild(i),t.appendChild(e)),this._func=[{key:"all",type:"func",text:"全選"},{key:"none",type:"func",text:"全不選"}],this.view={layout:new ldview({root:this.layout.getNode(this.name),initRender:!1,handler:{legend:{list:function(){var n,t=l._data.map(function(t){return t}),i=l.cfg.sort||{};return"none"!==i.mode&&(n="desc"===i.direction?1:-1,t.sort(function(t,e){return"value"===i.mode?n*(e.value-t.value):n*(t.text<e.text?1:t.text>e.text?-1:0)})),t.concat(l.cfg.selectable?l._func:[])},key:function(t){return t.key},view:{handler:{shape:function(t){return t.node.setAttribute("data-name",l._name(t.ctx,"shape"))},text:function(t){var e=t.node,t=t.ctx;return e.setAttribute("data-name",l._name(t,"text")),e.innerText=t.text}}}}}}),render:new ldview({root:this.layout.getGroup(this.name),initRender:!1,handler:{legend:{list:function(){return l._data.concat(l.cfg.selectable?l._func:[])},key:function(t){return t.key},view:{action:{click:{"@":function(t){t.node;var e,n=t.ctx;if(l.cfg.selectable){if("func"===n.type)for(e in l._picked)l._picked[e]="all"===n.key;else l._picked[n.key]=!l._picked[n.key];return l.view.render.render("legend"),l.fire("select",l._picked)}}}},handler:{"@":function(t){var e=t.node,t=t.ctx;return e.style.opacity=!l.cfg.selectable||"func"===t.type||l._picked[t.key]?1:.3},shape:function(t){var e,n,i,r=t.node,t=t.ctx;if("func"!==t.type)return r.querySelector("circle")||r.appendChild(document.createElementNS(u,"circle")),e=r.querySelector("circle"),n=l.layout.getBox(l._name(t,"shape")),i=l.layout.getBox(l.name),e.setAttribute("cx",".5em"),e.setAttribute("cy",".5em"),e.setAttribute("r",".5em"),e.setAttribute("transform","translate("+(n.x-i.x)+", "+(n.y-i.y)+")"),"function"==typeof a.shape?a.shape.call(e,t):void 0;r.style.display="none"},text:function(t){var e=t.node,t=t.ctx,n=l.layout.getNode(l._name(t,"text")),t=l.layout.getBox(l._name(t,"text")),i=l.layout.getBox(l.name);return e.setAttribute("transform","translate("+(t.x-i.x)+", "+(t.y-i.y)+")"),e.textContent="",t=wrapSvgText({node:n,useRange:!0}),e.appendChild(t)}}}}}})},this.update(),this}).prototype=((t,e)=>{var n,i={}.hasOwnProperty;for(n in e)i.call(e,n)&&(t[n]=e[n]);return t})(Object.create(Object.prototype),{_name:function(t,e){return"pdlg-"+(e=null==e?"s":e)+"-"+this.id+"-"+(t.type||"")+"-"+t.key},enabled:function(){return this._data&&this._data.length&&(!(null!=this.cfg.enabled)||this.cfg.enabled)},update:function(){var t=this.enabled()?"":"0px",e=this.layout.getNode(this.name).style;return e.width=t,e.height=t,e.padding=t,e.margin=t,(e=this.layout.getNode(this.name).querySelector(".pdlg"))&&("vertical"===this.dir?(e.style.height="fit-content",e.style.height=getComputedStyle(e.parentNode).height):e.style.height=""),this.view.layout.render()},render:function(){var t=this.enabled();if(this.layout.getGroup(this.name).style.display=t?"":"none",t)return this.view.render.render()},config:function(t){var e,n=this;return null==t?this.cfg:(this.cfg.selectable!==t.selectable&&(this._picked=null,this._updatePicked()),this.cfg=t,this.dir="bottom"===this.cfg.position?"horizontal":"vertical",e=this.layout.getNode(this.name).querySelector(".pdlg"),["horizontal","vertical"].map(function(t){return e.classList.toggle(t,n.dir===t)}))},_updatePicked:function(){var e=this;return null==this._picked&&(this._picked=Object.fromEntries(this._data.map(function(t){return[t.key,!0]}))),this._data.map(function(t){if(null==e._picked[t.key])return e._picked[t.key]=!0})},data:function(t){var n;return arguments.length?(n={},t.map(function(t,e){return n[t.key]=e}),this._data=t.filter(function(t,e){return n[t.key]===e}),this._range=this._data.filter(function(t){return t.ext}),this._updatePicked(),this.update(),this.layout.update(!1),this.view.render.render()):this._data},on:function(t,n){var i=this;return(Array.isArray(t)?t:[t]).map(function(t){var e;return((e=i.evtHandler)[t]||(e[t]=[])).push(n)})},fire:function(t){for(var e,n,i,r,a=[],l=[],u=1,s=arguments.length;u<s;++u)l.push(arguments[u]);for(e=l,u=0,i=(n=this.evtHandler[t]||[]).length;u<i;++u)r=n[u],a.push(r.apply(this,e));return a},isSelected:function(e){var n=this;return this._range&&this._range.length?!!this._range.filter(function(t){return e>=t.ext[0]&&e<t.ext[1]&&n._picked[t.key]}).length:!!this._picked[e]},mode:function(){return"shrink"===((this.cfg.subset||{}).mode||"shrink")?"shrink":"dim"},opacity:function(){var t;return null!=(t=(this.cfg.subset||{}).opacity)?t:.2},isVisible:function(t){return"shrink"!==this.mode()||this.isSelected(t)},select:function(t){var e;return null==t?this._picked=Object.fromEntries(this._data.map(function(t){return[t.key,!0]})):(e=Object.fromEntries(t.map(function(t){return[t,!0]})),this._picked=Object.fromEntries(this._data.map(function(t){return[t.key,!!e[t.key]]}))),this.view.render.render("legend"),this},selected:function(){var e=this,t=this._data.filter(function(t){return!!e._picked[t.key]}).map(function(t){return t.key});return t.length===this._data.length?null:t}}),"undefined"!=typeof chart&&null!==chart&&((chart.utils||(chart.utils={})).legend=t)}.call(this);
|
package/utils/tick.min.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
!function(){var t=function(t){var e,n,
|
|
1
|
+
!function(){var t=function(t){var e,r,n,u,o,a,f,h,i,l,p,c,s,M,x,y,m,k,g,v,d,w,N,b=(t=null==t?{}:t).extent||[0,1],F=t.len||3,L=b=(b=b.map(function(t){return isNaN(t)?0:t}))[0]>b[1]?[b[1],b[0]]:b;if(null!=t.exp){if(e=[10,15,20,25,30,40,50,75,100],r=[],n=[],u=Math.pow(10,t.exp),null==t.pretty||t.pretty){for(b=[[b[0],"floor"],[b[1],"ceil"]].map(function(t){var r=t[0],n=t[1],t=e.map(function(t){return[t,Math.abs(r-Math[n](r/t)*t)]});return t.sort(function(t,r){return t[1]-r[1]}),t[0][0]*Math[n](r/t[0][0])}),o=b[1]-b[0],a=1;a<=F;++a){for(f=a,h=+(o*(Math.pow(f/F,u)-Math.pow((f-1)/F,u))).toFixed(2),i=Math.floor(Math.log(h)/Math.LN10),l=0,p=e.length;l<p&&!((c=e[l]*Math.pow(10,i-1).toFixed(2))>=h);++l);n.push(c)}for(o=n.reduce(function(t,r){return t+r},0),M=(b=[[(b=[b[0],(s=b[0]+o)>(x=b[1])?s:x])[0],"floor"],[b[1],"ceil"]].map(function(t){var r=t[0],n=t[1],t=e.map(function(t){return[t,Math.abs(r-Math[n](r/t)*t)]});return t.sort(function(t,r){return t[1]-r[1]}),t[0][0]*Math[n](r/t[0][0])}))[0],a=0;a<F&&(f=a,r.push(M),!((M+=n[f])>=L[1]));++a);r.push(M)}else o=b[1]-b[0],r=(()=>{for(var t=[],r=0,n=F;r<=n;++r)t.push(r);return t})().map(function(t){return o*Math.pow(t/F,u)+b[0]});r.sort(function(t,r){return t-r}),x=[r[0],r[F-1]]}else if(null==t.pretty||t.pretty){for(h=(b[1]-b[0])/(F+1),i=Math.floor(Math.log((b[1]-b[0]||1)/(F+1))/Math.LN10),a=0,p=(s=[10,20,25,50,100]).length;a<p&&(f=s[a],!((c=f*Math.pow(10,i-1))>h));++a);y=c*Math.floor(b[0]/c),x=[(r=(()=>{for(var t=[],r=0,n=F;r<=n;++r)t.push(r);return t})().map(function(t){return y+c*t}))[0],r[F]]}else x=[(r=(()=>{for(var t=[],r=0,n=F;r<n;++r)t.push(r);return t})().map(function(t){return b[0]+(b[1]-b[0])*t/(1<(t=F-1)?t:1)}))[0],r[F-1]];if(m=t.legend){if(k=m.format||function(t){return t},g=m.unit||"",m.range)for(v=[],a=0,d=r.length-1;a<d;++a)w=(s=[r[f=a],r[f+1]])[0],v.push({ext:[w,N=s[1]],key:(w+N)/2,text:m.text?m.text(w,N):k(w)+" - "+k(N)+g});else v=r.map(function(t){return{key:t,text:m.text?m.text(t):k(t)+""+g}});v.sort(function(t,r){return t.key<r.key?1:t.key>r.key?-1:0})}return{ticks:r,extent:x,labels:v}};"undefined"!=typeof chart&&null!==chart&&((chart.utils||(chart.utils={})).tick=t)}.call(this);
|
package/utils/tint.min.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
!function(){var
|
|
1
|
+
!function(){var i;(i=function(t){return this.isUnique=null==(t=null==t?{}:t).unique||t.unique,this.map={},this.nmap=[],this.wm=new WeakMap,this.count=0,this._ext=t.extent||[0,1],this.set(t.palette)||t.colors,this.mode(t.mode),this}).default=["#e15c64","#f7b26a","#f3ed9d","#a4bd81","#a0d7d2","#8db1da","#daaedb"],i.prototype=((t,n)=>{var s,r={}.hasOwnProperty;for(s in n)r.call(n,s)&&(t[s]=n[s]);return t})(Object.create(Object.prototype),{set:function(t){var n,s=this,r=(t=null==t?[]:t).key||t.name;return null==n&&(n=null!=r&&this.key!==r),this.key=r,this.colors=Array.isArray(t)&&t.length?t:t.colors&&Array.isArray(t.colors)?t.colors:i.default,this.nmap=t.maps||[],this.tags=this.colors.map(function(t){return t.tag||[]}),this.colors=this.colors.map(function(t){return t.value||t}),1===this.colors.length&&this.colors.push(ldcolor.complement(this.colors[0])),this.colors=this.colors.map(function(t){return ldcolor.hsl(t)}),this.len=2<(r=this.colors.length)?r:2,n?this.reset():this.nmap.map(function(t,n){return(Array.isArray(t)?t:[t]).map(function(t){return s.get(t,0,n)})}),this.tags.map(function(t,n){return t.map(function(t){return s.get(t,0,n)})})},unique:function(t){return null!=t?this.isUnique=!!t:this.isUnique},reset:function(){var s=this;return this.map={},this.wm=new WeakMap,this.count=0,(this.nmap||[]).map(function(t,n){return(Array.isArray(t)?t:[t]).map(function(t){return s.get(t,0,n)})})},mode:function(t){return 0===arguments.length?this._m:this._m=t},extent:function(t){return 0===arguments.length?this._ext:(this._ext=t.map(function(t){return null!=t?t:0}),this._ext.sort(function(t,n){return t-n}))},get:function(t,n,s){switch(null==n&&(n=0),this._m){case 1:return this._vd(t,n);case 2:return this._vc(t,n);case 3:return this._vs(t,n);default:return this._d(t,n,s)}},_v:function(t,n){return 0<n?t=ldcolor.lighter(t,n):n<0&&(t=ldcolor.darker(t,-n)),ldcolor.web(t)},_d:function(t,n,s){var r,i,e,o,h,l,u,c;if(null==n&&(n=0),null!=s?(this.count<s&&(this.count=s+1),r=s%this.len,"object"==typeof t?this.wm.set(t,r):this.map[t]=r):("object"==typeof t?null==(r=this.wm.get(t))&&this.wm.set(t,r=this.count++):null==(r=this.map[t])&&(this.map[t]=r=this.count++),this.isUnique||(r%=this.len)),r>=this.len){for(s=r%(this.len-1),i=Math.floor(r/(this.len-1)),o=(e=[0,1])[0],h=e[1];0<i;)o=(e=[2*o,2*h])[0],h=e[1],i%2&&(o+=1),i>>=1;i=o/h,e=[this.colors[s],this.colors[1+s]],l=e[0],u=e[1],c={h:(e=["h","s","l"].map(function(t){return i*(u[t]-l[t])+l[t]}))[0],s:e[1],l:e[2]}}else c=this.colors[r];return this._v(c,n)},_vs:function(t,n){for(var s,r,i,e=this._ext||[0,1],o=-1,h=0,l=e.length-1;h<l;++h)if(!(t>=e[(s=h)+1])){o=s;break}return-1===o&&(o=e.length),this._v(this.colors[(r=0<o?o:0)<(i=this.colors.length-1)?r:i],n)},_vd:function(t,n){var s=this._ext||[0,1],r=(s=0<(t=(t-s[0])/(s[1]-s[0]||1))?t:0)<1?s:1;return this._v(this.colors[Math.floor((s=r*(this.len||1))<(t=this.len-1)?s:t)],n)},_vc:function(t,n){var s,r,i,e=this._ext||[0,1],t=((e=0<(t=(t-e[0])/(e[1]-e[0]||1))?t:0)<1?e:1)*(0<(e=this.len-1)?e:0),e=t==this.len-1?[0<(e=this.len-2)?e:0,0<(e=this.len-1)?e:0]:[Math.floor(t),Math.floor(t)+1],o=e[0];return e=[this.colors[o],this.colors[e[1]]],s=e[0],r=e[1],i=t-o,t=(e=["h","s","l"].map(function(t){return i*(r[t]-s[t])+s[t]}))[0],this._v({h:t,s:e[1],l:e[2]},n)},text:function(t,n){return null==n&&(n={}),t=ldcolor.hcl(this.get(t)),ldcolor.web(50<t.l?n.textDark||"#000":n.textLight||"#fff")}}),i.mode={ordinal:0,discrete:1,continuous:2,ranges:3},"undefined"!=typeof chart&&null!==chart&&((chart.utils||(chart.utils={})).tint=i)}.call(this);
|
package/utils/tip.min.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
!function(){var t,e=function(t){var e,i=this;return this.root="string"==typeof(t=null==t?{}:t).root?document.querySelector(t.root):t.root,this.tip="string"==typeof t.node?this.root.querySelector(t.node):t.node,this.margin=null!=t.margin?t.margin:10,this.type="over"===t.type?"over":"move",this.accessor=t.accessor,this.range=t.range,this.zmgr=t.zmgr,this._z=0,this.enabled=!0,this.tip||(this.tip=document.createElement("div"),this.tip.innerHTML='<div ld="group" style="font-size:.75em"></div>\n<div ld="name" style="font-size:.85em"></div>\n<div ld="value" style="font-weight:bold;font-size:1.1em;line-height:1.2em"></div>\n<div ld="value-alt" style="font-size:0.9em;line-height:1em"></div>',this.root.appendChild(this.tip),(e=this.tip.style).padding=".4em .5em",e.background="#13171a",e.color="#fff",e.borderRadius="3px",e.boxShadow="0 2px 4px rgba(0,0,0,.3)",e.lineHeight="1.2em",e.fontSize=".9em",e.maxWidth="10em",e.wordBreak="break-all"),(e=this.tip.style).position="absolute",e.zIndex=1,e.top=0,e.left=0,e.pointerEvents="none",e.userSelect="none",e.opacity=0,e.transition="opacity .15s ease-in-out"+("over"===this.type?", transform .15s ease-in-out":""),this.view=new ldview({root:this.tip,text:t.view||{group:function(t){t=t.ctx;return t?t.group:""},name:function(t){t=t.ctx;return t?t.name:""},value:function(t){t=t.ctx;return t?t.value:""},"value-alt":function(t){t=t.ctx;return t?t.valueAlt:""}}}),this.hide=debounce(3e3,function(){if(this.tip.style.opacity=0,this.zmgr)return this.zmgr.remove(this._z)}),this._evthdr={},this.accessor&&(this.root.addEventListener("over"===this.type?"mouseover":"mousemove",this._evthdr.over=function(t){var e;if(t.target&&(e=i.accessor({evt:t})))return i.render({data:e,node:t.target,evt:t})}),this.root.addEventListener("mouseout",this._evthdr.out=function(){return i.hide().now()})),this};e.prototype=((t=Object.create(Object.prototype)).destroy=function(){if(this._evthdr.over&&this.root.removeEventListener("over"===this.type?"mouseover":"mousemove",this._evthdr.over),this._evthdr.out)return this.root.removeEventListener("mouseout",this._evthdr.out)},t.toggle=function(t){return null==t?this.enabled:this.enabled=t},t.render=function(t){var e,i,n,o,r,h,s
|
|
1
|
+
!function(){var t,e=function(t){var e,i=this;return this.root="string"==typeof(t=null==t?{}:t).root?document.querySelector(t.root):t.root,this.tip="string"==typeof t.node?this.root.querySelector(t.node):t.node,this.margin=null!=t.margin?t.margin:10,this.type="over"===t.type?"over":"move",this.accessor=t.accessor,this.range=t.range,this.zmgr=t.zmgr,this._z=0,this.enabled=!0,this.tip||(this.tip=document.createElement("div"),this.tip.innerHTML='<div ld="group" style="font-size:.75em"></div>\n<div ld="name" style="font-size:.85em"></div>\n<div ld="value" style="font-weight:bold;font-size:1.1em;line-height:1.2em"></div>\n<div ld="value-alt" style="font-size:0.9em;line-height:1em"></div>',this.root.appendChild(this.tip),(e=this.tip.style).padding=".4em .5em",e.background="#13171a",e.color="#fff",e.borderRadius="3px",e.boxShadow="0 2px 4px rgba(0,0,0,.3)",e.lineHeight="1.2em",e.fontSize=".9em",e.maxWidth="10em",e.wordBreak="break-all"),(e=this.tip.style).position="absolute",e.zIndex=1,e.top=0,e.left=0,e.pointerEvents="none",e.userSelect="none",e.opacity=0,e.transition="opacity .15s ease-in-out"+("over"===this.type?", transform .15s ease-in-out":""),this.view=new ldview({root:this.tip,text:t.view||{group:function(t){t=t.ctx;return t?t.group:""},name:function(t){t=t.ctx;return t?t.name:""},value:function(t){t=t.ctx;return t?t.value:""},"value-alt":function(t){t=t.ctx;return t?t.valueAlt:""}}}),this.hide=debounce(3e3,function(){if(this.tip.style.opacity=0,this.zmgr)return this.zmgr.remove(this._z)}),this._evthdr={},this.accessor&&(this.root.addEventListener("over"===this.type?"mouseover":"mousemove",this._evthdr.over=function(t){var e;if(t.target&&(e=i.accessor({evt:t})))return i.render({data:e,node:t.target,evt:t})}),this.root.addEventListener("mouseout",this._evthdr.out=function(){return i.hide().now()})),this};e.prototype=((t=Object.create(Object.prototype)).destroy=function(){if(this._evthdr.over&&this.root.removeEventListener("over"===this.type?"mouseover":"mousemove",this._evthdr.over),this._evthdr.out)return this.root.removeEventListener("mouseout",this._evthdr.out)},t.toggle=function(t){return null==t?this.enabled:this.enabled=t},t.render=function(t){var e,i,n,o,r,h,s;if(null==t&&(t={}),this.enabled)return this.view.ctx(t.data),this.view.render(),e=this.root.getBoundingClientRect(),n=null!=t.node?((n=t.node.getBoundingClientRect()).x=n.x-e.x,n.y=n.y-e.y,n):null!=t.box?t.box:{x:t.x,y:t.y,width:t.width,height:t.height},i=this.tip.getBoundingClientRect(),o=(t=[t.evt.clientX-e.x,t.evt.clientY-e.y])[0],s=t[1],h=this.margin,n=(t=[n.x+(null!=n.width?n.width/2:0),n.y+(null!=n.height?n.height/2:0)])[0],r=t[1],n=(t=[(t=[o-i.width/2,s-i.height/2])[0]+(n<o?1:-1)*(h+i.width/2),t[1]+(r<s?1:-1)*(h+i.height/2)])[0],o=t[1],n=(t=[((t=(n>(s=(r=this.range?this.range():e).x-e.x)?n:s)+i.width)<(h=r.width+r.x-e.x)?t:h)-i.width,((t=(o>(s=r.y-e.y)?o:s)+i.height)<(h=r.height+r.y-e.y)?t:h)-i.height])[0],o=t[1],(t=this.tip.style).transform="translate("+n+"px,"+o+"px)",t.opacity=1,t.zIndex=this._z=this.zmgr?this.zmgr.add(10):10,this.hide()},t),"undefined"!=typeof chart&&null!==chart&&((chart.utils||(chart.utils={})).tip=e)}.call(this);
|