@plotdb/chart 3.7.0 → 3.8.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/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  (function(){
2
- var svgns, _np, _nparse, _snum, _isNumeric, _alignDim, _parseSubset, _rgb, bindScope, parent, aniloop, visibilityObserver, resizeObserver, withDefault, defaultConfig, chart;
2
+ var svgns, _np, _nparse, _snum, _isNumeric, _alignDim, _parseSubset, _isDataframe, _isNum, _isDate, _frameList, _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;
@@ -146,6 +146,75 @@
146
146
  });
147
147
  }
148
148
  };
149
+ _isDataframe = function(o){
150
+ return !!(o && !Array.isArray(o) && Array.isArray(o.frames));
151
+ };
152
+ _isNum = function(v){
153
+ return typeof v === 'number' || (typeof v === 'string' && v.trim() && !isNaN(+v));
154
+ };
155
+ _isDate = function(v){
156
+ return v instanceof Date || (typeof v === 'string' && !isNaN(Date.parse(v)));
157
+ };
158
+ _frameList = function(df){
159
+ var list, order, hash, ret, ids, t;
160
+ df == null && (df = {});
161
+ list = (df.frames || []).map(function(f, i){
162
+ return {
163
+ id: f.id != null ? f.id : i,
164
+ raw: f.raw || []
165
+ };
166
+ });
167
+ order = df.frameOrder;
168
+ if (Array.isArray(order) && order.length) {
169
+ hash = {};
170
+ list.map(function(f){
171
+ return hash[f.id + ""] = f;
172
+ });
173
+ ret = order.map(function(it){
174
+ return hash[it + ""];
175
+ }).filter(function(it){
176
+ return it;
177
+ });
178
+ return ret.concat(list.filter(function(it){
179
+ return !in$(it, ret);
180
+ }));
181
+ }
182
+ ids = list.map(function(it){
183
+ return it.id;
184
+ });
185
+ if (ids.length && ids.every(_isNum)) {
186
+ return list.map(function(f, i){
187
+ return {
188
+ f: f,
189
+ i: i
190
+ };
191
+ }).sort(function(a, b){
192
+ return +a.f.id - +b.f.id || a.i - b.i;
193
+ }).map(function(it){
194
+ return it.f;
195
+ });
196
+ }
197
+ if (ids.length && ids.every(_isDate)) {
198
+ t = function(v){
199
+ if (v instanceof Date) {
200
+ return v.getTime();
201
+ } else {
202
+ return Date.parse(v);
203
+ }
204
+ };
205
+ return list.map(function(f, i){
206
+ return {
207
+ f: f,
208
+ i: i
209
+ };
210
+ }).sort(function(a, b){
211
+ return t(a.f.id) - t(b.f.id) || a.i - b.i;
212
+ }).map(function(it){
213
+ return it.f;
214
+ });
215
+ }
216
+ return list;
217
+ };
149
218
  _rgb = function(c){
150
219
  var m, x, v;
151
220
  if (typeof c !== 'string') {
@@ -406,7 +475,7 @@
406
475
  return _(cfg);
407
476
  };
408
477
  chart = function(opt){
409
- var name, ref$, tbl, this$ = this;
478
+ var ref$, name, ref1$, tbl, this$ = this;
410
479
  opt == null && (opt = {});
411
480
  this.root = typeof opt.root === 'string'
412
481
  ? document.querySelector(opt.root)
@@ -435,8 +504,19 @@
435
504
  this._normalizeBinding();
436
505
  this.evtHandler = {};
437
506
  this._subset = opt.subset || null;
438
- for (name in ref$ = chart.scopes) {
439
- tbl = ref$[name];
507
+ this._frames = null;
508
+ this._player = {
509
+ playing: false,
510
+ pos: 0,
511
+ origin: 0,
512
+ raf: null
513
+ };
514
+ if (_isDataframe(this.raw)) {
515
+ this._setFrames(this.raw);
516
+ this.raw = ((ref$ = this._frames.list[this._frames.index]) != null ? ref$.raw : void 8) || [];
517
+ }
518
+ for (name in ref1$ = chart.scopes) {
519
+ tbl = ref1$[name];
440
520
  if (this[name] != null) {
441
521
  throw new Error("[@plotdb/chart] scope name `" + name + "` is already taken.");
442
522
  }
@@ -449,6 +529,13 @@
449
529
  if ((chart.utils || (chart.utils = {})).anim && !(this.anim != null)) {
450
530
  this.anim = new chart.utils.anim();
451
531
  }
532
+ if (this.anim) {
533
+ this.anim.on('step', function(){
534
+ if (this$._player.playing) {
535
+ return this$._playerTick();
536
+ }
537
+ });
538
+ }
452
539
  this.init = proxise.once(function(){
453
540
  return this$._init();
454
541
  });
@@ -622,15 +709,29 @@
622
709
  this$.parse();
623
710
  this$.bind();
624
711
  this$.resize();
625
- return this$.render();
712
+ this$.render();
713
+ if (this$._frames) {
714
+ return this$._framesStart();
715
+ }
626
716
  });
627
717
  });
628
718
  },
629
719
  parse: function(){
720
+ this.data = this._parseRows(this.raw);
721
+ if (this._frames) {
722
+ this._frames.all = null;
723
+ }
724
+ _parseSubset.apply(this);
725
+ if (this.mod.parse) {
726
+ return this.mod.parse.apply(this);
727
+ }
728
+ },
729
+ _parseRows: function(rows){
630
730
  var dim, ref$, bind;
731
+ rows == null && (rows = []);
631
732
  dim = (ref$ = this.mod).dimension || (ref$.dimension = {});
632
733
  bind = this.binding;
633
- this.data = this.raw.map(function(r, i){
734
+ return rows.map(function(r, i){
634
735
  var ret, k, ref$, v, b;
635
736
  ret = {};
636
737
  for (k in ref$ = dim) {
@@ -662,10 +763,6 @@
662
763
  return _nparse(it);
663
764
  }
664
765
  });
665
- _parseSubset.apply(this);
666
- if (this.mod.parse) {
667
- return this.mod.parse.apply(this);
668
- }
669
766
  },
670
767
  bind: function(){
671
768
  if (this.mod.bind) {
@@ -705,6 +802,7 @@
705
802
  if (!this._inited) {
706
803
  return;
707
804
  }
805
+ this._syncAnim();
708
806
  if (this.mod.render) {
709
807
  return this.mod.render.apply(this);
710
808
  }
@@ -722,6 +820,7 @@
722
820
  if (this$.layout) {
723
821
  this$.layout.destroy();
724
822
  }
823
+ this$.pause();
725
824
  this$.stop();
726
825
  if (this$.mod.destroy) {
727
826
  return this$.mod.destroy.apply(this$);
@@ -783,12 +882,23 @@
783
882
  setRaw: function(raw, binding, reinit){
784
883
  var ref$;
785
884
  reinit == null && (reinit = false);
786
- if (!Array.isArray(raw)) {
787
- if (raw && 'subset' in raw) {
885
+ if (raw && !Array.isArray(raw) && !_isDataframe(raw)) {
886
+ if ('subset' in raw) {
788
887
  this._subset = raw.subset || null;
789
888
  }
790
889
  ref$ = raw, raw = ref$.raw, binding = ref$.binding, reinit = ref$.reinit;
791
890
  }
891
+ if (_isDataframe(raw)) {
892
+ this._setFrames(raw);
893
+ raw = ((ref$ = this._frames.list[this._frames.index]) != null ? ref$.raw : void 8) || [];
894
+ } else if (raw != null && this._frames) {
895
+ this.pause();
896
+ this._frames = null;
897
+ this._player.pos = 0;
898
+ if (this.anim) {
899
+ this.anim.resume();
900
+ }
901
+ }
792
902
  if (raw != null) {
793
903
  this.raw = raw;
794
904
  }
@@ -808,9 +918,240 @@
808
918
  this.parse();
809
919
  this.bind();
810
920
  this.resize();
811
- return this.render();
921
+ this.render();
922
+ if (this._frames) {
923
+ return this._framesStart();
924
+ }
925
+ }
926
+ },
927
+ _animCfg: function(){
928
+ return ((this.cfg || {}).common || {}).animation || {};
929
+ },
930
+ _syncAnim: function(){
931
+ var c;
932
+ if (!this.anim) {
933
+ return;
934
+ }
935
+ c = this._animCfg();
936
+ if (c.transition != null) {
937
+ this.anim.duration(c.transition);
938
+ }
939
+ return this.anim.speed(c.speed != null ? c.speed : 1);
940
+ },
941
+ _setFrames: function(df){
942
+ var list, ref$, ref1$;
943
+ list = _frameList(df);
944
+ this._frames = {
945
+ list: list,
946
+ index: 0,
947
+ all: null
948
+ };
949
+ return this._frames.index = this._frameAt((ref$ = this._player.pos) < (ref1$ = this.duration()) ? ref$ : ref1$);
950
+ },
951
+ _interval: function(){
952
+ return +this._animCfg().interval || 1000;
953
+ },
954
+ _clock: function(){
955
+ if (this.anim) {
956
+ return this.anim.time();
957
+ } else {
958
+ if (typeof performance != 'undefined' && performance !== null) {
959
+ return performance.now();
960
+ } else {
961
+ return Date.now();
962
+ }
812
963
  }
813
964
  },
965
+ _frameAt: function(t){
966
+ var n, ref$, ref1$, ref2$;
967
+ n = this._frames ? this._frames.list.length : 0;
968
+ if (!n) {
969
+ return 0;
970
+ }
971
+ return (ref$ = (ref2$ = Math.floor(t / this._interval())) > 0 ? ref2$ : 0) < (ref1$ = n - 1) ? ref$ : ref1$;
972
+ },
973
+ _framesStart: function(){
974
+ this.fire('frame', {
975
+ index: this._frames.index,
976
+ id: this.frame.id()
977
+ });
978
+ if (this._animCfg().autoplay && !this._player.playing) {
979
+ return this.play();
980
+ }
981
+ },
982
+ _goto: function(i, late){
983
+ var f, ref$, ref1$, this$ = this;
984
+ late == null && (late = 0);
985
+ f = this._frames;
986
+ if (!f || !f.list.length) {
987
+ return;
988
+ }
989
+ i = (ref$ = i > 0 ? i : 0) < (ref1$ = f.list.length - 1) ? ref$ : ref1$;
990
+ f.index = i;
991
+ this.raw = f.list[i].raw;
992
+ if (!this._inited) {
993
+ return;
994
+ }
995
+ this.parse();
996
+ this.bind();
997
+ this.resize();
998
+ if (this.anim && late > 0) {
999
+ this.anim.ago(late, function(){
1000
+ return this$.render();
1001
+ });
1002
+ } else {
1003
+ this.render();
1004
+ }
1005
+ return this.fire('frame', {
1006
+ index: i,
1007
+ id: f.list[i].id
1008
+ });
1009
+ },
1010
+ duration: function(){
1011
+ if (this._frames) {
1012
+ return this._frames.list.length * this._interval();
1013
+ } else {
1014
+ return 0;
1015
+ }
1016
+ },
1017
+ position: function(){
1018
+ var p;
1019
+ p = this._player;
1020
+ if (p.playing) {
1021
+ return this._clock() - p.origin;
1022
+ } else {
1023
+ return p.pos;
1024
+ }
1025
+ },
1026
+ playing: function(){
1027
+ return this._player.playing;
1028
+ },
1029
+ play: function(){
1030
+ var p;
1031
+ p = this._player;
1032
+ if (!this._frames || p.playing || !this._frames.list.length) {
1033
+ return;
1034
+ }
1035
+ if (p.pos >= this.duration()) {
1036
+ p.pos = 0;
1037
+ }
1038
+ this._syncAnim();
1039
+ if (this.anim) {
1040
+ this.anim.resume();
1041
+ }
1042
+ p.origin = this._clock() - p.pos;
1043
+ p.playing = true;
1044
+ this.fire('play');
1045
+ return this._playerLoop();
1046
+ },
1047
+ pause: function(){
1048
+ var p;
1049
+ p = this._player;
1050
+ if (!p.playing) {
1051
+ return;
1052
+ }
1053
+ p.pos = this.position();
1054
+ p.playing = false;
1055
+ if (p.raf) {
1056
+ cancelAnimationFrame(p.raf);
1057
+ }
1058
+ p.raf = null;
1059
+ if (this.anim) {
1060
+ this.anim.pause();
1061
+ }
1062
+ return this.fire('pause');
1063
+ },
1064
+ seek: function(t){
1065
+ var iv, ref$, ref1$, ref2$, i, late, tr, p;
1066
+ if (!this._frames || !this._frames.list.length) {
1067
+ return;
1068
+ }
1069
+ iv = this._interval();
1070
+ if (t && typeof t === 'object') {
1071
+ t = ((t.frame || 0) + (t.progress || 0)) * iv;
1072
+ }
1073
+ t = (ref$ = (ref2$ = +t || 0) > 0 ? ref2$ : 0) < (ref1$ = this.duration()) ? ref$ : ref1$;
1074
+ i = this._frameAt(t);
1075
+ late = t - i * iv;
1076
+ tr = (ref$ = +this._animCfg().transition || 0) < iv ? ref$ : iv;
1077
+ if (i > 0 && late < tr) {
1078
+ this._goto(i - 1);
1079
+ if (this.anim) {
1080
+ this.anim.flush();
1081
+ }
1082
+ this._goto(i, late);
1083
+ } else {
1084
+ this._goto(i);
1085
+ if (this.anim) {
1086
+ this.anim.flush();
1087
+ }
1088
+ }
1089
+ p = this._player;
1090
+ p.pos = t;
1091
+ if (p.playing) {
1092
+ p.origin = this._clock() - t;
1093
+ }
1094
+ return this.fire('progress', {
1095
+ time: t,
1096
+ duration: this.duration(),
1097
+ index: i
1098
+ });
1099
+ },
1100
+ _playerLoop: function(){
1101
+ var p, step, this$ = this;
1102
+ p = this._player;
1103
+ if (p.raf || !(typeof requestAnimationFrame != 'undefined' && requestAnimationFrame !== null)) {
1104
+ return;
1105
+ }
1106
+ step = function(){
1107
+ p.raf = null;
1108
+ if (!p.playing) {
1109
+ return;
1110
+ }
1111
+ if (!(this$.anim && this$.anim.manual())) {
1112
+ this$._playerTick();
1113
+ }
1114
+ if (p.playing) {
1115
+ return p.raf = requestAnimationFrame(step);
1116
+ }
1117
+ };
1118
+ return p.raf = requestAnimationFrame(step);
1119
+ },
1120
+ _playerTick: function(){
1121
+ var p, f, dur, t, i;
1122
+ p = this._player;
1123
+ f = this._frames;
1124
+ if (!f || !f.list.length) {
1125
+ return;
1126
+ }
1127
+ dur = this.duration();
1128
+ t = this.position();
1129
+ if (t >= dur) {
1130
+ if (this._animCfg().loop) {
1131
+ t = t % dur;
1132
+ p.origin = this._clock() - t;
1133
+ } else {
1134
+ p.pos = dur;
1135
+ p.playing = false;
1136
+ this.fire('progress', {
1137
+ time: dur,
1138
+ duration: dur,
1139
+ index: f.index
1140
+ });
1141
+ this.fire('end');
1142
+ return;
1143
+ }
1144
+ }
1145
+ i = this._frameAt(t);
1146
+ if (i !== f.index) {
1147
+ this._goto(i, t - i * this._interval());
1148
+ }
1149
+ return this.fire('progress', {
1150
+ time: t,
1151
+ duration: dur,
1152
+ index: i
1153
+ });
1154
+ },
814
1155
  on: function(n, cb){
815
1156
  var this$ = this;
816
1157
  return (Array.isArray(n)
@@ -899,6 +1240,37 @@
899
1240
  });
900
1241
  chart.commonConfig = {
901
1242
  common: {
1243
+ animation: {
1244
+ transition: {
1245
+ type: 'number',
1246
+ 'default': 350,
1247
+ min: 0,
1248
+ max: 5000,
1249
+ step: 10
1250
+ },
1251
+ interval: {
1252
+ type: 'number',
1253
+ 'default': 1000,
1254
+ min: 100,
1255
+ max: 20000,
1256
+ step: 50
1257
+ },
1258
+ speed: {
1259
+ type: 'number',
1260
+ 'default': 1,
1261
+ min: 0.1,
1262
+ max: 10,
1263
+ step: 0.1
1264
+ },
1265
+ loop: {
1266
+ type: 'boolean',
1267
+ 'default': true
1268
+ },
1269
+ autoplay: {
1270
+ type: 'boolean',
1271
+ 'default': true
1272
+ }
1273
+ },
902
1274
  subset: {
903
1275
  mode: {
904
1276
  type: 'choice',
@@ -923,6 +1295,53 @@
923
1295
  }
924
1296
  };
925
1297
  chart.scopes = {
1298
+ frame: {
1299
+ active: function(){
1300
+ return !!this._frames;
1301
+ },
1302
+ count: function(){
1303
+ if (this._frames) {
1304
+ return this._frames.list.length;
1305
+ } else {
1306
+ return 0;
1307
+ }
1308
+ },
1309
+ index: function(){
1310
+ if (this._frames) {
1311
+ return this._frames.index;
1312
+ } else {
1313
+ return -1;
1314
+ }
1315
+ },
1316
+ id: function(i){
1317
+ if (!this._frames) {
1318
+ return null;
1319
+ }
1320
+ return (this._frames.list[i != null
1321
+ ? i
1322
+ : this._frames.index] || {}).id;
1323
+ },
1324
+ ids: function(){
1325
+ if (this._frames) {
1326
+ return this._frames.list.map(function(it){
1327
+ return it.id;
1328
+ });
1329
+ } else {
1330
+ return [];
1331
+ }
1332
+ },
1333
+ all: function(){
1334
+ var ref$, ref1$;
1335
+ if (!this._frames) {
1336
+ return this._parseRows(this.raw);
1337
+ }
1338
+ return (ref1$ = (ref$ = this._frames).all) != null
1339
+ ? ref1$
1340
+ : ref$.all = this._parseRows([].concat.apply([], this._frames.list.map(function(it){
1341
+ return it.raw;
1342
+ })));
1343
+ }
1344
+ },
926
1345
  subset: {
927
1346
  set: function(raw){
928
1347
  this._subset = raw || null;
@@ -972,6 +1391,29 @@
972
1391
  }
973
1392
  }
974
1393
  };
1394
+ chart.dataframe = {
1395
+ is: _isDataframe,
1396
+ split: function(raw, key){
1397
+ var hash, frames;
1398
+ raw == null && (raw = []);
1399
+ hash = {};
1400
+ frames = [];
1401
+ raw.map(function(r){
1402
+ var k;
1403
+ k = r[key] + "";
1404
+ if (!hash[k]) {
1405
+ frames.push(hash[k] = {
1406
+ id: r[key],
1407
+ raw: []
1408
+ });
1409
+ }
1410
+ return hash[k].raw.push(r);
1411
+ });
1412
+ return {
1413
+ frames: frames
1414
+ };
1415
+ }
1416
+ };
975
1417
  if (typeof module != 'undefined' && module !== null) {
976
1418
  module.exports = chart;
977
1419
  } else if (typeof window != 'undefined' && window !== null) {
@@ -1061,6 +1503,11 @@
1061
1503
  return result;
1062
1504
  }
1063
1505
  }
1506
+ function in$(x, xs){
1507
+ var i = -1, l = xs.length >>> 0;
1508
+ while (++i < l) if (x === xs[i]) return true;
1509
+ return false;
1510
+ }
1064
1511
  function import$(obj, src){
1065
1512
  var own = {}.hasOwnProperty;
1066
1513
  for (var key in src) if (own.call(src, key)) obj[key] = src[key];
package/index.min.js CHANGED
@@ -1 +1 @@
1
- !function(){var n,c,f,d,t,e,i,o,s,r,u,a,l,h,p;function m(t,n,f){function d(t,n){return e.call(t,n)}var p={}.toString,e={}.hasOwnProperty,m=!0;return function t(n,e,i){var r,o,s,u,a,l,h,c;if(null==n||null==e)return n===e;if(n.__placeholder__||e.__placeholder__)return!0;if(n===e)return 0!==n||1/n==1/e;r=p.call(n);if(p.call(e)!=r)return!1;switch(r){case"[object String]":return n==String(e);case"[object Number]":return n!=+n?e!=+e:0==n?1/n==1/e:n==+e;case"[object Date]":case"[object Boolean]":return+n==+e;case"[object RegExp]":return n.source==e.source&&n.global==e.global&&n.multiline==e.multiline&&n.ignoreCase==e.ignoreCase}if("object"!=typeof n||"object"!=typeof e)return!1;o=i.length;for(;o--;)if(i[o]==n)return!0;i.push(n);s=0;u=!0;if("[object Array]"==r){if(a=n.length,l=e.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 n==s in e&&t(n[s],e[s],i)););}else{if("constructor"in n!="constructor"in e||n.constructor!=e.constructor)return!1;for(h in n)if(d(n,h)&&(s++,!(u=d(e,h)&&t(n[h],e[h],i))))break;if(u){for(h in c=0,e)d(e,h)&&++c;u=m?"<<="===f?s<c:"<=="===f?s<=c:s===c:(m=!1,s===c)}}i.pop();return u}(t,n,[])}function y(t,n){var e,i={}.hasOwnProperty;for(e in n)i.call(n,e)&&(t[e]=n[e]);return t}n=new function(t){var e=new Intl.NumberFormat(t),t=e.formatToParts(12345.6),n=Array.from({length:10}).map(function(t,n){return e.format(n)}),i=new Map(n.map(function(t,n){return[t,n]}));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("["+n.join("")+"]","g"),this._index=function(t){return i.get(t)},this}("en-US"),c=function(t){return(t=((t=null==t?"":t)+"").trim().replace(n._group,"").replace(n._decimal,".").replace(n._numeral,n._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(n){var t,e,i,r,o,s=[];for(e in n=null==n?{}:n)s.push(e);for(t=s,i=0,o=(r=["name","order"]).length;i<o;++i)if(n[e=r[i]]&&!d(n[e]))return e;return t.filter(function(t){return!d(n[t])})[0]},e=function(){var a,l,h,u=this,c=(this.mod||{}).dimension||{};if(this._subset)return a=t(c),l=this._subset.map(function(n){var t,e,i,r,o={};for(t in e=c)i=e[t],(r=u.binding[t])&&(o[t]=i.multiple?(r.map?r:[r]).map(s):n[r.key],d(i))&&(o[t]=Array.isArray(o[t])?o[t].map(f):f(o[t]));return o;function s(t){return n[t.key]}}),h={},a&&l.map(function(t){return h[t[a]+""]=t}),this.data.map(function(t,n){var e,i,r,o=a?h[t[a]+""]:l[n],s={};for(e in i=c)r=i[e],d(r)&&(s[e]=r.multiple?(t[e]||[]).map(u):o?f(o[e]):0);return t.subset=s;function u(t,n){return o?f((o[e]||[])[n]):0}}),"shrink"===(((this.cfg||{}).common||{}).subset||{}).mode?this.data.map(function(t){var n,e,i,r=[];for(n in e=c)i=e[n],d(i)&&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})},i=function(t){var n,e;if("string"!=typeof t)return null;if(t=t.trim(),n=/^#([0-9a-f]{3})$/i.exec(t)){for(var i,r=[],o=0,s=(i=n[1].split("")).length;o<s;++o)e=i[o],r.push(parseInt(e+e,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},o=function(t,n,e){var i,r,o,s;for(r in null==e&&(e={}),i={},o=y(y({},n=null==n?{}:n),e||{}))s=o[r],i[r]="function"==typeof s?s.bind(t):s;return i},s=function(t,n,e){for(var i=t;t&&t!==e;)t=t.parentNode;if(t!==e)return null;if(!n)return t;for(t=i;t&&t!==e&&(!t.matches||(t.matches,!t.matches(n)));)t=t.parentNode;return t!==e||e.matches&&e.matches(n)?t:null},(r=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,e){var i=this;return(Array.isArray(t)?t:[t]).map(function(t){var n;return((n=i.evtHandler)[t]||(n[t]=[])).push(e)})},fire:function(t){for(var n,e,i,r,o=[],s=[],u=1,a=arguments.length;u<a;++u)s.push(arguments[u]);for(n=s,u=0,i=(e=this.evtHandler[t]||[]).length;u<i;++u)r=e[u],o.push(r.apply(this,n));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 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 e,i,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,e=this.isThrottled?1e3<(e=this._fps_delay)?e:1e3:this._fps_delay,(n||(i=this.time.now-this.time.last)>=e)&&(this.time.last=t,this.render(n?0:i)),requestAnimationFrame(function(t){return r.handler(t,!1)}))}}),u={list:[],init:function(){var t,e,i=this;return this.inited=!0,t=null==document.hidden&&null==document.msHidden&&null!=document.webkiHidden?["webkitHidden","webkitvisibilitychange"]:["hidden","visibilitychange"],e=t[0],document.addEventListener(t[1],debounce(150,function(){var n=!!document[e];return i.list.map(function(t){return t.throttle(n)})},!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,n){return this.wm.set(t,n),this.ro.observe(t)},delete:function(t){return this.ro.unobserve(t),this.wm.delete(t)}},l=function(t,n,e){return null==n&&(n={}),null==e&&(e={}),function(t,n,e){var i,r;for(i in n)r=n[i],null==t[i]?t[i]=r:"object"!=typeof t[i]||"object"!=typeof r||e[i]&&e[i].type||l(t[i],n[i],e[i]);return t}(t=null==t?{}:t,n=JSON.parse(JSON.stringify(n)),e)},h=function(t){var r=function(t,n){var e,i;for(e in null==n&&(n={}),t.child,t)(i=t[e]).type?i.default&&(n[e]=i.default):r(i,n[e]||(n[e]={}));return n};return r(t)},(p=function(t){var n,e,i,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,e=p.scopes){if(i=e[n],null!=this[n])throw new Error("[@plotdb/chart] scope name `"+n+"` is already taken.");this[n]=o(this,i,this.mod[n])}if(null!=this.local)throw new Error("[@plotdb/chart] scope name `local` is already taken.");return this.local=o(this,{},this.mod.local),(p.utils||(p.utils={})).anim&&null==this.anim&&(this.anim=new p.utils.anim),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=s(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=s(t.target,".data",r.root))return r.fire("hover",[{data:r.dataAccessor(t),node:t}])})),this}).prototype=y(Object.create(Object.prototype),{_init:function(){var e,t,n,i=this;return"static"===window.getComputedStyle(this.root).position&&(this.root.style.position="relative"),e=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||(e||console.error("[@plotdb/chart] layout enabled yet layout root isn't configured properly. "),n=e.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 r,u.add(this._aniloop),this._aniloop.on("tick",function(t,n){return i.tick(t,n)}),this.anim&&(this._aniloop.external=function(){return i.anim.manual()},this.anim.on("step",function(t,n){if(i._aniloop.isRunning())return i._aniloop.setTime(t),i._aniloop.render(n)})),Promise.resolve().then(function(){var t;return i.mod.config=l(i.mod.config||{},p.commonConfig),i._defcfg=t=h(i.mod.config),l(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,n;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."):(e||(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?((n=y({},i.layoutOpt)).watchResize=!1,n):{root:e,watchResize:!1}))),t=proxise(function(){return a.add(i.root,i),null}),i._resize=function(){return t.resolve()},n=t(),(i.forceInit||!i.root.offsetParent||"none"===window.getComputedStyle(i.root).display||i.root.offsetWidth&&i.root.offsetHeight)&&t.resolve(),n}).then(function(){return i._resize=function(){}}).then(function(){var t,n=function(){if(i.mod.init)return i.mod.init.apply(i)};return(i.layout?(t=proxise(function(){return Promise.resolve(i.layout.init(n)),null}),i._layout=function(){return t.resolve()},i.layout.on("render",function(){return i._layout()}),t):n)()}).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(n,t){var e,i,r,o,s={};for(e in i=l)r=i[e],(o=h[e])?(s[e]=r.multiple?(o.map?o:[o]).map(u):n[o.key],/[RIT]/.exec(r.type)&&!/[CN]/.exec(r.type)&&(s[e]=Array.isArray(s[e])?s[e].map(a):c(s[e]))):r.multiple&&(s[e]=[]);return s._raw=n,s._idx=t,s;function u(t){return n[t.key]}function a(t){return c(t)}}),e.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(t,n){if(this.mod.tick)return this.mod.tick.apply(this,[t,n])},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,n,e;if(!arguments.length)return this.cfg;for(t={},n=0,e=arguments.length;n<e;++n)l(t,arguments[n],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 n,e,i,r,o,s,u,a=[];if(null==t){for(t in n=[],this.mod.dimension||{})n.push(t);t=n}for(e=0,i=(t=Array.isArray(t)?t:[t]).length;e<i;++e)r=t[e],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,n){if(this.binding[t]=n,this._normalizeBinding([t]),this._inited)return this.parse(),this.bind(),this.resize(),this.render()},setRaw:function(t,n,e){var i;return null==e&&(e=!1),Array.isArray(t)||(t&&"subset"in t&&(this._subset=t.subset||null),t=(i=t).raw,n=i.binding,e=i.reinit),null!=t&&(this.raw=t),null!=n&&(this.binding=n,this._normalizeBinding()),this.renderLock?(this.renderLock.resolve(),this.renderLock=null):this._inited?(e&&this.mod.init&&this.mod.init.apply(this),this.parse(),this.bind(),this.resize(),this.render()):this._pendingRaw=!0},on:function(t,e){var i=this;return(Array.isArray(t)?t:[t]).map(function(t){var n;return((n=i.evtHandler)[t]||(n[t]=[])).push(e)})},fire:function(t){for(var n,e,i,r,o=[],s=[],u=1,a=arguments.length;u<a;++u)s.push(arguments[u]);for(n=s,u=0,i=(e=this.evtHandler[t]||[]).length;u<i;++u)r=e[u],o.push(r.apply(this,n));return o},filter:function(t,n){var e,i,r,o,s;for(i in null==t&&(t={}),null==n&&(n=!1),e=[],r=this.binding)o=r[i],s=(s=Array.isArray(o)?o:[o]).map(u),e=e.concat(s);for(i in t)o=t[i],e.filter(a).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 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:{}}},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,n,e){return t&&t.subset?!(t=(e=null!=e?[(t[n]||[])[e],(t.subset[n]||[])[e]]:[t[n],t.subset[n]])[0])||(n=e[1]/t)<0?0:1<n?1:n:null},color:function(t,n){var e;return(e=i(t))?(e=.3*e[0]+.59*e[1]+.11*e[2],n=null!=n?n:(((this.cfg||{}).common||{}).subset||{}).fade,"rgb("+(e=Math.round(e+(255-e)*(null!=n?n:.72)))+","+e+","+e+")"):t}}},"undefined"!=typeof module&&null!==module?module.exports=p:"undefined"!=typeof window&&null!==window&&(window.chart=p)}.call(this);
1
+ !function(){var i,f,c,p,t,n,s,r,o,e,a,u,l,h,d,m,y,g,_;function v(t,i,c){function p(t,i){return n.call(t,i)}var d={}.toString,n={}.hasOwnProperty,m=!0;return function t(i,n,e){var r,s,o,a,u,l,h,f;if(null==i||null==n)return i===n;if(i.__placeholder__||n.__placeholder__)return!0;if(i===n)return 0!==i||1/i==1/n;r=d.call(i);if(d.call(n)!=r)return!1;switch(r){case"[object String]":return i==String(n);case"[object Number]":return i!=+i?n!=+n:0==i?1/i==1/n:i==+n;case"[object Date]":case"[object Boolean]":return+i==+n;case"[object RegExp]":return i.source==n.source&&i.global==n.global&&i.multiline==n.multiline&&i.ignoreCase==n.ignoreCase}if("object"!=typeof i||"object"!=typeof n)return!1;s=e.length;for(;s--;)if(e[s]==i)return!0;e.push(i);o=0;a=!0;if("[object Array]"==r){if(u=i.length,l=n.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 i==o in n&&t(i[o],n[o],e)););}else{if("constructor"in i!="constructor"in n||i.constructor!=n.constructor)return!1;for(h in i)if(p(i,h)&&(o++,!(a=p(n,h)&&t(i[h],n[h],e))))break;if(a){for(h in f=0,n)p(n,h)&&++f;a=m?"<<="===c?o<f:"<=="===c?o<=f:o===f:(m=!1,o===f)}}e.pop();return a}(t,i,[])}function b(t,i){var n,e={}.hasOwnProperty;for(n in i)e.call(i,n)&&(t[n]=i[n]);return t}i=new function(t){var n=new Intl.NumberFormat(t),t=n.formatToParts(12345.6),i=Array.from({length:10}).map(function(t,i){return n.format(i)}),e=new Map(i.map(function(t,i){return[t,i]}));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("["+i.join("")+"]","g"),this._index=function(t){return e.get(t)},this}("en-US"),f=function(t){return(t=((t=null==t?"":t)+"").trim().replace(i._group,"").replace(i._decimal,".").replace(i._numeral,i._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(i){var t,n,e,r,s,o=[];for(n in i=null==i?{}:i)o.push(n);for(t=o,e=0,s=(r=["name","order"]).length;e<s;++e)if(i[n=r[e]]&&!p(i[n]))return n;return t.filter(function(t){return!p(i[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(i){var t,n,e,r,s={};for(t in n=f)e=n[t],(r=a.binding[t])&&(s[t]=e.multiple?(r.map?r:[r]).map(o):i[r.key],p(e))&&(s[t]=Array.isArray(s[t])?s[t].map(c):c(s[t]));return s;function o(t){return i[t.key]}}),h={},u&&l.map(function(t){return h[t[u]+""]=t}),this.data.map(function(t,i){var n,e,r,s=u?h[t[u]+""]:l[i],o={};for(n in e=f)r=e[n],p(r)&&(o[n]=r.multiple?(t[n]||[]).map(a):s?c(s[n]):0);return t.subset=o;function a(t,i){return s?c((s[n]||[])[i]):0}}),"shrink"===(((this.cfg||{}).common||{}).subset||{}).mode?this.data.map(function(t){var i,n,e,r=[];for(i in n=f)e=n[i],p(e)&&r.push(t[i]=t.subset[i]);return r}):void 0;this.data.map(function(t){var i=t.subset;return delete t.subset,i})},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 i,n,s,e;return i=((t=null==t?{}:t).frames||[]).map(function(t,i){return{id:null!=t.id?t.id:i,raw:t.raw||[]}}),t=t.frameOrder,Array.isArray(t)&&t.length?(n={},i.map(function(t){return n[t.id+""]=t}),(s=t.map(function(t){return n[t+""]}).filter(function(t){return t})).concat(i.filter(function(t){for(var i=t,n=s,e=-1,r=n.length>>>0;++e<r;)if(i===n[e])return!1;return!0}))):(t=i.map(function(t){return t.id})).length&&t.every(r)?i.map(function(t,i){return{f:t,i:i}}).sort(function(t,i){return+t.f.id-+i.f.id||t.i-i.i}).map(function(t){return t.f}):t.length&&t.every(o)?(e=function(t){return t instanceof Date?t.getTime():Date.parse(t)},i.map(function(t,i){return{f:t,i:i}}).sort(function(t,i){return e(t.f.id)-e(i.f.id)||t.i-i.i}).map(function(t){return t.f})):i},a=function(t){var i,n;if("string"!=typeof t)return null;if(t=t.trim(),i=/^#([0-9a-f]{3})$/i.exec(t)){for(var e,r=[],s=0,o=(e=i[1].split("")).length;s<o;++s)n=e[s],r.push(parseInt(n+n,16));return r}return(i=/^#([0-9a-f]{6})$/i.exec(t))?[0,1,2].map(function(t){return parseInt(i[1].substr(2*t,2),16)}):(i=/^rgba?\(([^)]+)\)$/i.exec(t))&&3===(t=i[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,i,n){var e,r,s,o;for(r in null==n&&(n={}),e={},s=b(b({},i=null==i?{}:i),n||{}))o=s[r],e[r]="function"==typeof o?o.bind(t):o;return e},l=function(t,i,n){for(var e=t;t&&t!==n;)t=t.parentNode;if(t!==n)return null;if(!i)return t;for(t=e;t&&t!==n&&(!t.matches||(t.matches,!t.matches(i)));)t=t.parentNode;return t!==n||n.matches&&n.matches(i)?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,n){var e=this;return(Array.isArray(t)?t:[t]).map(function(t){var i;return((i=e.evtHandler)[t]||(i[t]=[])).push(n)})},fire:function(t){for(var i,n,e,r,s=[],o=[],a=1,u=arguments.length;a<u;++a)o.push(arguments[a]);for(i=o,a=0,e=(n=this.evtHandler[t]||[]).length;a<e;++a)r=n[a],s.push(r.apply(this,i));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 i=this;if(null!=t&&this.fps(t),!this.running)return this.running=!0,requestAnimationFrame(function(t){return i.handler(i.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,i){var n,e,r=this;if(null==i&&(i=!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,(i||(e=this.time.now-this.time.last)>=n)&&(this.time.last=t,this.render(i?0:e)),requestAnimationFrame(function(t){return r.handler(t,!1)}))}}),d={list:[],init:function(){var t,n,e=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 i=!!document[n];return e.list.map(function(t){return t.throttle(i)})},!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,i){return this.wm.set(t,i),this.ro.observe(t)},delete:function(t){return this.ro.unobserve(t),this.wm.delete(t)}},y=function(t,i,n){return null==i&&(i={}),null==n&&(n={}),function(t,i,n){var e,r;for(e in i)r=i[e],null==t[e]?t[e]=r:"object"!=typeof t[e]||"object"!=typeof r||n[e]&&n[e].type||y(t[e],i[e],n[e]);return t}(t=null==t?{}:t,i=JSON.parse(JSON.stringify(i)),n)},g=function(t){var r=function(t,i){var n,e;for(n in null==i&&(i={}),t.child,t)(e=t[n]).type?e.default&&(i[n]=e.default):r(e,i[n]||(i[n]={}));return i};return r(t)},(_=function(t){var i,n,e,r=this;for(i 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)||[]),n=_.scopes){if(e=n[i],null!=this[i])throw new Error("[@plotdb/chart] scope name `"+i+"` is already taken.");this[i]=u(this,e,this.mod[i])}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 n,t,i,e=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. "),i=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."),(i||this.root).appendChild(this.svg)),this._aniloop=new h,d.add(this._aniloop),this._aniloop.on("tick",function(t,i){return e.tick(t,i)}),this.anim&&(this._aniloop.external=function(){return e.anim.manual()},this.anim.on("step",function(t,i){if(e._aniloop.isRunning())return e._aniloop.setTime(t),e._aniloop.render(i)})),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,i;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."):(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")),e.layout=new layout("object"==typeof e.layoutOpt?((i=b({},e.layoutOpt)).watchResize=!1,i):{root:n,watchResize:!1}))),t=proxise(function(){return m.add(e.root,e),null}),e._resize=function(){return t.resolve()},i=t(),(e.forceInit||!e.root.offsetParent||"none"===window.getComputedStyle(e.root).display||e.root.offsetWidth&&e.root.offsetHeight)&&t.resolve(),i}).then(function(){return e._resize=function(){}}).then(function(){var t,i=function(){if(e.mod.init)return e.mod.init.apply(e)};return(e.layout?(t=proxise(function(){return Promise.resolve(e.layout.init(i)),null}),e._layout=function(){return t.resolve()},e.layout.on("render",function(){return e._layout()}),t):i)()}).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(){return e.resize(),e.render()},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),n.apply(this),this.mod.parse)return this.mod.parse.apply(this)},_parseRows:function(t){var l,i,h;return null==t&&(t=[]),l=(i=this.mod).dimension||(i.dimension={}),h=this.binding,t.map(function(i,t){var n,e,r,s,o={};for(n in e=l)r=e[n],(s=h[n])?(o[n]=r.multiple?(s.map?s:[s]).map(a):i[s.key],/[RIT]/.exec(r.type)&&!/[CN]/.exec(r.type)&&(o[n]=Array.isArray(o[n])?o[n].map(u):f(o[n]))):r.multiple&&(o[n]=[]);return o._raw=i,o._idx=t,o;function a(t){return i[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,i){if(this.mod.tick)return this.mod.tick.apply(this,[t,i])},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,i,n;if(!arguments.length)return this.cfg;for(t={},i=0,n=arguments.length;i<n;++i)y(t,arguments[i],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 i,n,e,r,s,o,a,u=[];if(null==t){for(t in i=[],this.mod.dimension||{})i.push(t);t=i}for(n=0,e=(t=Array.isArray(t)?t:[t]).length;n<e;++n)r=t[n],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,i){if(this.binding[t]=i,this._normalizeBinding([t]),this._inited)return this.parse(),this.bind(),this.resize(),this.render()},setRaw:function(t,i,n){var e;return null==n&&(n=!1),!t||Array.isArray(t)||s(t)||("subset"in t&&(this._subset=t.subset||null),t=(e=t).raw,i=e.binding,n=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!=i&&(this.binding=i,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 i,t=e(t);return this._frames={list:t,index:0,all:null},this._frames.index=this._frameAt((t=this._player.pos)<(i=this.duration())?t:i)},_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 i=this._frames?this._frames.list.length:0;return i?(t=0<(t=Math.floor(t/this._interval()))?t:0)<(i=i-1)?t:i: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,i){var n,e,r,s=this;if(null==i&&(i=0),(n=this._frames)&&n.list.length&&(t=(e=0<t?t:0)<(r=n.list.length-1)?e:r,n.index=t,this.raw=n.list[t].raw,this._inited))return this.parse(),this.bind(),this.resize(),this.anim&&0<i?this.anim.ago(i,function(){return s.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 i,n,e,r;if(this._frames&&this._frames.list.length)return r=this._interval(),n=(t=(e=0<(e=+(t=t&&"object"==typeof t?((t.frame||0)+(t.progress||0))*r:t)||0)?e:0)<(i=this.duration())?e:i)-(i=this._frameAt(t))*r,e=(e=+this._animCfg().transition||0)<r?e:r,0<i&&n<e?(this._goto(i-1),this.anim&&this.anim.flush(),this._goto(i,n)):(this._goto(i),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:i})},_playerLoop:function(){var t,i=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 i.anim&&i.anim.manual()||i._playerTick(),n.playing?n.raf=requestAnimationFrame(t):void 0})},_playerTick:function(){var t,i,n=this._player,e=this._frames;if(e&&e.list.length){if((t=this.duration())<=(i=this.position())){if(!this._animCfg().loop)return n.pos=t,n.playing=!1,this.fire("progress",{time:t,duration:t,index:e.index}),void this.fire("end");i%=t,n.origin=this._clock()-i}return(n=this._frameAt(i))!==e.index&&this._goto(n,i-n*this._interval()),this.fire("progress",{time:i,duration:t,index:n})}},on:function(t,n){var e=this;return(Array.isArray(t)?t:[t]).map(function(t){var i;return((i=e.evtHandler)[t]||(i[t]=[])).push(n)})},fire:function(t){for(var i,n,e,r,s=[],o=[],a=1,u=arguments.length;a<u;++a)o.push(arguments[a]);for(i=o,a=0,e=(n=this.evtHandler[t]||[]).length;a<e;++a)r=n[a],s.push(r.apply(this,i));return s},filter:function(t,i){var n,e,r,s,o;for(e in null==t&&(t={}),null==i&&(i=!1),n=[],r=this.binding)s=r[e],o=(o=Array.isArray(s)?s:[s]).map(a),n=n.concat(o);for(e in t)s=t[e],n.filter(u).map(l);return i&&this.fire("filter",t),this.mod.filter&&this.mod.filter.apply(this,[t,i]),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}}}},_.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,i;return this._frames?null!=(i=(t=this._frames).all)?i: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,i,n){return t&&t.subset?!(t=(n=null!=n?[(t[i]||[])[n],(t.subset[i]||[])[n]]:[t[i],t.subset[i]])[0])||(i=n[1]/t)<0?0:1<i?1:i:null},color:function(t,i){var n;return(n=a(t))?(n=.3*n[0]+.59*n[1]+.11*n[2],i=null!=i?i:(((this.cfg||{}).common||{}).subset||{}).fade,"rgb("+(n=Math.round(n+(255-n)*(null!=i?i:.72)))+","+n+","+n+")"):t}}},_.dataframe={is:s,split:function(t,n){var e={},r=[];return(t=null==t?[]:t).map(function(t){var i=t[n]+"";return e[i]||r.push(e[i]={id:t[n],raw:[]}),e[i].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.7.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/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"}}
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.8.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/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"}}