@plotdb/chart 3.10.1 → 3.13.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 +51 -0
- package/bundle.js +406 -30
- package/bundle.min.js +1 -1
- package/index.js +332 -1
- package/index.min.js +1 -1
- package/package.json +1 -1
- package/utils/axis.js +56 -25
- package/utils/axis.min.js +1 -1
- package/utils/config.js +12 -1
- package/utils/config.min.js +1 -1
- package/utils/legend.js +6 -3
- package/utils/legend.min.js +1 -1
package/index.js
CHANGED
|
@@ -813,7 +813,211 @@
|
|
|
813
813
|
}
|
|
814
814
|
this._syncAnim();
|
|
815
815
|
if (this.mod.render) {
|
|
816
|
-
|
|
816
|
+
this.mod.render.apply(this);
|
|
817
|
+
}
|
|
818
|
+
this._brushStyle();
|
|
819
|
+
this._empty();
|
|
820
|
+
return this._anno();
|
|
821
|
+
},
|
|
822
|
+
_emptyText: function(){
|
|
823
|
+
var cfg, k, i, r, lng, res;
|
|
824
|
+
cfg = ((this.cfg || {}).common || {}).empty || {};
|
|
825
|
+
if (cfg.text) {
|
|
826
|
+
return cfg.text;
|
|
827
|
+
}
|
|
828
|
+
k = chart.i18nNs + ":text";
|
|
829
|
+
i = (typeof block != 'undefined' && block !== null) && block.i18n && block.i18n.module ? block.i18n.module : null;
|
|
830
|
+
if (i && i.t && (r = i.t(k)) && r !== k && r !== 'text') {
|
|
831
|
+
return r;
|
|
832
|
+
}
|
|
833
|
+
lng = (i ? i.language || i.lng : null) || (typeof document != 'undefined' && document !== null ? document.documentElement.lang : '') || 'en';
|
|
834
|
+
res = chart.i18n[lng] || chart.i18n[lng.split('-')[0]] || (/^zh/i.exec(lng) ? chart.i18n[/cn|hans|sg/i.exec(lng) ? 'zh-CN' : 'zh-TW'] : void 8) || chart.i18n.en;
|
|
835
|
+
return res.text;
|
|
836
|
+
},
|
|
837
|
+
_empty: function(){
|
|
838
|
+
var cfg, show, box, t;
|
|
839
|
+
cfg = ((this.cfg || {}).common || {}).empty || {};
|
|
840
|
+
show = (cfg.enabled != null ? !!cfg.enabled : true) && !(this.data || []).length;
|
|
841
|
+
if (!this.svg) {
|
|
842
|
+
return;
|
|
843
|
+
}
|
|
844
|
+
if (!show) {
|
|
845
|
+
if (this._emptyG && this._emptyG.parentNode) {
|
|
846
|
+
this._emptyG.parentNode.removeChild(this._emptyG);
|
|
847
|
+
}
|
|
848
|
+
return;
|
|
849
|
+
}
|
|
850
|
+
if (!this._emptyG) {
|
|
851
|
+
this._emptyG = document.createElementNS(svgns, 'g');
|
|
852
|
+
this._emptyG.setAttribute('data-type', 'empty');
|
|
853
|
+
this._emptyG.style.pointerEvents = 'none';
|
|
854
|
+
}
|
|
855
|
+
this.svg.appendChild(this._emptyG);
|
|
856
|
+
this._emptyG.textContent = '';
|
|
857
|
+
box = this._annoBox();
|
|
858
|
+
t = document.createElementNS(svgns, 'text');
|
|
859
|
+
t.setAttribute('x', box.x + box.width / 2);
|
|
860
|
+
t.setAttribute('y', box.y + box.height / 2);
|
|
861
|
+
t.setAttribute('text-anchor', 'middle');
|
|
862
|
+
t.setAttribute('dominant-baseline', 'middle');
|
|
863
|
+
t.style.fill = cfg.color || 'currentColor';
|
|
864
|
+
t.style.opacity = cfg.opacity != null ? cfg.opacity : 0.45;
|
|
865
|
+
if ((cfg.font || {}).size) {
|
|
866
|
+
t.style.fontSize = cfg.font.size + "";
|
|
867
|
+
}
|
|
868
|
+
t.textContent = this._emptyText();
|
|
869
|
+
return this._emptyG.appendChild(t);
|
|
870
|
+
},
|
|
871
|
+
_brushStyle: function(){
|
|
872
|
+
var cfg, set, i$, ref$, len$, n, results$ = [];
|
|
873
|
+
cfg = ((this.cfg || {}).common || {}).brush || {};
|
|
874
|
+
if (!this.svg) {
|
|
875
|
+
return;
|
|
876
|
+
}
|
|
877
|
+
set = function(n, k, v){
|
|
878
|
+
if (v != null && v !== '') {
|
|
879
|
+
return n.setAttribute(k, v);
|
|
880
|
+
}
|
|
881
|
+
};
|
|
882
|
+
for (i$ = 0, len$ = (ref$ = this.svg.querySelectorAll('rect.selection')).length; i$ < len$; ++i$) {
|
|
883
|
+
n = ref$[i$];
|
|
884
|
+
set(n, 'fill', cfg.fill);
|
|
885
|
+
set(n, 'fill-opacity', cfg.fillOpacity);
|
|
886
|
+
set(n, 'stroke', cfg.stroke);
|
|
887
|
+
set(n, 'stroke-opacity', cfg.strokeOpacity);
|
|
888
|
+
set(n, 'stroke-width', cfg.strokeWidth);
|
|
889
|
+
}
|
|
890
|
+
for (i$ = 0, len$ = (ref$ = this.svg.querySelectorAll('rect.handle')).length; i$ < len$; ++i$) {
|
|
891
|
+
n = ref$[i$];
|
|
892
|
+
set(n, 'fill', cfg.handleFill);
|
|
893
|
+
results$.push(set(n, 'fill-opacity', cfg.handleOpacity));
|
|
894
|
+
}
|
|
895
|
+
return results$;
|
|
896
|
+
},
|
|
897
|
+
_annoBox: function(){
|
|
898
|
+
var b;
|
|
899
|
+
if (this.layout) {
|
|
900
|
+
try {
|
|
901
|
+
b = this.layout.getBox('view');
|
|
902
|
+
if (b && b.width && b.height) {
|
|
903
|
+
return b;
|
|
904
|
+
}
|
|
905
|
+
} catch (e$) {}
|
|
906
|
+
}
|
|
907
|
+
return {
|
|
908
|
+
x: 0,
|
|
909
|
+
y: 0,
|
|
910
|
+
width: (this.box || {}).width || 0,
|
|
911
|
+
height: (this.box || {}).height || 0
|
|
912
|
+
};
|
|
913
|
+
},
|
|
914
|
+
_anno: function(){
|
|
915
|
+
var cfg, enabled, notes, refs, box, font, textOf, i$, len$, n, x, y, r, dir, v, e, ln, ref$, x1, y1, x2, y2, lx, ly, anchor, baseline, this$ = this, results$ = [];
|
|
916
|
+
cfg = ((this.cfg || {}).common || {}).annotation || {};
|
|
917
|
+
enabled = cfg.enabled != null ? !!cfg.enabled : true;
|
|
918
|
+
notes = enabled
|
|
919
|
+
? cfg.notes || []
|
|
920
|
+
: [];
|
|
921
|
+
refs = enabled
|
|
922
|
+
? cfg.reference || []
|
|
923
|
+
: [];
|
|
924
|
+
if (!this.svg) {
|
|
925
|
+
return;
|
|
926
|
+
}
|
|
927
|
+
if (!(notes.length || refs.length)) {
|
|
928
|
+
if (this._annoG && this._annoG.parentNode) {
|
|
929
|
+
this._annoG.parentNode.removeChild(this._annoG);
|
|
930
|
+
}
|
|
931
|
+
return;
|
|
932
|
+
}
|
|
933
|
+
if (!this._annoG) {
|
|
934
|
+
this._annoG = document.createElementNS(svgns, 'g');
|
|
935
|
+
this._annoG.setAttribute('data-type', 'annotation');
|
|
936
|
+
this._annoG.style.pointerEvents = 'none';
|
|
937
|
+
}
|
|
938
|
+
this.svg.appendChild(this._annoG);
|
|
939
|
+
this._annoG.textContent = '';
|
|
940
|
+
box = this._annoBox();
|
|
941
|
+
font = cfg.font || {};
|
|
942
|
+
textOf = function(o, x, y, anchor, baseline){
|
|
943
|
+
var t;
|
|
944
|
+
t = document.createElementNS(svgns, 'text');
|
|
945
|
+
t.setAttribute('x', x);
|
|
946
|
+
t.setAttribute('y', y);
|
|
947
|
+
t.setAttribute('text-anchor', anchor);
|
|
948
|
+
t.setAttribute('dominant-baseline', baseline);
|
|
949
|
+
t.style.fill = o.color || cfg.color || 'currentColor';
|
|
950
|
+
if (o.size || font.size) {
|
|
951
|
+
t.style.fontSize = (o.size || font.size) + "";
|
|
952
|
+
}
|
|
953
|
+
t.style.opacity = o.opacity != null
|
|
954
|
+
? o.opacity
|
|
955
|
+
: cfg.opacity != null ? cfg.opacity : 1;
|
|
956
|
+
t.textContent = o.text + "";
|
|
957
|
+
this$._annoG.appendChild(t);
|
|
958
|
+
return t;
|
|
959
|
+
};
|
|
960
|
+
for (i$ = 0, len$ = notes.length; i$ < len$; ++i$) {
|
|
961
|
+
n = notes[i$];
|
|
962
|
+
if (!(n && n.text != null)) {
|
|
963
|
+
continue;
|
|
964
|
+
}
|
|
965
|
+
x = box.x + box.width * (n.x != null ? n.x : 0.5);
|
|
966
|
+
y = box.y + box.height * (n.y != null ? n.y : 0.5);
|
|
967
|
+
textOf(n, x, y, n.align || 'middle', n.baseline || 'middle');
|
|
968
|
+
}
|
|
969
|
+
for (i$ = 0, len$ = refs.length; i$ < len$; ++i$) {
|
|
970
|
+
r = refs[i$];
|
|
971
|
+
if (!r) {
|
|
972
|
+
continue;
|
|
973
|
+
}
|
|
974
|
+
dir = r.axis === 'x' ? 'x' : 'y';
|
|
975
|
+
v = (fn$.call(this));
|
|
976
|
+
if (!(v != null) || isNaN(v)) {
|
|
977
|
+
continue;
|
|
978
|
+
}
|
|
979
|
+
if (v < 0 || v > (dir === 'y'
|
|
980
|
+
? box.height
|
|
981
|
+
: box.width)) {
|
|
982
|
+
continue;
|
|
983
|
+
}
|
|
984
|
+
ln = document.createElementNS(svgns, 'line');
|
|
985
|
+
ref$ = dir === 'y'
|
|
986
|
+
? [box.x, box.y + v, box.x + box.width, box.y + v]
|
|
987
|
+
: [box.x + v, box.y, box.x + v, box.y + box.height], x1 = ref$[0], y1 = ref$[1], x2 = ref$[2], y2 = ref$[3];
|
|
988
|
+
ln.setAttribute('x1', x1);
|
|
989
|
+
ln.setAttribute('y1', y1);
|
|
990
|
+
ln.setAttribute('x2', x2);
|
|
991
|
+
ln.setAttribute('y2', y2);
|
|
992
|
+
import$(ln.style, {
|
|
993
|
+
stroke: r.color || cfg.color || 'currentColor',
|
|
994
|
+
strokeWidth: r.width != null ? r.width : 1,
|
|
995
|
+
strokeDasharray: r.dash != null ? r.dash : '4 3',
|
|
996
|
+
opacity: r.opacity != null
|
|
997
|
+
? r.opacity
|
|
998
|
+
: cfg.opacity != null ? cfg.opacity : 0.6
|
|
999
|
+
});
|
|
1000
|
+
this._annoG.appendChild(ln);
|
|
1001
|
+
if (r.label != null) {
|
|
1002
|
+
ref$ = dir === 'y'
|
|
1003
|
+
? [box.x + box.width - 2, box.y + v - 3, 'end', 'auto']
|
|
1004
|
+
: [box.x + v + 3, box.y + 2, 'start', 'hanging'], lx = ref$[0], ly = ref$[1], anchor = ref$[2], baseline = ref$[3];
|
|
1005
|
+
results$.push(textOf({
|
|
1006
|
+
text: r.label,
|
|
1007
|
+
color: r.color,
|
|
1008
|
+
size: r.size,
|
|
1009
|
+
opacity: r.opacity
|
|
1010
|
+
}, lx, ly, anchor, baseline));
|
|
1011
|
+
}
|
|
1012
|
+
}
|
|
1013
|
+
return results$;
|
|
1014
|
+
function fn$(){
|
|
1015
|
+
try {
|
|
1016
|
+
return this.space[dir](r.value);
|
|
1017
|
+
} catch (e$) {
|
|
1018
|
+
e = e$;
|
|
1019
|
+
return null;
|
|
1020
|
+
}
|
|
817
1021
|
}
|
|
818
1022
|
},
|
|
819
1023
|
destroy: function(){
|
|
@@ -1304,10 +1508,137 @@
|
|
|
1304
1508
|
type: 'color',
|
|
1305
1509
|
'default': 'transparent'
|
|
1306
1510
|
}
|
|
1511
|
+
},
|
|
1512
|
+
empty: {
|
|
1513
|
+
enabled: {
|
|
1514
|
+
type: 'boolean',
|
|
1515
|
+
'default': true
|
|
1516
|
+
},
|
|
1517
|
+
text: {
|
|
1518
|
+
type: 'text',
|
|
1519
|
+
'default': ''
|
|
1520
|
+
},
|
|
1521
|
+
color: {
|
|
1522
|
+
type: 'color',
|
|
1523
|
+
'default': 'currentColor'
|
|
1524
|
+
},
|
|
1525
|
+
opacity: {
|
|
1526
|
+
type: 'number',
|
|
1527
|
+
'default': 0.45,
|
|
1528
|
+
min: 0,
|
|
1529
|
+
max: 1,
|
|
1530
|
+
step: 0.05
|
|
1531
|
+
},
|
|
1532
|
+
font: {
|
|
1533
|
+
size: {
|
|
1534
|
+
type: 'quantity',
|
|
1535
|
+
'default': '',
|
|
1536
|
+
units: [{
|
|
1537
|
+
name: 'em',
|
|
1538
|
+
max: 10,
|
|
1539
|
+
step: 0.01,
|
|
1540
|
+
'default': 1
|
|
1541
|
+
}]
|
|
1542
|
+
}
|
|
1543
|
+
}
|
|
1544
|
+
},
|
|
1545
|
+
brush: {
|
|
1546
|
+
fill: {
|
|
1547
|
+
type: 'color',
|
|
1548
|
+
'default': ''
|
|
1549
|
+
},
|
|
1550
|
+
fillOpacity: {
|
|
1551
|
+
type: 'number',
|
|
1552
|
+
'default': '',
|
|
1553
|
+
min: 0,
|
|
1554
|
+
max: 1,
|
|
1555
|
+
step: 0.05
|
|
1556
|
+
},
|
|
1557
|
+
stroke: {
|
|
1558
|
+
type: 'color',
|
|
1559
|
+
'default': ''
|
|
1560
|
+
},
|
|
1561
|
+
strokeOpacity: {
|
|
1562
|
+
type: 'number',
|
|
1563
|
+
'default': '',
|
|
1564
|
+
min: 0,
|
|
1565
|
+
max: 1,
|
|
1566
|
+
step: 0.05
|
|
1567
|
+
},
|
|
1568
|
+
strokeWidth: {
|
|
1569
|
+
type: 'number',
|
|
1570
|
+
'default': '',
|
|
1571
|
+
min: 0,
|
|
1572
|
+
max: 20,
|
|
1573
|
+
step: 0.5
|
|
1574
|
+
},
|
|
1575
|
+
handleFill: {
|
|
1576
|
+
type: 'color',
|
|
1577
|
+
'default': ''
|
|
1578
|
+
},
|
|
1579
|
+
handleOpacity: {
|
|
1580
|
+
type: 'number',
|
|
1581
|
+
'default': '',
|
|
1582
|
+
min: 0,
|
|
1583
|
+
max: 1,
|
|
1584
|
+
step: 0.05
|
|
1585
|
+
}
|
|
1586
|
+
},
|
|
1587
|
+
annotation: {
|
|
1588
|
+
enabled: {
|
|
1589
|
+
type: 'boolean',
|
|
1590
|
+
'default': true
|
|
1591
|
+
},
|
|
1592
|
+
color: {
|
|
1593
|
+
type: 'color',
|
|
1594
|
+
'default': 'currentColor'
|
|
1595
|
+
},
|
|
1596
|
+
opacity: {
|
|
1597
|
+
type: 'number',
|
|
1598
|
+
'default': 1,
|
|
1599
|
+
min: 0,
|
|
1600
|
+
max: 1,
|
|
1601
|
+
step: 0.05
|
|
1602
|
+
},
|
|
1603
|
+
font: {
|
|
1604
|
+
size: {
|
|
1605
|
+
type: 'quantity',
|
|
1606
|
+
'default': '.8em',
|
|
1607
|
+
units: [{
|
|
1608
|
+
name: 'em',
|
|
1609
|
+
max: 10,
|
|
1610
|
+
step: 0.01,
|
|
1611
|
+
'default': 0.8
|
|
1612
|
+
}]
|
|
1613
|
+
}
|
|
1614
|
+
}
|
|
1307
1615
|
}
|
|
1308
1616
|
}
|
|
1309
1617
|
};
|
|
1618
|
+
chart.i18nNs = "@plotdb/chart";
|
|
1619
|
+
chart.i18n = {
|
|
1620
|
+
en: {
|
|
1621
|
+
text: "No data to show"
|
|
1622
|
+
},
|
|
1623
|
+
"zh-TW": {
|
|
1624
|
+
text: "沒有可顯示的資料"
|
|
1625
|
+
},
|
|
1626
|
+
"zh-CN": {
|
|
1627
|
+
text: "没有可显示的数据"
|
|
1628
|
+
},
|
|
1629
|
+
ja: {
|
|
1630
|
+
text: "表示するデータがありません"
|
|
1631
|
+
}
|
|
1632
|
+
};
|
|
1310
1633
|
chart.scopes = {
|
|
1634
|
+
space: {
|
|
1635
|
+
x: function(v){
|
|
1636
|
+
return null;
|
|
1637
|
+
},
|
|
1638
|
+
y: function(v){
|
|
1639
|
+
return null;
|
|
1640
|
+
}
|
|
1641
|
+
},
|
|
1311
1642
|
frame: {
|
|
1312
1643
|
active: function(){
|
|
1313
1644
|
return !!this._frames;
|
package/index.min.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
!function(){var n,f,c,p,t,i,s,r,o,e,a,u,l,h,d,m,y,g,_;function v(t,n,c){function p(t,n){return i.call(t,n)}var d={}.toString,i={}.hasOwnProperty,m=!0;return function t(n,i,e){var r,s,o,a,u,l,h,f;if(null==n||null==i)return n===i;if(n.__placeholder__||i.__placeholder__)return!0;if(n===i)return 0!==n||1/n==1/i;r=d.call(n);if(d.call(i)!=r)return!1;switch(r){case"[object String]":return n==String(i);case"[object Number]":return n!=+n?i!=+i:0==n?1/n==1/i:n==+i;case"[object Date]":case"[object Boolean]":return+n==+i;case"[object RegExp]":return n.source==i.source&&n.global==i.global&&n.multiline==i.multiline&&n.ignoreCase==i.ignoreCase}if("object"!=typeof n||"object"!=typeof i)return!1;s=e.length;for(;s--;)if(e[s]==n)return!0;e.push(n);o=0;a=!0;if("[object Array]"==r){if(u=n.length,l=i.length,m){switch(c){case"===":a=u===l;break;case"<==":a=u<=l;break;case"<<=":a=u<l}o=u,m=!1}else a=u===l,o=u;if(a)for(;o--&&(a=o in n==o in i&&t(n[o],i[o],e)););}else{if("constructor"in n!="constructor"in i||n.constructor!=i.constructor)return!1;for(h in n)if(p(n,h)&&(o++,!(a=p(i,h)&&t(n[h],i[h],e))))break;if(a){for(h in f=0,i)p(i,h)&&++f;a=m?"<<="===c?o<f:"<=="===c?o<=f:o===f:(m=!1,o===f)}}e.pop();return a}(t,n,[])}function b(t,n){var i,e={}.hasOwnProperty;for(i in n)e.call(n,i)&&(t[i]=n[i]);return t}n=new function(t){var i=new Intl.NumberFormat(t),t=i.formatToParts(12345.6),n=Array.from({length:10}).map(function(t,n){return i.format(n)}),e=new Map(n.map(function(t,n){return[t,n]}));return this._group=new RegExp("["+t.find(function(t){return v(t.type,"group","===")}).value+"]","g"),this._decimal=new RegExp("["+t.find(function(t){return v(t.type,"decimal","===")}).value+"]"),this._numeral=new RegExp("["+n.join("")+"]","g"),this._index=function(t){return e.get(t)},this}("en-US"),f=function(t){return(t=((t=null==t?"":t)+"").trim().replace(n._group,"").replace(n._decimal,".").replace(n._numeral,n._index))?+t:NaN},c=function(t){return"number"==typeof t?t:!t&&0!==t||isNaN(+t)?0:+t},p=function(t){return!(!/[RIT]/.exec((t=null==t?{}:t).type||"")||/[CN]/.exec(t.type||""))},t=function(n){var t,i,e,r,s,o=[];for(i in n=null==n?{}:n)o.push(i);for(t=o,e=0,s=(r=["name","order"]).length;e<s;++e)if(n[i=r[e]]&&!p(n[i]))return i;return t.filter(function(t){return!p(n[t])})[0]},i=function(){var u,l,h,a=this,f=(this.mod||{}).dimension||{};if(this._subset)return u=t(f),l=this._subset.map(function(n){var t,i,e,r,s={};for(t in i=f)e=i[t],(r=a.binding[t])&&(s[t]=e.multiple?(r.map?r:[r]).map(o):n[r.key],p(e))&&(s[t]=Array.isArray(s[t])?s[t].map(c):c(s[t]));return s;function o(t){return n[t.key]}}),h={},u&&l.map(function(t){return h[t[u]+""]=t}),this.data.map(function(t,n){var i,e,r,s=u?h[t[u]+""]:l[n],o={};for(i in e=f)r=e[i],p(r)&&(o[i]=r.multiple?(t[i]||[]).map(a):s?c(s[i]):0);return t.subset=o;function a(t,n){return s?c((s[i]||[])[n]):0}}),"shrink"===(((this.cfg||{}).common||{}).subset||{}).mode?this.data.map(function(t){var n,i,e,r=[];for(n in i=f)e=i[n],p(e)&&r.push(t[n]=t.subset[n]);return r}):void 0;this.data.map(function(t){var n=t.subset;return delete t.subset,n})},s=function(t){return!(!t||Array.isArray(t)||!Array.isArray(t.frames))},r=function(t){return"number"==typeof t||"string"==typeof t&&t.trim()&&!isNaN(+t)},o=function(t){return t instanceof Date||"string"==typeof t&&!isNaN(Date.parse(t))},e=function(t){var n,i,s,e;return n=((t=null==t?{}:t).frames||[]).map(function(t,n){return{id:null!=t.id?t.id:n,raw:t.raw||[]}}),t=t.frameOrder,Array.isArray(t)&&t.length?(i={},n.map(function(t){return i[t.id+""]=t}),(s=t.map(function(t){return i[t+""]}).filter(function(t){return t})).concat(n.filter(function(t){for(var n=t,i=s,e=-1,r=i.length>>>0;++e<r;)if(n===i[e])return!1;return!0}))):(t=n.map(function(t){return t.id})).length&&t.every(r)?n.map(function(t,n){return{f:t,i:n}}).sort(function(t,n){return+t.f.id-+n.f.id||t.i-n.i}).map(function(t){return t.f}):t.length&&t.every(o)?(e=function(t){return t instanceof Date?t.getTime():Date.parse(t)},n.map(function(t,n){return{f:t,i:n}}).sort(function(t,n){return e(t.f.id)-e(n.f.id)||t.i-n.i}).map(function(t){return t.f})):n},a=function(t){var n,i;if("string"!=typeof t)return null;if(t=t.trim(),n=/^#([0-9a-f]{3})$/i.exec(t)){for(var e,r=[],s=0,o=(e=n[1].split("")).length;s<o;++s)i=e[s],r.push(parseInt(i+i,16));return r}return(n=/^#([0-9a-f]{6})$/i.exec(t))?[0,1,2].map(function(t){return parseInt(n[1].substr(2*t,2),16)}):(n=/^rgba?\(([^)]+)\)$/i.exec(t))&&3===(t=n[1].split(",").slice(0,3).map(function(t){return parseFloat(t.trim())})).length&&t.every(function(t){return!isNaN(t)})?t:null},u=function(t,n,i){var e,r,s,o;for(r in null==i&&(i={}),e={},s=b(b({},n=null==n?{}:n),i||{}))o=s[r],e[r]="function"==typeof o?o.bind(t):o;return e},l=function(t,n,i){for(var e=t;t&&t!==i;)t=t.parentNode;if(t!==i)return null;if(!n)return t;for(t=e;t&&t!==i&&(!t.matches||(t.matches,!t.matches(n)));)t=t.parentNode;return t!==i||i.matches&&i.matches(n)?t:null},(h=function(){return this.running=!1,this.time={now:0,last:0},this.fps(60),this.evtHandler={},this}).prototype=b(Object.create(Object.prototype),{on:function(t,i){var e=this;return(Array.isArray(t)?t:[t]).map(function(t){var n;return((n=e.evtHandler)[t]||(n[t]=[])).push(i)})},fire:function(t){for(var n,i,e,r,s=[],o=[],a=1,u=arguments.length;a<u;++a)o.push(arguments[a]);for(n=o,a=0,e=(i=this.evtHandler[t]||[]).length;a<e;++a)r=i[a],s.push(r.apply(this,n));return s},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(t){return this.fire("tick",this.time.now,t=null==t?0:t)},run:function(t){var n=this;if(null!=t&&this.fps(t),!this.running)return this.running=!0,requestAnimationFrame(function(t){return n.handler(n.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,n){var i,e,r=this;if(null==n&&(n=!1),this.running)return this.external&&this.external()?(this.time.last=t,requestAnimationFrame(function(t){return r.handler(t,!1)})):(this.time.now=t,i=this.isThrottled?1e3<(i=this._fps_delay)?i:1e3:this._fps_delay,(n||(e=this.time.now-this.time.last)>=i)&&(this.time.last=t,this.render(n?0:e)),requestAnimationFrame(function(t){return r.handler(t,!1)}))}}),d={list:[],init:function(){var t,i,e=this;return this.inited=!0,t=null==document.hidden&&null==document.msHidden&&null!=document.webkiHidden?["webkitHidden","webkitvisibilitychange"]:["hidden","visibilitychange"],i=t[0],document.addEventListener(t[1],debounce(150,function(){var n=!!document[i];return e.list.map(function(t){return t.throttle(n)})},!1))},add:function(t){return this.inited||this.init(),this.list.push(t)}},m={wm:new WeakMap,ro:new ResizeObserver(function(t){return t.map(function(t){return m.wm.get(t.target)._resize()})}),add:function(t,n){return this.wm.set(t,n),this.ro.observe(t)},delete:function(t){return this.ro.unobserve(t),this.wm.delete(t)}},y=function(t,n,i){return null==n&&(n={}),null==i&&(i={}),function(t,n,i){var e,r;for(e in n)r=n[e],null==t[e]?t[e]=r:"object"!=typeof t[e]||"object"!=typeof r||i[e]&&i[e].type||y(t[e],n[e],i[e]);return t}(t=null==t?{}:t,n=JSON.parse(JSON.stringify(n)),i)},g=function(t){var r=function(t,n){var i,e;for(i in null==n&&(n={}),t.child,t)(e=t[i]).type?e.default&&(n[i]=e.default):r(e,n[i]||(n[i]={}));return n};return r(t)},(_=function(t){var n,i,e,r=this;for(n 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,this._frames=null,this._player={playing:!1,pos:0,origin:0,raf:null},s(this.raw)&&(this._setFrames(this.raw),this.raw=(null!=(t=this._frames.list[this._frames.index])?t.raw:void 0)||[]),i=_.scopes){if(e=i[n],null!=this[n])throw new Error("[@plotdb/chart] scope name `"+n+"` is already taken.");this[n]=u(this,e,this.mod[n])}if(null!=this.local)throw new Error("[@plotdb/chart] scope name `local` is already taken.");return this.local=u(this,{},this.mod.local),(_.utils||(_.utils={})).anim&&null==this.anim&&(this.anim=new _.utils.anim),this.anim&&this.anim.on("step",function(){if(r._player.playing)return r._playerTick()}),this.init=proxise.once(function(){return r._init()}),this._resize=null,this._inited=!1,this.autoSelect&&(this.root.addEventListener("click",this._select=function(t){if(t=l(t.target,".data",r.root))return r.fire("select",[{data:r.dataAccessor(t),node:t}])}),this.root.addEventListener("mouseover",this._hover=function(t){if(t=l(t.target,".data",r.root))return r.fire("hover",[{data:r.dataAccessor(t),node:t}])})),this}).prototype=b(Object.create(Object.prototype),{_init:function(){var i,t,n,e=this;return"static"===window.getComputedStyle(this.root).position&&(this.root.style.position="relative"),i=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||(i||console.error("[@plotdb/chart] layout enabled yet layout root isn't configured properly. "),n=i.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."),(n||this.root).appendChild(this.svg)),this._aniloop=new h,d.add(this._aniloop),this._aniloop.on("tick",function(t,n){return e.tick(t,n)}),this.anim&&(this._aniloop.external=function(){return e.anim.manual()},this.anim.on("step",function(t,n){if(e._aniloop.isRunning())return e._aniloop.setTime(t),e._aniloop.render(n)})),Promise.resolve().then(function(){var t;return e.mod.config=y(e.mod.config||{},_.commonConfig),e._defcfg=t=g(e.mod.config),y(e.cfg,t),e.raw&&Array.isArray(e.raw)?{raw:e.raw,binding:e.binding}:e.useSample&&e.mod.sample?(t=e.mod.sample.apply(e)).then?t.then():Promise.resolve(t):void 0}).then(function(t){return e.raw=(t=t||{}).raw,e.binding=t.binding,e}).then(function(){var t,n;return e.raw||(e.raw=[]),e.layoutOpt&&("undefined"==typeof layout||null===layout?console.warn("[@plotdb/chart] layout-opt is set yet @plotdb/layout is not found."):(i||(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")),e.layout=new layout("object"==typeof e.layoutOpt?((n=b({},e.layoutOpt)).watchResize=!1,n):{root:i,watchResize:!1}))),t=proxise(function(){return m.add(e.root,e),null}),e._resize=function(){return t.resolve()},n=t(),(e.forceInit||!e.root.offsetParent||"none"===window.getComputedStyle(e.root).display||e.root.offsetWidth&&e.root.offsetHeight)&&t.resolve(),n}).then(function(){return e._resize=function(){}}).then(function(){var t,n=function(){if(e.mod.init)return e.mod.init.apply(e)};return(e.layout?(t=proxise(function(){return Promise.resolve(e.layout.init(n)),null}),e._layout=function(){return t.resolve()},e.layout.on("render",function(){return e._layout()}),t):n)()}).then(function(){e._layout=function(){},Promise.resolve().then(function(){if(e.delayRender&&!e._pendingRaw)return e.renderLock=proxise(function(){}),e.renderLock()}).then(function(){if(e._inited=!0,e._resize=function(){e.anim&&e.anim.immediate(!0);try{return e.resize(),e.render()}finally{e.anim&&e.anim.immediate(!1)}},e._layout=function(){return e.parse(),e.bind(),e.resize(),e.render()},e.parse(),e.bind(),e.resize(),e.render(),e._frames)return e._framesStart()})})},parse:function(){if(this.data=this._parseRows(this.raw),this._frames&&(this._frames.all=null),i.apply(this),this.mod.parse)return this.mod.parse.apply(this)},_parseRows:function(t){var l,n,h;return null==t&&(t=[]),l=(n=this.mod).dimension||(n.dimension={}),h=this.binding,t.map(function(n,t){var i,e,r,s,o={};for(i in e=l)r=e[i],(s=h[i])?(o[i]=r.multiple?(s.map?s:[s]).map(a):n[s.key],/[RIT]/.exec(r.type)&&!/[CN]/.exec(r.type)&&(o[i]=Array.isArray(o[i])?o[i].map(u):f(o[i]))):r.multiple&&(o[i]=[]);return o._raw=n,o._idx=t,o;function a(t){return n[t.key]}function u(t){return f(t)}})},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(t,n){if(this.mod.tick)return this.mod.tick.apply(this,[t,n])},render:function(){if(this._inited)return this._syncAnim(),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),m.delete(t.root),t.layout&&t.layout.destroy(),t.pause(),t.stop(),t.mod.destroy)return t.mod.destroy.apply(t)})},config:function(){var t,n,i;if(!arguments.length)return this.cfg;for(t={},n=0,i=arguments.length;n<i;++n)y(t,arguments[n],this.mod.config);return y(t,this.cfg,this.mod.config),y(t,this._defcfg,this.mod.config),b(this.cfg,t)},_normalizeBinding:function(t){var n,i,e,r,s,o,a,u=[];if(null==t){for(t in n=[],this.mod.dimension||{})n.push(t);t=n}for(i=0,e=(t=Array.isArray(t)?t:[t]).length;i<e;++i)r=t[i],s=(this.mod.dimension||{})[r]||{},o=this.binding[r],a=Array.isArray(o),!s.multiple!=!a&&(s.multiple||a)&&u.push(this.binding[r]=a?o[0]:o?[o]:[]);return u},setBind:function(t,n){if(this.binding[t]=n,this._normalizeBinding([t]),this._inited)return this.parse(),this.bind(),this.resize(),this.render()},setRaw:function(t,n,i){var e;return null==i&&(i=!1),!t||Array.isArray(t)||s(t)||("subset"in t&&(this._subset=t.subset||null),t=(e=t).raw,n=e.binding,i=e.reinit),s(t)?(this._setFrames(t),t=(null!=(e=this._frames.list[this._frames.index])?e.raw:void 0)||[]):null!=t&&this._frames&&(this.pause(),this._frames=null,this._player.pos=0,this.anim)&&this.anim.resume(),null!=t&&(this.raw=t),null!=n&&(this.binding=n,this._normalizeBinding()),this.renderLock?(this.renderLock.resolve(),this.renderLock=null):this._inited?(i&&this.mod.init&&this.mod.init.apply(this),this.parse(),this.bind(),this.resize(),this.render(),this._frames?this._framesStart():void 0):this._pendingRaw=!0},_animCfg:function(){return((this.cfg||{}).common||{}).animation||{}},_syncAnim:function(){var t;if(this.anim)return null!=(t=this._animCfg()).transition&&this.anim.duration(t.transition),this.anim.speed(null!=t.speed?t.speed:1)},_setFrames:function(t){var n,t=e(t);return this._frames={list:t,index:0,all:null},this._frames.index=this._frameAt((t=this._player.pos)<(n=this.duration())?t:n)},_interval:function(){return+this._animCfg().interval||1e3},_clock:function(){return this.anim?this.anim.time():("undefined"!=typeof performance&&null!==performance?performance:Date).now()},_frameAt:function(t){var n=this._frames?this._frames.list.length:0;return n?(t=0<(t=Math.floor(t/this._interval()))?t:0)<(n=n-1)?t:n:0},_framesStart:function(){if(this.fire("frame",{index:this._frames.index,id:this.frame.id()}),this._animCfg().autoplay&&!this._player.playing)return this.play()},_goto:function(t,n){var i,e,r,s=this;if(null==n&&(n=0),(i=this._frames)&&i.list.length&&(t=(e=0<t?t:0)<(r=i.list.length-1)?e:r,i.index=t,this.raw=i.list[t].raw,this._inited))return this.parse(),this.bind(),this.resize(),this.anim&&0<n?this.anim.ago(n,function(){return s.render()}):this.render(),this.fire("frame",{index:t,id:i.list[t].id})},duration:function(){return this._frames?this._frames.list.length*this._interval():0},position:function(){var t=this._player;return t.playing?this._clock()-t.origin:t.pos},playing:function(){return this._player.playing},play:function(){var t=this._player;if(this._frames&&!t.playing&&this._frames.list.length)return t.pos>=this.duration()&&(t.pos=0),this._syncAnim(),this.anim&&this.anim.resume(),t.origin=this._clock()-t.pos,t.playing=!0,this.fire("play"),this._playerLoop()},pause:function(){var t=this._player;if(t.playing)return t.pos=this.position(),t.playing=!1,t.raf&&cancelAnimationFrame(t.raf),t.raf=null,this.anim&&this.anim.pause(),this.fire("pause")},seek:function(t){var n,i,e,r;if(this._frames&&this._frames.list.length)return r=this._interval(),i=(t=(e=0<(e=+(t=t&&"object"==typeof t?((t.frame||0)+(t.progress||0))*r:t)||0)?e:0)<(n=this.duration())?e:n)-(n=this._frameAt(t))*r,e=(e=+this._animCfg().transition||0)<r?e:r,0<n&&i<e?(this._goto(n-1),this.anim&&this.anim.flush(),this._goto(n,i)):(this._goto(n),this.anim&&this.anim.flush()),(r=this._player).pos=t,r.playing&&(r.origin=this._clock()-t),this.fire("progress",{time:t,duration:this.duration(),index:n})},_playerLoop:function(){var t,n=this,i=this._player;if(!i.raf&&"undefined"!=typeof requestAnimationFrame&&null!==requestAnimationFrame)return i.raf=requestAnimationFrame(t=function(){if(i.raf=null,i.playing)return n.anim&&n.anim.manual()||n._playerTick(),i.playing?i.raf=requestAnimationFrame(t):void 0})},_playerTick:function(){var t,n,i=this._player,e=this._frames;if(e&&e.list.length){if((t=this.duration())<=(n=this.position())){if(!this._animCfg().loop)return i.pos=t,i.playing=!1,this.fire("progress",{time:t,duration:t,index:e.index}),void this.fire("end");n%=t,i.origin=this._clock()-n}return(i=this._frameAt(n))!==e.index&&this._goto(i,n-i*this._interval()),this.fire("progress",{time:n,duration:t,index:i})}},on:function(t,i){var e=this;return(Array.isArray(t)?t:[t]).map(function(t){var n;return((n=e.evtHandler)[t]||(n[t]=[])).push(i)})},fire:function(t){for(var n,i,e,r,s=[],o=[],a=1,u=arguments.length;a<u;++a)o.push(arguments[a]);for(n=o,a=0,e=(i=this.evtHandler[t]||[]).length;a<e;++a)r=i[a],s.push(r.apply(this,n));return s},filter:function(t,n){var i,e,r,s,o;for(e in null==t&&(t={}),null==n&&(n=!1),i=[],r=this.binding)s=r[e],o=(o=Array.isArray(s)?s:[s]).map(a),i=i.concat(o);for(e in t)s=t[e],i.filter(u).map(l);return n&&this.fire("filter",t),this.mod.filter&&this.mod.filter.apply(this,[t,n]),this.parse(),this.bind(),this.resize(),this.render();function a(t){return{k:e,v:t}}function u(t){return t.k===e}function l(t){return t.v.filter=s}},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}}),_.commonConfig={common:{animation:{transition:{type:"number",default:350,min:0,max:5e3,step:10},interval:{type:"number",default:1e3,min:100,max:2e4,step:50},speed:{type:"number",default:1,min:.1,max:10,step:.1},loop:{type:"boolean",default:!0},autoplay:{type:"boolean",default:!0}},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},background:{type:"color",default:"transparent"}}}},_.scopes={frame:{active:function(){return!!this._frames},count:function(){return this._frames?this._frames.list.length:0},index:function(){return this._frames?this._frames.index:-1},id:function(t){return this._frames?(this._frames.list[null!=t?t:this._frames.index]||{}).id:null},ids:function(){return this._frames?this._frames.list.map(function(t){return t.id}):[]},all:function(){var t,n;return this._frames?null!=(n=(t=this._frames).all)?n:t.all=this._parseRows([].concat.apply([],this._frames.list.map(function(t){return t.raw}))):this._parseRows(this.raw)}},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,n,i){return t&&t.subset?!(t=(i=null!=i?[(t[n]||[])[i],(t.subset[n]||[])[i]]:[t[n],t.subset[n]])[0])||(n=i[1]/t)<0?0:1<n?1:n:null},color:function(t,n){var i,e,r,s;return(e=a(t))?(i=.3*e[0]+.59*e[1]+.11*e[2],e=((this.cfg||{}).common||{}).subset||{},r=null!=(r=null!=n?n:e.fade)?r:.72,s=a(e.background)||a((this.cfg||{}).background)||[255,255,255],"rgb("+[0,1,2].map(function(t){return Math.round(i+(s[t]-i)*r)}).join(",")+")"):t}}},_.dataframe={is:s,split:function(t,i){var e={},r=[];return(t=null==t?[]:t).map(function(t){var n=t[i]+"";return e[n]||r.push(e[n]={id:t[i],raw:[]}),e[n].raw.push(t)}),{frames:r}}},"undefined"!=typeof module&&null!==module?module.exports=_:"undefined"!=typeof window&&null!==window&&(window.chart=_)}.call(this);
|
|
1
|
+
!function(){var w,e,f,c,p,t,n,o,r,s,i,a,u,l,h,d,m,y,g,_;function b(t,e,c){function p(t,e){return n.call(t,e)}var d={}.toString,n={}.hasOwnProperty,m=!0;return function t(e,n,i){var r,o,s,a,u,l,h,f;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=d.call(e);if(d.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;a=!0;if("[object Array]"==r){if(u=e.length,l=n.length,m){switch(c){case"===":a=u===l;break;case"<==":a=u<=l;break;case"<<=":a=u<l}s=u,m=!1}else a=u===l,s=u;if(a)for(;s--&&(a=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(p(e,h)&&(s++,!(a=p(n,h)&&t(e[h],n[h],i))))break;if(a){for(h in f=0,n)p(n,h)&&++f;a=m?"<<="===c?s<f:"<=="===c?s<=f:s===f:(m=!1,s===f)}}i.pop();return a}(t,e,[])}function x(t,e){var n,i={}.hasOwnProperty;for(n in e)i.call(e,n)&&(t[n]=e[n]);return t}w="http://www.w3.org/2000/svg",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)}),i=new Map(e.map(function(t,e){return[t,e]}));return this._group=new RegExp("["+t.find(function(t){return b(t.type,"group","===")}).value+"]","g"),this._decimal=new RegExp("["+t.find(function(t){return b(t.type,"decimal","===")}).value+"]"),this._numeral=new RegExp("["+e.join("")+"]","g"),this._index=function(t){return i.get(t)},this}("en-US"),f=function(t){return(t=((t=null==t?"":t)+"").trim().replace(e._group,"").replace(e._decimal,".").replace(e._numeral,e._index))?+t:NaN},c=function(t){return"number"==typeof t?t:!t&&0!==t||isNaN(+t)?0:+t},p=function(t){return!(!/[RIT]/.exec((t=null==t?{}:t).type||"")||/[CN]/.exec(t.type||""))},t=function(e){var t,n,i,r,o,s=[];for(n in e=null==e?{}:e)s.push(n);for(t=s,i=0,o=(r=["name","order"]).length;i<o;++i)if(e[n=r[i]]&&!p(e[n]))return n;return t.filter(function(t){return!p(e[t])})[0]},n=function(){var u,l,h,a=this,f=(this.mod||{}).dimension||{};if(this._subset)return u=t(f),l=this._subset.map(function(e){var t,n,i,r,o={};for(t in n=f)i=n[t],(r=a.binding[t])&&(o[t]=i.multiple?(r.map?r:[r]).map(s):e[r.key],p(i))&&(o[t]=Array.isArray(o[t])?o[t].map(c):c(o[t]));return o;function s(t){return e[t.key]}}),h={},u&&l.map(function(t){return h[t[u]+""]=t}),this.data.map(function(t,e){var n,i,r,o=u?h[t[u]+""]:l[e],s={};for(n in i=f)r=i[n],p(r)&&(s[n]=r.multiple?(t[n]||[]).map(a):o?c(o[n]):0);return t.subset=s;function a(t,e){return o?c((o[n]||[])[e]):0}}),"shrink"===(((this.cfg||{}).common||{}).subset||{}).mode?this.data.map(function(t){var e,n,i,r=[];for(e in n=f)i=n[e],p(i)&&r.push(t[e]=t.subset[e]);return r}):void 0;this.data.map(function(t){var e=t.subset;return delete t.subset,e})},o=function(t){return!(!t||Array.isArray(t)||!Array.isArray(t.frames))},r=function(t){return"number"==typeof t||"string"==typeof t&&t.trim()&&!isNaN(+t)},s=function(t){return t instanceof Date||"string"==typeof t&&!isNaN(Date.parse(t))},i=function(t){var e,n,o,i;return e=((t=null==t?{}:t).frames||[]).map(function(t,e){return{id:null!=t.id?t.id:e,raw:t.raw||[]}}),t=t.frameOrder,Array.isArray(t)&&t.length?(n={},e.map(function(t){return n[t.id+""]=t}),(o=t.map(function(t){return n[t+""]}).filter(function(t){return t})).concat(e.filter(function(t){for(var e=t,n=o,i=-1,r=n.length>>>0;++i<r;)if(e===n[i])return!1;return!0}))):(t=e.map(function(t){return t.id})).length&&t.every(r)?e.map(function(t,e){return{f:t,i:e}}).sort(function(t,e){return+t.f.id-+e.f.id||t.i-e.i}).map(function(t){return t.f}):t.length&&t.every(s)?(i=function(t){return t instanceof Date?t.getTime():Date.parse(t)},e.map(function(t,e){return{f:t,i:e}}).sort(function(t,e){return i(t.f.id)-i(e.f.id)||t.i-e.i}).map(function(t){return t.f})):e},a=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 i,r=[],o=0,s=(i=e[1].split("")).length;o<s;++o)n=i[o],r.push(parseInt(n+n,16));return r}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},u=function(t,e,n){var i,r,o,s;for(r in null==n&&(n={}),i={},o=x(x({},e=null==e?{}:e),n||{}))s=o[r],i[r]="function"==typeof s?s.bind(t):s;return i},l=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},(h=function(){return this.running=!1,this.time={now:0,last:0},this.fps(60),this.evtHandler={},this}).prototype=x(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=[],a=1,u=arguments.length;a<u;++a)s.push(arguments[a]);for(e=s,a=0,i=(n=this.evtHandler[t]||[]).length;a<i;++a)r=n[a],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(t){return this.fire("tick",this.time.now,t=null==t?0:t)},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,r=this;if(null==e&&(e=!1),this.running)return this.external&&this.external()?(this.time.last=t,requestAnimationFrame(function(t){return r.handler(t,!1)})):(this.time.now=t,n=this.isThrottled?1e3<(n=this._fps_delay)?n:1e3:this._fps_delay,(e||(i=this.time.now-this.time.last)>=n)&&(this.time.last=t,this.render(e?0:i)),requestAnimationFrame(function(t){return r.handler(t,!1)}))}}),d={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)}},m={wm:new WeakMap,ro:new ResizeObserver(function(t){return t.map(function(t){return m.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)}},y=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||y(t[i],e[i],n[i]);return t}(t=null==t?{}:t,e=JSON.parse(JSON.stringify(e)),n)},g=function(t){var r=function(t,e){var n,i;for(n in null==e&&(e={}),t.child,t)(i=t[n]).type?i.default&&(e[n]=i.default):r(i,e[n]||(e[n]={}));return e};return r(t)},(_=function(t){var e,n,i,r=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,this._frames=null,this._player={playing:!1,pos:0,origin:0,raf:null},o(this.raw)&&(this._setFrames(this.raw),this.raw=(null!=(t=this._frames.list[this._frames.index])?t.raw:void 0)||[]),n=_.scopes){if(i=n[e],null!=this[e])throw new Error("[@plotdb/chart] scope name `"+e+"` is already taken.");this[e]=u(this,i,this.mod[e])}if(null!=this.local)throw new Error("[@plotdb/chart] scope name `local` is already taken.");return this.local=u(this,{},this.mod.local),(_.utils||(_.utils={})).anim&&null==this.anim&&(this.anim=new _.utils.anim),this.anim&&this.anim.on("step",function(){if(r._player.playing)return r._playerTick()}),this.init=proxise.once(function(){return r._init()}),this._resize=null,this._inited=!1,this.autoSelect&&(this.root.addEventListener("click",this._select=function(t){if(t=l(t.target,".data",r.root))return r.fire("select",[{data:r.dataAccessor(t),node:t}])}),this.root.addEventListener("mouseover",this._hover=function(t){if(t=l(t.target,".data",r.root))return r.fire("hover",[{data:r.dataAccessor(t),node:t}])})),this}).prototype=x(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(w,"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 h,d.add(this._aniloop),this._aniloop.on("tick",function(t,e){return i.tick(t,e)}),this.anim&&(this._aniloop.external=function(){return i.anim.manual()},this.anim.on("step",function(t,e){if(i._aniloop.isRunning())return i._aniloop.setTime(t),i._aniloop.render(e)})),Promise.resolve().then(function(){var t;return i.mod.config=y(i.mod.config||{},_.commonConfig),i._defcfg=t=g(i.mod.config),y(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;return 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?((e=x({},i.layoutOpt)).watchResize=!1,e):{root:n,watchResize:!1}))),t=proxise(function(){return m.add(i.root,i),null}),i._resize=function(){return t.resolve()},e=t(),(i.forceInit||!i.root.offsetParent||"none"===window.getComputedStyle(i.root).display||i.root.offsetWidth&&i.root.offsetHeight)&&t.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(){if(i._inited=!0,i._resize=function(){i.anim&&i.anim.immediate(!0);try{return i.resize(),i.render()}finally{i.anim&&i.anim.immediate(!1)}},i._layout=function(){return i.parse(),i.bind(),i.resize(),i.render()},i.parse(),i.bind(),i.resize(),i.render(),i._frames)return i._framesStart()})})},parse:function(){if(this.data=this._parseRows(this.raw),this._frames&&(this._frames.all=null),n.apply(this),this.mod.parse)return this.mod.parse.apply(this)},_parseRows:function(t){var l,e,h;return null==t&&(t=[]),l=(e=this.mod).dimension||(e.dimension={}),h=this.binding,t.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(a):e[o.key],/[RIT]/.exec(r.type)&&!/[CN]/.exec(r.type)&&(s[n]=Array.isArray(s[n])?s[n].map(u):f(s[n]))):r.multiple&&(s[n]=[]);return s._raw=e,s._idx=t,s;function a(t){return e[t.key]}function u(t){return f(t)}})},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(t,e){if(this.mod.tick)return this.mod.tick.apply(this,[t,e])},render:function(){if(this._inited)return this._syncAnim(),this.mod.render&&this.mod.render.apply(this),this._brushStyle(),this._empty(),this._anno()},_emptyText:function(){var t,e,n=((this.cfg||{}).common||{}).empty||{};return n.text||(n=_.i18nNs+":text",(t="undefined"!=typeof block&&null!==block&&block.i18n&&block.i18n.module?block.i18n.module:null)&&t.t&&(e=t.t(n))&&e!==n&&"text"!==e?e:(n=(t?t.language||t.lng:null)||("undefined"!=typeof document&&null!==document?document.documentElement.lang:"")||"en",(_.i18n[n]||_.i18n[n.split("-")[0]]||(/^zh/i.exec(n)?_.i18n[/cn|hans|sg/i.exec(n)?"zh-CN":"zh-TW"]:void 0)||_.i18n.en).text))},_empty:function(){var t,e=((this.cfg||{}).common||{}).empty||{},n=!(null!=e.enabled&&!e.enabled||(this.data||[]).length);if(this.svg){if(n)return this._emptyG||(this._emptyG=document.createElementNS(w,"g"),this._emptyG.setAttribute("data-type","empty"),this._emptyG.style.pointerEvents="none"),this.svg.appendChild(this._emptyG),this._emptyG.textContent="",n=this._annoBox(),(t=document.createElementNS(w,"text")).setAttribute("x",n.x+n.width/2),t.setAttribute("y",n.y+n.height/2),t.setAttribute("text-anchor","middle"),t.setAttribute("dominant-baseline","middle"),t.style.fill=e.color||"currentColor",t.style.opacity=null!=e.opacity?e.opacity:.45,(e.font||{}).size&&(t.style.fontSize=e.font.size+""),t.textContent=this._emptyText(),this._emptyG.appendChild(t);this._emptyG&&this._emptyG.parentNode&&this._emptyG.parentNode.removeChild(this._emptyG)}},_brushStyle:function(){var t,e,n,i,r,o=[],s=((this.cfg||{}).common||{}).brush||{};if(this.svg){for(t=function(t,e,n){if(null!=n&&""!==n)return t.setAttribute(e,n)},e=0,i=(n=this.svg.querySelectorAll("rect.selection")).length;e<i;++e)t(r=n[e],"fill",s.fill),t(r,"fill-opacity",s.fillOpacity),t(r,"stroke",s.stroke),t(r,"stroke-opacity",s.strokeOpacity),t(r,"stroke-width",s.strokeWidth);for(e=0,i=(n=this.svg.querySelectorAll("rect.handle")).length;e<i;++e)t(r=n[e],"fill",s.handleFill),o.push(t(r,"fill-opacity",s.handleOpacity));return o}},_annoBox:function(){var t;if(this.layout)try{if((t=this.layout.getBox("view"))&&t.width&&t.height)return t}catch(t){}return{x:0,y:0,width:(this.box||{}).width||0,height:(this.box||{}).height||0}},_anno:function(){var t,s,e,n,i,r,o,a,u,l,h,f,c,p,d=this,m=[],y=((this.cfg||{}).common||{}).annotation||{},g=null==y.enabled||!!y.enabled,_=g&&y.notes||[],b=g&&y.reference||[];if(this.svg){if(_.length||b.length){for(this._annoG||(this._annoG=document.createElementNS(w,"g"),this._annoG.setAttribute("data-type","annotation"),this._annoG.style.pointerEvents="none"),this.svg.appendChild(this._annoG),this._annoG.textContent="",t=this._annoBox(),s=y.font||{},e=function(t,e,n,i,r){var o=document.createElementNS(w,"text");return o.setAttribute("x",e),o.setAttribute("y",n),o.setAttribute("text-anchor",i),o.setAttribute("dominant-baseline",r),o.style.fill=t.color||y.color||"currentColor",(t.size||s.size)&&(o.style.fontSize=(t.size||s.size)+""),o.style.opacity=null!=t.opacity?t.opacity:null!=y.opacity?y.opacity:1,o.textContent=t.text+"",d._annoG.appendChild(o),o},n=0,i=_.length;n<i;++n)(r=_[n])&&null!=r.text&&e(r,t.x+t.width*(null!=r.x?r.x:.5),t.y+t.height*(null!=r.y?r.y:.5),r.align||"middle",r.baseline||"middle");for(n=0,i=b.length;n<i;++n)(o=b[n])&&(a="x"===o.axis?"x":"y",null==(u=v.call(this))||isNaN(u)||u<0||u>("y"===a?t.height:t.width)||(l=document.createElementNS(w,"line"),f=(h="y"===a?[t.x,t.y+u,t.x+t.width,t.y+u]:[t.x+u,t.y,t.x+u,t.y+t.height])[1],c=h[2],p=h[3],l.setAttribute("x1",h[0]),l.setAttribute("y1",f),l.setAttribute("x2",c),l.setAttribute("y2",p),x(l.style,{stroke:o.color||y.color||"currentColor",strokeWidth:null!=o.width?o.width:1,strokeDasharray:null!=o.dash?o.dash:"4 3",opacity:null!=o.opacity?o.opacity:null!=y.opacity?y.opacity:.6}),this._annoG.appendChild(l),null!=o.label&&(h="y"===a?[t.x+t.width-2,t.y+u-3,"end","auto"]:[t.x+u+3,t.y+2,"start","hanging"],m.push(e({text:o.label,color:o.color,size:o.size,opacity:o.opacity},h[0],h[1],h[2],h[3])))));return m}this._annoG&&this._annoG.parentNode&&this._annoG.parentNode.removeChild(this._annoG)}function v(){try{return this.space[a](o.value)}catch(t){return null}}},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),m.delete(t.root),t.layout&&t.layout.destroy(),t.pause(),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)y(t,arguments[e],this.mod.config);return y(t,this.cfg,this.mod.config),y(t,this._defcfg,this.mod.config),x(this.cfg,t)},_normalizeBinding:function(t){var e,n,i,r,o,s,a,u=[];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],a=Array.isArray(s),!o.multiple!=!a&&(o.multiple||a)&&u.push(this.binding[r]=a?s[0]:s?[s]:[]);return u},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),!t||Array.isArray(t)||o(t)||("subset"in t&&(this._subset=t.subset||null),t=(i=t).raw,e=i.binding,n=i.reinit),o(t)?(this._setFrames(t),t=(null!=(i=this._frames.list[this._frames.index])?i.raw:void 0)||[]):null!=t&&this._frames&&(this.pause(),this._frames=null,this._player.pos=0,this.anim)&&this.anim.resume(),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._frames?this._framesStart():void 0):this._pendingRaw=!0},_animCfg:function(){return((this.cfg||{}).common||{}).animation||{}},_syncAnim:function(){var t;if(this.anim)return null!=(t=this._animCfg()).transition&&this.anim.duration(t.transition),this.anim.speed(null!=t.speed?t.speed:1)},_setFrames:function(t){var e,t=i(t);return this._frames={list:t,index:0,all:null},this._frames.index=this._frameAt((t=this._player.pos)<(e=this.duration())?t:e)},_interval:function(){return+this._animCfg().interval||1e3},_clock:function(){return this.anim?this.anim.time():("undefined"!=typeof performance&&null!==performance?performance:Date).now()},_frameAt:function(t){var e=this._frames?this._frames.list.length:0;return e?(t=0<(t=Math.floor(t/this._interval()))?t:0)<(e=e-1)?t:e:0},_framesStart:function(){if(this.fire("frame",{index:this._frames.index,id:this.frame.id()}),this._animCfg().autoplay&&!this._player.playing)return this.play()},_goto:function(t,e){var n,i,r,o=this;if(null==e&&(e=0),(n=this._frames)&&n.list.length&&(t=(i=0<t?t:0)<(r=n.list.length-1)?i:r,n.index=t,this.raw=n.list[t].raw,this._inited))return this.parse(),this.bind(),this.resize(),this.anim&&0<e?this.anim.ago(e,function(){return o.render()}):this.render(),this.fire("frame",{index:t,id:n.list[t].id})},duration:function(){return this._frames?this._frames.list.length*this._interval():0},position:function(){var t=this._player;return t.playing?this._clock()-t.origin:t.pos},playing:function(){return this._player.playing},play:function(){var t=this._player;if(this._frames&&!t.playing&&this._frames.list.length)return t.pos>=this.duration()&&(t.pos=0),this._syncAnim(),this.anim&&this.anim.resume(),t.origin=this._clock()-t.pos,t.playing=!0,this.fire("play"),this._playerLoop()},pause:function(){var t=this._player;if(t.playing)return t.pos=this.position(),t.playing=!1,t.raf&&cancelAnimationFrame(t.raf),t.raf=null,this.anim&&this.anim.pause(),this.fire("pause")},seek:function(t){var e,n,i,r;if(this._frames&&this._frames.list.length)return r=this._interval(),n=(t=(i=0<(i=+(t=t&&"object"==typeof t?((t.frame||0)+(t.progress||0))*r:t)||0)?i:0)<(e=this.duration())?i:e)-(e=this._frameAt(t))*r,i=(i=+this._animCfg().transition||0)<r?i:r,0<e&&n<i?(this._goto(e-1),this.anim&&this.anim.flush(),this._goto(e,n)):(this._goto(e),this.anim&&this.anim.flush()),(r=this._player).pos=t,r.playing&&(r.origin=this._clock()-t),this.fire("progress",{time:t,duration:this.duration(),index:e})},_playerLoop:function(){var t,e=this,n=this._player;if(!n.raf&&"undefined"!=typeof requestAnimationFrame&&null!==requestAnimationFrame)return n.raf=requestAnimationFrame(t=function(){if(n.raf=null,n.playing)return e.anim&&e.anim.manual()||e._playerTick(),n.playing?n.raf=requestAnimationFrame(t):void 0})},_playerTick:function(){var t,e,n=this._player,i=this._frames;if(i&&i.list.length){if((t=this.duration())<=(e=this.position())){if(!this._animCfg().loop)return n.pos=t,n.playing=!1,this.fire("progress",{time:t,duration:t,index:i.index}),void this.fire("end");e%=t,n.origin=this._clock()-e}return(n=this._frameAt(e))!==i.index&&this._goto(n,e-n*this._interval()),this.fire("progress",{time:e,duration:t,index:n})}},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=[],a=1,u=arguments.length;a<u;++a)s.push(arguments[a]);for(e=s,a=0,i=(n=this.evtHandler[t]||[]).length;a<i;++a)r=n[a],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(a),n=n.concat(s);for(i in t)o=t[i],n.filter(u).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 a(t){return{k:i,v:t}}function u(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:{}}},filterDims:function(){var t;return(t=(this.mod||{}).filterDims)?t.call(this):(this.mod||{}).filter?["name"]:[]},canFilter:function(){return!!this.filterDims().length}}),_.commonConfig={common:{animation:{transition:{type:"number",default:350,min:0,max:5e3,step:10},interval:{type:"number",default:1e3,min:100,max:2e4,step:50},speed:{type:"number",default:1,min:.1,max:10,step:.1},loop:{type:"boolean",default:!0},autoplay:{type:"boolean",default:!0}},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},background:{type:"color",default:"transparent"}},empty:{enabled:{type:"boolean",default:!0},text:{type:"text",default:""},color:{type:"color",default:"currentColor"},opacity:{type:"number",default:.45,min:0,max:1,step:.05},font:{size:{type:"quantity",default:"",units:[{name:"em",max:10,step:.01,default:1}]}}},brush:{fill:{type:"color",default:""},fillOpacity:{type:"number",default:"",min:0,max:1,step:.05},stroke:{type:"color",default:""},strokeOpacity:{type:"number",default:"",min:0,max:1,step:.05},strokeWidth:{type:"number",default:"",min:0,max:20,step:.5},handleFill:{type:"color",default:""},handleOpacity:{type:"number",default:"",min:0,max:1,step:.05}},annotation:{enabled:{type:"boolean",default:!0},color:{type:"color",default:"currentColor"},opacity:{type:"number",default:1,min:0,max:1,step:.05},font:{size:{type:"quantity",default:".8em",units:[{name:"em",max:10,step:.01,default:.8}]}}}}},_.i18nNs="@plotdb/chart",_.i18n={en:{text:"No data to show"},"zh-TW":{text:"沒有可顯示的資料"},"zh-CN":{text:"没有可显示的数据"},ja:{text:"表示するデータがありません"}},_.scopes={space:{x:function(t){return null},y:function(t){return null}},frame:{active:function(){return!!this._frames},count:function(){return this._frames?this._frames.list.length:0},index:function(){return this._frames?this._frames.index:-1},id:function(t){return this._frames?(this._frames.list[null!=t?t:this._frames.index]||{}).id:null},ids:function(){return this._frames?this._frames.list.map(function(t){return t.id}):[]},all:function(){var t,e;return this._frames?null!=(e=(t=this._frames).all)?e:t.all=this._parseRows([].concat.apply([],this._frames.list.map(function(t){return t.raw}))):this._parseRows(this.raw)}},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,i,r,o;return(i=a(t))?(n=.3*i[0]+.59*i[1]+.11*i[2],i=((this.cfg||{}).common||{}).subset||{},r=null!=(r=null!=e?e:i.fade)?r:.72,o=a(i.background)||a((this.cfg||{}).background)||[255,255,255],"rgb("+[0,1,2].map(function(t){return Math.round(n+(o[t]-n)*r)}).join(",")+")"):t}}},_.dataframe={is:o,split:function(t,n){var i={},r=[];return(t=null==t?[]:t).map(function(t){var e=t[n]+"";return i[e]||r.push(i[e]={id:t[n],raw:[]}),i[e].raw.push(t)}),{frames:r}}},"undefined"!=typeof module&&null!==module?module.exports=_:"undefined"!=typeof window&&null!==window&&(window.chart=_)}.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.
|
|
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.13.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","verify":"node tools/verify/shape-test.js && node tools/verify/scale-test.js"},"devDependencies":{"@loadingio/bootstrap.ext":"^0.0.12","@loadingio/ldcolorpicker":"^3.0.6","@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","@zbryikt/voronoijs":"^1.0.0","bootstrap":"^4.6.1","bootstrap.native":"^3.0.15","choosefont.js":"^0.0.1","d3":"^7.9.2","d3-force-boundary":"^0.0.2","fedep":"^1.9.0","jsdom":"^22.1.0","ldbutton":"^2.0.5","ldcover":"^3.6.1","ldfile":"^2.0.1","ldiconfont":"^0.2.8","ldloader":"^3.0.3","ldpalettepicker":"^4.1.4","ldslider":"^3.2.0","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","@plotdb/block":"^5.2.2","@plotdb/csscope":"^5.0.3","@plotdb/konfig":"^4.8.12","@plotdb/rescope":"^5.0.9","ldcolor":"^1.1.3","proxise":"^1.0.1","wrap-svg-text":"^0.0.7"}}
|
package/utils/axis.js
CHANGED
|
@@ -147,7 +147,7 @@
|
|
|
147
147
|
var map, size, unit, count, itr, ref$, ends, k, v, this$ = this;
|
|
148
148
|
map = {};
|
|
149
149
|
size = this._n.layout.getBoundingClientRect()[this.dir < 2 ? 'width' : 'height'];
|
|
150
|
-
unit = this.dir < 2 && this.cfg.label.direction
|
|
150
|
+
unit = this.dir < 2 && this.cfg.label.direction !== 'horizontal' ? 12 : 25;
|
|
151
151
|
count = Math.round(size / unit);
|
|
152
152
|
itr = (ref$ = Math.round(ticks.length / (count > 1 ? count : 1))) > 1 ? ref$ : 1;
|
|
153
153
|
ends = this.cfg.label.strategy === 'ends';
|
|
@@ -290,13 +290,30 @@
|
|
|
290
290
|
return this.adjust();
|
|
291
291
|
},
|
|
292
292
|
adjust: function(){
|
|
293
|
-
var ticks, isHorizon,
|
|
293
|
+
var ticks, isHorizon, em, gap, fits, place, modes, allIdx, res$, i$, to$, i, len$, mode, sel, k, tol, ref$, lo, hi, pick, even, p, idx, picked, shown, mm3, md3, size, delta, box, xoff, yoff, this$ = this;
|
|
294
294
|
ticks = this._ticks;
|
|
295
295
|
isHorizon = this.dir < 2;
|
|
296
|
-
vertical = isHorizon && this.cfg.label.direction === 'vertical';
|
|
297
296
|
em = parseFloat(getComputedStyle(this._n.wrap).fontSize) || 16;
|
|
298
|
-
|
|
299
|
-
|
|
297
|
+
gap = em * (this.cfg.label.gap != null ? this.cfg.label.gap : 1.5);
|
|
298
|
+
fits = function(idx){
|
|
299
|
+
var prev, i$, len$, i, tick;
|
|
300
|
+
prev = null;
|
|
301
|
+
for (i$ = 0, len$ = idx.length; i$ < len$; ++i$) {
|
|
302
|
+
i = idx[i$];
|
|
303
|
+
tick = ticks[i];
|
|
304
|
+
if (prev != null && tick._start - (prev._start + prev._size) < gap) {
|
|
305
|
+
return false;
|
|
306
|
+
}
|
|
307
|
+
prev = tick;
|
|
308
|
+
}
|
|
309
|
+
return true;
|
|
310
|
+
};
|
|
311
|
+
place = function(tick, idx, mode){
|
|
312
|
+
var vertical, angled, ang, ref$, cos, sin, pos, coord, box, offset, doOffset, r, toff;
|
|
313
|
+
vertical = isHorizon && mode === 'vertical';
|
|
314
|
+
angled = isHorizon && mode === 'angled';
|
|
315
|
+
ang = this$.cfg.label.angle != null ? this$.cfg.label.angle : 45;
|
|
316
|
+
ref$ = [Math.cos(ang * Math.PI / 180), Math.sin(ang * Math.PI / 180)], cos = ref$[0], sin = ref$[1];
|
|
300
317
|
pos = !idx
|
|
301
318
|
? 0
|
|
302
319
|
: idx === ticks.length - 1 ? 2 : 1;
|
|
@@ -319,6 +336,8 @@
|
|
|
319
336
|
if (vertical) {
|
|
320
337
|
offset.x -= box.width;
|
|
321
338
|
offset.y -= box.height * r;
|
|
339
|
+
} else if (angled) {
|
|
340
|
+
offset.x -= box.width;
|
|
322
341
|
} else if (isHorizon) {
|
|
323
342
|
offset.x -= box.width * r;
|
|
324
343
|
} else {
|
|
@@ -327,16 +346,24 @@
|
|
|
327
346
|
tick.n.tt.setAttribute('transform', "translate(" + offset.x + "," + offset.y + ")");
|
|
328
347
|
tick._size = vertical
|
|
329
348
|
? box.height
|
|
330
|
-
:
|
|
349
|
+
: angled
|
|
350
|
+
? box.width * cos + box.height * sin
|
|
351
|
+
: box[isHorizon ? 'width' : 'height'];
|
|
331
352
|
tick._sizeAlt = vertical
|
|
332
353
|
? box.width
|
|
333
|
-
:
|
|
334
|
-
|
|
354
|
+
: angled
|
|
355
|
+
? box.width * sin + box.height * cos
|
|
356
|
+
: box[isHorizon ? 'height' : 'width'];
|
|
357
|
+
tick._start = angled
|
|
358
|
+
? coord - box.width * cos
|
|
359
|
+
: coord - tick._size * r;
|
|
335
360
|
if (isHorizon) {
|
|
336
361
|
tick.n.g.setAttribute('transform', "translate(" + coord + ",0)");
|
|
337
362
|
tick.n.p.setAttribute('d', "M0 0L0 " + this$.cfg.tick.inner);
|
|
338
363
|
toff = this$.cfg.tick.inner + this$.cfg.label.padding;
|
|
339
|
-
tick.n.t.setAttribute('transform', ("translate(0," + toff + ")") + (vertical
|
|
364
|
+
tick.n.t.setAttribute('transform', ("translate(0," + toff + ")") + (vertical
|
|
365
|
+
? " rotate(-90)"
|
|
366
|
+
: angled ? " rotate(" + (-ang) + ")" : ""));
|
|
340
367
|
} else {
|
|
341
368
|
tick.n.g.setAttribute('transform', "translate(0," + coord + ")");
|
|
342
369
|
tick.n.p.setAttribute('d', "M0 0L-" + this$.cfg.tick.inner + " 0");
|
|
@@ -344,26 +371,27 @@
|
|
|
344
371
|
}
|
|
345
372
|
return tick.n.p.style.stroke = this$.cfg.tick.color || '';
|
|
346
373
|
};
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
374
|
+
modes = isHorizon && this.cfg.label.direction === 'auto'
|
|
375
|
+
? ['horizontal', 'angled', 'vertical']
|
|
376
|
+
: [this.cfg.label.direction || 'horizontal'];
|
|
377
|
+
res$ = [];
|
|
378
|
+
for (i$ = 0, to$ = ticks.length; i$ < to$; ++i$) {
|
|
379
|
+
i = i$;
|
|
380
|
+
res$.push(i);
|
|
381
|
+
}
|
|
382
|
+
allIdx = res$;
|
|
383
|
+
for (i$ = 0, len$ = modes.length; i$ < len$; ++i$) {
|
|
384
|
+
mode = modes[i$];
|
|
385
|
+
ticks.map(fn$);
|
|
386
|
+
if (fits(allIdx)) {
|
|
387
|
+
break;
|
|
359
388
|
}
|
|
360
|
-
|
|
361
|
-
};
|
|
389
|
+
}
|
|
362
390
|
sel = [0];
|
|
363
391
|
if (ticks.length > 1) {
|
|
364
392
|
if (this.cfg.label.strategy !== 'ends') {
|
|
365
393
|
k = 1;
|
|
366
|
-
while (k < ticks.length && !fits((
|
|
394
|
+
while (k < ticks.length && !fits((fn1$()))) {
|
|
367
395
|
k++;
|
|
368
396
|
}
|
|
369
397
|
res$ = [];
|
|
@@ -482,7 +510,10 @@
|
|
|
482
510
|
return n.setAttribute('transform', "translate(" + xoff + "," + yoff + ") rotate(90)");
|
|
483
511
|
});
|
|
484
512
|
}
|
|
485
|
-
function fn$(){
|
|
513
|
+
function fn$(tick, i){
|
|
514
|
+
return place(tick, i, mode);
|
|
515
|
+
}
|
|
516
|
+
function fn1$(){
|
|
486
517
|
var i$, step$, to$, results$ = [];
|
|
487
518
|
for (i$ = 0, to$ = ticks.length, step$ = k; step$ < 0 ? i$ > to$ : i$ < to$; i$ += step$) {
|
|
488
519
|
i = i$;
|