@plotdb/chart 3.11.0 → 3.14.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
@@ -815,8 +815,85 @@
815
815
  if (this.mod.render) {
816
816
  this.mod.render.apply(this);
817
817
  }
818
+ this._brushStyle();
819
+ this._empty();
818
820
  return this._anno();
819
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
+ },
820
897
  _annoBox: function(){
821
898
  var b;
822
899
  if (this.layout) {
@@ -1432,6 +1509,81 @@
1432
1509
  'default': 'transparent'
1433
1510
  }
1434
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
+ },
1435
1587
  annotation: {
1436
1588
  enabled: {
1437
1589
  type: 'boolean',
@@ -1463,6 +1615,21 @@
1463
1615
  }
1464
1616
  }
1465
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
+ };
1466
1633
  chart.scopes = {
1467
1634
  space: {
1468
1635
  x: function(v){
package/index.min.js CHANGED
@@ -1 +1 @@
1
- !function(){var w,n,f,c,d,t,i,s,r,o,e,a,u,l,h,p,m,y,g,_;function v(t,n,c){function d(t,n){return i.call(t,n)}var p={}.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=p.call(n);if(p.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(d(n,h)&&(o++,!(a=d(i,h)&&t(n[h],i[h],e))))break;if(a){for(h in f=0,i)d(i,h)&&++f;a=m?"<<="===c?o<f:"<=="===c?o<=f:o===f:(m=!1,o===f)}}e.pop();return a}(t,n,[])}function x(t,n){var i,e={}.hasOwnProperty;for(i in n)e.call(n,i)&&(t[i]=n[i]);return t}w="http://www.w3.org/2000/svg",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},d=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]]&&!d(n[i]))return i;return t.filter(function(t){return!d(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],d(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],d(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],d(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=x(x({},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=x(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)}))}}),p={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=x(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(w,"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,p.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=x({},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),this._anno()},_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,o,n,i,e,r,s,a,u,l,h,f,c,d,p=this,m=[],y=((this.cfg||{}).common||{}).annotation||{},g=null==y.enabled||!!y.enabled,_=g&&y.notes||[],v=g&&y.reference||[];if(this.svg){if(_.length||v.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(),o=y.font||{},n=function(t,n,i,e,r){var s=document.createElementNS(w,"text");return s.setAttribute("x",n),s.setAttribute("y",i),s.setAttribute("text-anchor",e),s.setAttribute("dominant-baseline",r),s.style.fill=t.color||y.color||"currentColor",(t.size||o.size)&&(s.style.fontSize=(t.size||o.size)+""),s.style.opacity=null!=t.opacity?t.opacity:null!=y.opacity?y.opacity:1,s.textContent=t.text+"",p._annoG.appendChild(s),s},i=0,e=_.length;i<e;++i)(r=_[i])&&null!=r.text&&n(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(i=0,e=v.length;i<e;++i)(s=v[i])&&(a="x"===s.axis?"x":"y",null==(u=b.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],d=h[3],l.setAttribute("x1",h[0]),l.setAttribute("y1",f),l.setAttribute("x2",c),l.setAttribute("y2",d),x(l.style,{stroke:s.color||y.color||"currentColor",strokeWidth:null!=s.width?s.width:1,strokeDasharray:null!=s.dash?s.dash:"4 3",opacity:null!=s.opacity?s.opacity:null!=y.opacity?y.opacity:.6}),this._annoG.appendChild(l),null!=s.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(n({text:s.label,color:s.color,size:s.size,opacity:s.opacity},h[0],h[1],h[2],h[3])))));return m}this._annoG&&this._annoG.parentNode&&this._annoG.parentNode.removeChild(this._annoG)}function b(){try{return this.space[a](s.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,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),x(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"}},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}]}}}}},_.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,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.11.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"}}
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.14.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/config.js CHANGED
@@ -82,6 +82,11 @@
82
82
  }
83
83
  },
84
84
  legend: {
85
+ mode: {
86
+ type: 'choice',
87
+ values: ['list', 'direct'],
88
+ 'default': 'list'
89
+ },
85
90
  selectable: {
86
91
  type: 'boolean',
87
92
  'default': true
@@ -1 +1 @@
1
- !function(){var e;e={from:function(e){var p=this,d=function(e,t){var a,l;if(t.preset){var o,n=e,u=JSON.parse(JSON.stringify(p.preset[t.preset])),r={}.hasOwnProperty;for(o in u)r.call(u,o)&&(n[o]=u[o])}for(a in t)l=t[a],"preset"!==a&&("string"==typeof l?e[a]=JSON.parse(JSON.stringify(p.preset[l]))||{}:d(e[a]||(e[a]={}),l));return e};return d({},e)},preset:{default:{margin:{type:"number"},font:e={family:{type:"font"},size:{type:"quantity",default:"1em",units:[{name:"em",max:10,step:.01,default:1},{name:"px",max:256,step:1,default:16}]}},color:{type:"color",default:"currentColor"},palette:{type:"palette"},background:{type:"color",default:"transparent"}},font:e,tip:{enabled:{type:"boolean",default:!0},format:{type:"format",default:".3s"}},label:{format:{type:"format",default:".3s"}},legend:{selectable:{type:"boolean",default:!0},actions:{type:"boolean",default:!0},enabled:{type:"boolean",default:!0},position:{type:"choice",values:["bottom","right"],default:"right"},sort:{direction:{type:"choice",values:["asc","desc"],default:"desc"},mode:{type:"choice",values:["label","value","none"],default:"value"}},subset:{mode:{type:"choice",values:["shrink","dim","partial"],default:"shrink"},opacity:{type:"number",default:.2,min:0,max:1,step:.05}},crossfilter:{type:"boolean",default:!1}},bin:{enabled:{type:"boolean",default:!1},width:{type:"number",default:0,min:0,max:1e6,step:.01},count:{type:"number",default:0,min:0,max:100,step:1},anchor:{type:"number",default:0,min:-1e6,max:1e6,step:.01},closed:{type:"choice",values:["left","right"],default:"left"},label:{type:"choice",values:["range","start","center"],default:"range"},format:{type:"format",default:""},empty:{type:"boolean",default:!0}},axis:{enabled:{type:"boolean",default:!0},center:{type:"boolean",default:!1},tick:{inner:{type:"number",name:"Inner Tick Size",default:8,min:0,max:40,step:.1},color:{type:"color",default:"currentColor"},count:{type:"number",default:4,min:1,max:40},boundaryOffset:{type:"boolean",default:!0}},baseline:{show:{type:"boolean",default:!0},color:{type:"color",default:"currentColor"}},label:{color:{type:"color",default:"currentColor"},format:{type:"format",default:".3s"},direction:{type:"choice",default:"horizontal",values:["horizontal","angled","vertical","auto"]},angle:{type:"number",default:45,min:0,max:90,step:1},gap:{type:"number",default:1.5,min:0,max:10,step:.1},strategy:{type:"choice",default:"stride",values:["stride","ends"]},tolerance:{type:"number",default:.2,min:0,max:1,step:.05},padding:{type:"number",default:1,min:0,max:100,step:.5},font:e},caption:{color:{type:"color",default:"currentColor"},text:{type:"text",default:""},show:{type:"boolean",default:!0},padding:{type:"number",default:1,min:0,max:100,step:.5},position:{type:"choice",default:4,values:[{name:"in / start",value:0},{name:"in / middle",value:1},{name:"in / end",value:2},{name:"out / start",value:3},{name:"out / middle",value:4},{name:"out / end",value:5}]},font:e},sideNoteStart:{show:{type:"boolean",default:!1},text:{type:"text",default:""},position:{type:"choice",default:0,values:[{name:"in",value:0},{name:"out",value:1}]},font:e,color:{type:"color",default:"currentColor"},padding:{type:"number",default:1,min:0,max:100,step:.5}},sideNoteEnd:{show:{type:"boolean",default:!1},text:{type:"text",default:""},position:{type:"choice",default:0,values:[{name:"in",value:0},{name:"out",value:1}]},font:e,color:{type:"color",default:"currentColor"},padding:{type:"number",default:1,min:0,max:100,step:.5}}}}},"undefined"!=typeof chart&&null!==chart&&((chart.utils||(chart.utils={})).config=e)}.call(this);
1
+ !function(){var e;e={from:function(e){var p=this,i=function(e,t){var a,l;if(t.preset){var o,n=e,u=JSON.parse(JSON.stringify(p.preset[t.preset])),r={}.hasOwnProperty;for(o in u)r.call(u,o)&&(n[o]=u[o])}for(a in t)l=t[a],"preset"!==a&&("string"==typeof l?e[a]=JSON.parse(JSON.stringify(p.preset[l]))||{}:i(e[a]||(e[a]={}),l));return e};return i({},e)},preset:{default:{margin:{type:"number"},font:e={family:{type:"font"},size:{type:"quantity",default:"1em",units:[{name:"em",max:10,step:.01,default:1},{name:"px",max:256,step:1,default:16}]}},color:{type:"color",default:"currentColor"},palette:{type:"palette"},background:{type:"color",default:"transparent"}},font:e,tip:{enabled:{type:"boolean",default:!0},format:{type:"format",default:".3s"}},label:{format:{type:"format",default:".3s"}},legend:{mode:{type:"choice",values:["list","direct"],default:"list"},selectable:{type:"boolean",default:!0},actions:{type:"boolean",default:!0},enabled:{type:"boolean",default:!0},position:{type:"choice",values:["bottom","right"],default:"right"},sort:{direction:{type:"choice",values:["asc","desc"],default:"desc"},mode:{type:"choice",values:["label","value","none"],default:"value"}},subset:{mode:{type:"choice",values:["shrink","dim","partial"],default:"shrink"},opacity:{type:"number",default:.2,min:0,max:1,step:.05}},crossfilter:{type:"boolean",default:!1}},bin:{enabled:{type:"boolean",default:!1},width:{type:"number",default:0,min:0,max:1e6,step:.01},count:{type:"number",default:0,min:0,max:100,step:1},anchor:{type:"number",default:0,min:-1e6,max:1e6,step:.01},closed:{type:"choice",values:["left","right"],default:"left"},label:{type:"choice",values:["range","start","center"],default:"range"},format:{type:"format",default:""},empty:{type:"boolean",default:!0}},axis:{enabled:{type:"boolean",default:!0},center:{type:"boolean",default:!1},tick:{inner:{type:"number",name:"Inner Tick Size",default:8,min:0,max:40,step:.1},color:{type:"color",default:"currentColor"},count:{type:"number",default:4,min:1,max:40},boundaryOffset:{type:"boolean",default:!0}},baseline:{show:{type:"boolean",default:!0},color:{type:"color",default:"currentColor"}},label:{color:{type:"color",default:"currentColor"},format:{type:"format",default:".3s"},direction:{type:"choice",default:"horizontal",values:["horizontal","angled","vertical","auto"]},angle:{type:"number",default:45,min:0,max:90,step:1},gap:{type:"number",default:1.5,min:0,max:10,step:.1},strategy:{type:"choice",default:"stride",values:["stride","ends"]},tolerance:{type:"number",default:.2,min:0,max:1,step:.05},padding:{type:"number",default:1,min:0,max:100,step:.5},font:e},caption:{color:{type:"color",default:"currentColor"},text:{type:"text",default:""},show:{type:"boolean",default:!0},padding:{type:"number",default:1,min:0,max:100,step:.5},position:{type:"choice",default:4,values:[{name:"in / start",value:0},{name:"in / middle",value:1},{name:"in / end",value:2},{name:"out / start",value:3},{name:"out / middle",value:4},{name:"out / end",value:5}]},font:e},sideNoteStart:{show:{type:"boolean",default:!1},text:{type:"text",default:""},position:{type:"choice",default:0,values:[{name:"in",value:0},{name:"out",value:1}]},font:e,color:{type:"color",default:"currentColor"},padding:{type:"number",default:1,min:0,max:100,step:.5}},sideNoteEnd:{show:{type:"boolean",default:!1},text:{type:"text",default:""},position:{type:"choice",default:0,values:[{name:"in",value:0},{name:"out",value:1}]},font:e,color:{type:"color",default:"currentColor"},padding:{type:"number",default:1,min:0,max:100,step:.5}}}}},"undefined"!=typeof chart&&null!==chart&&((chart.utils||(chart.utils={})).config=e)}.call(this);
@@ -0,0 +1,94 @@
1
+ (function(){
2
+ var labels;
3
+ labels = {};
4
+ labels.place = function(items, opt){
5
+ var gap, top, bottom, heightOf, order, blocks, i$, len$, i, b, a, pos, pushDown, last, hi, ret;
6
+ items == null && (items = []);
7
+ opt == null && (opt = {});
8
+ if (!items.length) {
9
+ return [];
10
+ }
11
+ gap = opt.gap || 0;
12
+ top = opt.top != null ? opt.top : 0;
13
+ bottom = opt.bottom != null ? opt.bottom : Infinity;
14
+ heightOf = function(d){
15
+ return (d || {}).height || 0;
16
+ };
17
+ order = items.map(function(d, i){
18
+ return i;
19
+ });
20
+ order.sort(function(a, b){
21
+ return items[a].y - items[b].y || a - b;
22
+ });
23
+ blocks = [];
24
+ for (i$ = 0, len$ = order.length; i$ < len$; ++i$) {
25
+ i = order[i$];
26
+ blocks.push({
27
+ list: [i],
28
+ h: heightOf(items[i]),
29
+ sum: items[i].y,
30
+ n: 1
31
+ });
32
+ while (blocks.length > 1) {
33
+ b = blocks[blocks.length - 1];
34
+ a = blocks[blocks.length - 2];
35
+ if (a.sum / a.n + a.h + gap <= b.sum / b.n) {
36
+ break;
37
+ }
38
+ a.sum += b.sum - b.n * (a.h + gap);
39
+ a.n += b.n;
40
+ a.h += gap + b.h;
41
+ a.list = a.list.concat(b.list);
42
+ blocks.pop();
43
+ }
44
+ }
45
+ pos = blocks.map(function(b){
46
+ return b.sum / b.n;
47
+ });
48
+ pushDown = function(){
49
+ var i$, to$, i, lo, results$ = [];
50
+ for (i$ = 1, to$ = blocks.length; i$ < to$; ++i$) {
51
+ i = i$;
52
+ lo = pos[i - 1] + blocks[i - 1].h + gap;
53
+ if (pos[i] < lo) {
54
+ results$.push(pos[i] = lo);
55
+ }
56
+ }
57
+ return results$;
58
+ };
59
+ pushDown();
60
+ if (bottom < Infinity) {
61
+ last = blocks.length - 1;
62
+ if (pos[last] + blocks[last].h > bottom) {
63
+ pos[last] = bottom - blocks[last].h;
64
+ }
65
+ for (i$ = blocks.length - 2; i$ >= 0; --i$) {
66
+ i = i$;
67
+ hi = pos[i + 1] - blocks[i].h - gap;
68
+ if (pos[i] > hi) {
69
+ pos[i] = hi;
70
+ }
71
+ }
72
+ }
73
+ if (pos[0] < top) {
74
+ pos[0] = top;
75
+ }
76
+ pushDown();
77
+ ret = [];
78
+ blocks.map(function(b, bi){
79
+ var y;
80
+ y = pos[bi];
81
+ return b.list.map(function(i){
82
+ ret[i] = {
83
+ y: y,
84
+ moved: Math.abs(y - items[i].y) > 0.5
85
+ };
86
+ return y += heightOf(items[i]) + gap;
87
+ });
88
+ });
89
+ return ret;
90
+ };
91
+ if (typeof chart != 'undefined' && chart !== null) {
92
+ (chart.utils || (chart.utils = {})).labels = labels;
93
+ }
94
+ }).call(this);
@@ -0,0 +1 @@
1
+ !function(){var n={place:function(r,n){var h,t,l,u,e,o,i,a,s,c,f,m,p,g,y;if(!(r=null==r?[]:r).length)return[];for(h=(n=null==n?{}:n).gap||0,t=null!=n.top?n.top:0,n=null!=n.bottom?n.bottom:1/0,l=function(n){return(n||{}).height||0},(u=r.map(function(n,t){return t})).sort(function(n,t){return r[n].y-r[t].y||n-t}),e=[],o=0,i=u.length;o<i;++o)for(a=u[o],e.push({list:[a],h:l(r[a]),sum:r[a].y,n:1});1<e.length&&(s=e[e.length-1],!((c=e[e.length-2]).sum/c.n+c.h+h<=s.sum/s.n));)c.sum+=s.sum-s.n*(c.h+h),c.n+=s.n,c.h+=h+s.h,c.list=c.list.concat(s.list),e.pop();if(f=e.map(function(n){return n.sum/n.n}),(m=function(){for(var n,t,u=[],r=1,l=e.length;r<l;++r)t=f[(n=r)-1]+e[n-1].h+h,f[n]<t&&u.push(f[n]=t);return u})(),n<1/0)for(f[p=e.length-1]+e[p].h>n&&(f[p]=n-e[p].h),o=e.length-2;0<=o;--o)g=f[(a=o)+1]-e[a].h-h,f[a]>g&&(f[a]=g);return f[0]<t&&(f[0]=t),m(),y=[],e.map(function(n,t){var u=f[t];return n.list.map(function(n){return y[n]={y:u,moved:.5<Math.abs(u-r[n].y)},u+=l(r[n])+h})}),y}};"undefined"!=typeof chart&&null!==chart&&((chart.utils||(chart.utils={})).labels=n)}.call(this);
package/utils/legend.js CHANGED
@@ -26,6 +26,8 @@
26
26
  return this$.render();
27
27
  });
28
28
  this.id = Math.random().toString(36).substring(2);
29
+ this._anchor = null;
30
+ this._pos = {};
29
31
  nodeLayout = this.layout.getNode(this.name);
30
32
  nodeRender = this.layout.getGroup(this.name);
31
33
  if (!nodeLayout.querySelector('[ld-each=legend]')) {
@@ -156,9 +158,17 @@
156
158
  },
157
159
  handler: {
158
160
  "@": function(arg$){
159
- var node, ctx;
161
+ var node, ctx, p;
160
162
  node = arg$.node, ctx = arg$.ctx;
161
- return node.style.opacity = !this$.cfg.selectable || ctx.type === 'func' || this$._picked[ctx.key] ? 1 : 0.3;
163
+ node.style.opacity = !this$.cfg.selectable || ctx.type === 'func' || this$._picked[ctx.key] ? 1 : 0.3;
164
+ if (!this$._direct()) {
165
+ return node.removeAttribute('transform');
166
+ }
167
+ p = this$._pos[ctx.key];
168
+ if (!p) {
169
+ return node.removeAttribute('transform');
170
+ }
171
+ return node.setAttribute('transform', "translate(0," + p.dy + ")");
162
172
  },
163
173
  "shape": function(arg$){
164
174
  var node, ctx, n, box, rbox;
@@ -257,7 +267,119 @@
257
267
  return this._lngHandler = null;
258
268
  },
259
269
  _actions: function(){
260
- return !!(this.cfg.selectable && (this.cfg.actions != null ? this.cfg.actions : true));
270
+ return !!(this.cfg.selectable && (this.cfg.actions != null ? this.cfg.actions : true) && !this._direct());
271
+ },
272
+ _direct: function(){
273
+ return this.cfg.mode === 'direct' && !!this._anchor && this.dir === 'vertical';
274
+ },
275
+ anchor: function(fn){
276
+ if (!arguments.length) {
277
+ return this._anchor;
278
+ }
279
+ this._anchor = fn;
280
+ return this;
281
+ },
282
+ _solve: function(){
283
+ var rbox, items, valid, got, this$ = this;
284
+ this._pos = {};
285
+ if (!this._direct()) {
286
+ return;
287
+ }
288
+ rbox = this.layout.getBox(this.name);
289
+ items = [];
290
+ this._data.map(function(d){
291
+ var nbox, y, e;
292
+ nbox = this$.layout.getBox(this$._name(d, 'text'));
293
+ y = (function(){
294
+ try {
295
+ return this._anchor(d);
296
+ } catch (e$) {
297
+ e = e$;
298
+ return null;
299
+ }
300
+ }.call(this$));
301
+ return items.push({
302
+ d: d,
303
+ nbox: nbox,
304
+ y: y
305
+ });
306
+ });
307
+ valid = items.filter(function(o){
308
+ return o.y != null && !isNaN(o.y);
309
+ });
310
+ if (!valid.length) {
311
+ return;
312
+ }
313
+ got = chart.utils.labels.place(valid.map(function(o){
314
+ return {
315
+ y: o.y - o.nbox.height / 2,
316
+ height: o.nbox.height
317
+ };
318
+ }), {
319
+ top: 0,
320
+ bottom: rbox.height,
321
+ gap: 2
322
+ });
323
+ return valid.map(function(o, i){
324
+ var base;
325
+ base = o.nbox.y - rbox.y;
326
+ return this$._pos[o.d.key] = {
327
+ dy: got[i].y - base,
328
+ y: got[i].y,
329
+ h: o.nbox.height,
330
+ moved: got[i].moved,
331
+ anchor: o.y
332
+ };
333
+ });
334
+ },
335
+ _leads: function(){
336
+ var g, k, ref$, p, d, n, ref1$, y0, y1, x1, results$ = [];
337
+ g = this.layout.getGroup(this.name);
338
+ if (!this._lead) {
339
+ this._lead = document.createElementNS(svgns, 'g');
340
+ this._lead.setAttribute('data-type', 'leader');
341
+ this._lead.style.pointerEvents = 'none';
342
+ }
343
+ if (!this._direct()) {
344
+ if (this._lead.parentNode) {
345
+ this._lead.parentNode.removeChild(this._lead);
346
+ }
347
+ return;
348
+ }
349
+ g.insertBefore(this._lead, g.firstChild);
350
+ this._lead.textContent = '';
351
+ for (k in ref$ = this._pos) {
352
+ p = ref$[k];
353
+ if (!p.moved) {
354
+ continue;
355
+ }
356
+ d = this._data.filter(fn$)[0];
357
+ if (!d) {
358
+ continue;
359
+ }
360
+ n = document.createElementNS(svgns, 'path');
361
+ ref1$ = [p.anchor, p.y + p.h / 2], y0 = ref1$[0], y1 = ref1$[1];
362
+ x1 = this._shapeX();
363
+ n.setAttribute('d', "M0 " + y0 + " L" + x1 / 2 + " " + y0 + " L" + x1 / 2 + " " + y1 + " L" + x1 + " " + y1);
364
+ n.setAttribute('fill', 'none');
365
+ n.setAttribute('stroke', 'currentColor');
366
+ n.setAttribute('stroke-width', 1);
367
+ n.setAttribute('opacity', this._picked[k] ? 0.35 : 0.12);
368
+ results$.push(this._lead.appendChild(n));
369
+ }
370
+ return results$;
371
+ function fn$(it){
372
+ return it.key === k;
373
+ }
374
+ },
375
+ _shapeX: function(){
376
+ var d, rbox;
377
+ d = this._data[0];
378
+ if (!d) {
379
+ return 0;
380
+ }
381
+ rbox = this.layout.getBox(this.name);
382
+ return this.layout.getBox(this._name(d, 'shape')).x - rbox.x;
261
383
  },
262
384
  _name: function(ctx, type){
263
385
  type == null && (type = "s");
@@ -290,9 +412,12 @@
290
412
  enabled = this.enabled();
291
413
  g = this.layout.getGroup(this.name);
292
414
  g.style.display = enabled ? '' : 'none';
293
- if (enabled) {
294
- return this.view.render.render();
415
+ if (!enabled) {
416
+ return;
295
417
  }
418
+ this._solve();
419
+ this.view.render.render();
420
+ return this._leads();
296
421
  },
297
422
  config: function(cfg){
298
423
  var node, this$ = this;