@plotdb/chart 3.10.0 → 3.11.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
@@ -813,7 +813,134 @@
813
813
  }
814
814
  this._syncAnim();
815
815
  if (this.mod.render) {
816
- return this.mod.render.apply(this);
816
+ this.mod.render.apply(this);
817
+ }
818
+ return this._anno();
819
+ },
820
+ _annoBox: function(){
821
+ var b;
822
+ if (this.layout) {
823
+ try {
824
+ b = this.layout.getBox('view');
825
+ if (b && b.width && b.height) {
826
+ return b;
827
+ }
828
+ } catch (e$) {}
829
+ }
830
+ return {
831
+ x: 0,
832
+ y: 0,
833
+ width: (this.box || {}).width || 0,
834
+ height: (this.box || {}).height || 0
835
+ };
836
+ },
837
+ _anno: function(){
838
+ var cfg, enabled, notes, refs, box, font, textOf, i$, len$, n, x, y, r, dir, v, e, ln, ref$, x1, y1, x2, y2, lx, ly, anchor, baseline, this$ = this, results$ = [];
839
+ cfg = ((this.cfg || {}).common || {}).annotation || {};
840
+ enabled = cfg.enabled != null ? !!cfg.enabled : true;
841
+ notes = enabled
842
+ ? cfg.notes || []
843
+ : [];
844
+ refs = enabled
845
+ ? cfg.reference || []
846
+ : [];
847
+ if (!this.svg) {
848
+ return;
849
+ }
850
+ if (!(notes.length || refs.length)) {
851
+ if (this._annoG && this._annoG.parentNode) {
852
+ this._annoG.parentNode.removeChild(this._annoG);
853
+ }
854
+ return;
855
+ }
856
+ if (!this._annoG) {
857
+ this._annoG = document.createElementNS(svgns, 'g');
858
+ this._annoG.setAttribute('data-type', 'annotation');
859
+ this._annoG.style.pointerEvents = 'none';
860
+ }
861
+ this.svg.appendChild(this._annoG);
862
+ this._annoG.textContent = '';
863
+ box = this._annoBox();
864
+ font = cfg.font || {};
865
+ textOf = function(o, x, y, anchor, baseline){
866
+ var t;
867
+ t = document.createElementNS(svgns, 'text');
868
+ t.setAttribute('x', x);
869
+ t.setAttribute('y', y);
870
+ t.setAttribute('text-anchor', anchor);
871
+ t.setAttribute('dominant-baseline', baseline);
872
+ t.style.fill = o.color || cfg.color || 'currentColor';
873
+ if (o.size || font.size) {
874
+ t.style.fontSize = (o.size || font.size) + "";
875
+ }
876
+ t.style.opacity = o.opacity != null
877
+ ? o.opacity
878
+ : cfg.opacity != null ? cfg.opacity : 1;
879
+ t.textContent = o.text + "";
880
+ this$._annoG.appendChild(t);
881
+ return t;
882
+ };
883
+ for (i$ = 0, len$ = notes.length; i$ < len$; ++i$) {
884
+ n = notes[i$];
885
+ if (!(n && n.text != null)) {
886
+ continue;
887
+ }
888
+ x = box.x + box.width * (n.x != null ? n.x : 0.5);
889
+ y = box.y + box.height * (n.y != null ? n.y : 0.5);
890
+ textOf(n, x, y, n.align || 'middle', n.baseline || 'middle');
891
+ }
892
+ for (i$ = 0, len$ = refs.length; i$ < len$; ++i$) {
893
+ r = refs[i$];
894
+ if (!r) {
895
+ continue;
896
+ }
897
+ dir = r.axis === 'x' ? 'x' : 'y';
898
+ v = (fn$.call(this));
899
+ if (!(v != null) || isNaN(v)) {
900
+ continue;
901
+ }
902
+ if (v < 0 || v > (dir === 'y'
903
+ ? box.height
904
+ : box.width)) {
905
+ continue;
906
+ }
907
+ ln = document.createElementNS(svgns, 'line');
908
+ ref$ = dir === 'y'
909
+ ? [box.x, box.y + v, box.x + box.width, box.y + v]
910
+ : [box.x + v, box.y, box.x + v, box.y + box.height], x1 = ref$[0], y1 = ref$[1], x2 = ref$[2], y2 = ref$[3];
911
+ ln.setAttribute('x1', x1);
912
+ ln.setAttribute('y1', y1);
913
+ ln.setAttribute('x2', x2);
914
+ ln.setAttribute('y2', y2);
915
+ import$(ln.style, {
916
+ stroke: r.color || cfg.color || 'currentColor',
917
+ strokeWidth: r.width != null ? r.width : 1,
918
+ strokeDasharray: r.dash != null ? r.dash : '4 3',
919
+ opacity: r.opacity != null
920
+ ? r.opacity
921
+ : cfg.opacity != null ? cfg.opacity : 0.6
922
+ });
923
+ this._annoG.appendChild(ln);
924
+ if (r.label != null) {
925
+ ref$ = dir === 'y'
926
+ ? [box.x + box.width - 2, box.y + v - 3, 'end', 'auto']
927
+ : [box.x + v + 3, box.y + 2, 'start', 'hanging'], lx = ref$[0], ly = ref$[1], anchor = ref$[2], baseline = ref$[3];
928
+ results$.push(textOf({
929
+ text: r.label,
930
+ color: r.color,
931
+ size: r.size,
932
+ opacity: r.opacity
933
+ }, lx, ly, anchor, baseline));
934
+ }
935
+ }
936
+ return results$;
937
+ function fn$(){
938
+ try {
939
+ return this.space[dir](r.value);
940
+ } catch (e$) {
941
+ e = e$;
942
+ return null;
943
+ }
817
944
  }
818
945
  },
819
946
  destroy: function(){
@@ -1304,10 +1431,47 @@
1304
1431
  type: 'color',
1305
1432
  'default': 'transparent'
1306
1433
  }
1434
+ },
1435
+ annotation: {
1436
+ enabled: {
1437
+ type: 'boolean',
1438
+ 'default': true
1439
+ },
1440
+ color: {
1441
+ type: 'color',
1442
+ 'default': 'currentColor'
1443
+ },
1444
+ opacity: {
1445
+ type: 'number',
1446
+ 'default': 1,
1447
+ min: 0,
1448
+ max: 1,
1449
+ step: 0.05
1450
+ },
1451
+ font: {
1452
+ size: {
1453
+ type: 'quantity',
1454
+ 'default': '.8em',
1455
+ units: [{
1456
+ name: 'em',
1457
+ max: 10,
1458
+ step: 0.01,
1459
+ 'default': 0.8
1460
+ }]
1461
+ }
1462
+ }
1307
1463
  }
1308
1464
  }
1309
1465
  };
1310
1466
  chart.scopes = {
1467
+ space: {
1468
+ x: function(v){
1469
+ return null;
1470
+ },
1471
+ y: function(v){
1472
+ return null;
1473
+ }
1474
+ },
1311
1475
  frame: {
1312
1476
  active: function(){
1313
1477
  return !!this._frames;
package/index.min.js CHANGED
@@ -1 +1 @@
1
- !function(){var n,f,c,p,t,i,s,r,o,e,a,u,l,h,d,m,y,g,_;function v(t,n,c){function p(t,n){return i.call(t,n)}var d={}.toString,i={}.hasOwnProperty,m=!0;return function t(n,i,e){var r,s,o,a,u,l,h,f;if(null==n||null==i)return n===i;if(n.__placeholder__||i.__placeholder__)return!0;if(n===i)return 0!==n||1/n==1/i;r=d.call(n);if(d.call(i)!=r)return!1;switch(r){case"[object String]":return n==String(i);case"[object Number]":return n!=+n?i!=+i:0==n?1/n==1/i:n==+i;case"[object Date]":case"[object Boolean]":return+n==+i;case"[object RegExp]":return n.source==i.source&&n.global==i.global&&n.multiline==i.multiline&&n.ignoreCase==i.ignoreCase}if("object"!=typeof n||"object"!=typeof i)return!1;s=e.length;for(;s--;)if(e[s]==n)return!0;e.push(n);o=0;a=!0;if("[object Array]"==r){if(u=n.length,l=i.length,m){switch(c){case"===":a=u===l;break;case"<==":a=u<=l;break;case"<<=":a=u<l}o=u,m=!1}else a=u===l,o=u;if(a)for(;o--&&(a=o in n==o in i&&t(n[o],i[o],e)););}else{if("constructor"in n!="constructor"in i||n.constructor!=i.constructor)return!1;for(h in n)if(p(n,h)&&(o++,!(a=p(i,h)&&t(n[h],i[h],e))))break;if(a){for(h in f=0,i)p(i,h)&&++f;a=m?"<<="===c?o<f:"<=="===c?o<=f:o===f:(m=!1,o===f)}}e.pop();return a}(t,n,[])}function b(t,n){var i,e={}.hasOwnProperty;for(i in n)e.call(n,i)&&(t[i]=n[i]);return t}n=new function(t){var i=new Intl.NumberFormat(t),t=i.formatToParts(12345.6),n=Array.from({length:10}).map(function(t,n){return i.format(n)}),e=new Map(n.map(function(t,n){return[t,n]}));return this._group=new RegExp("["+t.find(function(t){return v(t.type,"group","===")}).value+"]","g"),this._decimal=new RegExp("["+t.find(function(t){return v(t.type,"decimal","===")}).value+"]"),this._numeral=new RegExp("["+n.join("")+"]","g"),this._index=function(t){return e.get(t)},this}("en-US"),f=function(t){return(t=((t=null==t?"":t)+"").trim().replace(n._group,"").replace(n._decimal,".").replace(n._numeral,n._index))?+t:NaN},c=function(t){return"number"==typeof t?t:!t&&0!==t||isNaN(+t)?0:+t},p=function(t){return!(!/[RIT]/.exec((t=null==t?{}:t).type||"")||/[CN]/.exec(t.type||""))},t=function(n){var t,i,e,r,s,o=[];for(i in n=null==n?{}:n)o.push(i);for(t=o,e=0,s=(r=["name","order"]).length;e<s;++e)if(n[i=r[e]]&&!p(n[i]))return i;return t.filter(function(t){return!p(n[t])})[0]},i=function(){var u,l,h,a=this,f=(this.mod||{}).dimension||{};if(this._subset)return u=t(f),l=this._subset.map(function(n){var t,i,e,r,s={};for(t in i=f)e=i[t],(r=a.binding[t])&&(s[t]=e.multiple?(r.map?r:[r]).map(o):n[r.key],p(e))&&(s[t]=Array.isArray(s[t])?s[t].map(c):c(s[t]));return s;function o(t){return n[t.key]}}),h={},u&&l.map(function(t){return h[t[u]+""]=t}),this.data.map(function(t,n){var i,e,r,s=u?h[t[u]+""]:l[n],o={};for(i in e=f)r=e[i],p(r)&&(o[i]=r.multiple?(t[i]||[]).map(a):s?c(s[i]):0);return t.subset=o;function a(t,n){return s?c((s[i]||[])[n]):0}}),"shrink"===(((this.cfg||{}).common||{}).subset||{}).mode?this.data.map(function(t){var n,i,e,r=[];for(n in i=f)e=i[n],p(e)&&r.push(t[n]=t.subset[n]);return r}):void 0;this.data.map(function(t){var n=t.subset;return delete t.subset,n})},s=function(t){return!(!t||Array.isArray(t)||!Array.isArray(t.frames))},r=function(t){return"number"==typeof t||"string"==typeof t&&t.trim()&&!isNaN(+t)},o=function(t){return t instanceof Date||"string"==typeof t&&!isNaN(Date.parse(t))},e=function(t){var n,i,s,e;return n=((t=null==t?{}:t).frames||[]).map(function(t,n){return{id:null!=t.id?t.id:n,raw:t.raw||[]}}),t=t.frameOrder,Array.isArray(t)&&t.length?(i={},n.map(function(t){return i[t.id+""]=t}),(s=t.map(function(t){return i[t+""]}).filter(function(t){return t})).concat(n.filter(function(t){for(var n=t,i=s,e=-1,r=i.length>>>0;++e<r;)if(n===i[e])return!1;return!0}))):(t=n.map(function(t){return t.id})).length&&t.every(r)?n.map(function(t,n){return{f:t,i:n}}).sort(function(t,n){return+t.f.id-+n.f.id||t.i-n.i}).map(function(t){return t.f}):t.length&&t.every(o)?(e=function(t){return t instanceof Date?t.getTime():Date.parse(t)},n.map(function(t,n){return{f:t,i:n}}).sort(function(t,n){return e(t.f.id)-e(n.f.id)||t.i-n.i}).map(function(t){return t.f})):n},a=function(t){var n,i;if("string"!=typeof t)return null;if(t=t.trim(),n=/^#([0-9a-f]{3})$/i.exec(t)){for(var e,r=[],s=0,o=(e=n[1].split("")).length;s<o;++s)i=e[s],r.push(parseInt(i+i,16));return r}return(n=/^#([0-9a-f]{6})$/i.exec(t))?[0,1,2].map(function(t){return parseInt(n[1].substr(2*t,2),16)}):(n=/^rgba?\(([^)]+)\)$/i.exec(t))&&3===(t=n[1].split(",").slice(0,3).map(function(t){return parseFloat(t.trim())})).length&&t.every(function(t){return!isNaN(t)})?t:null},u=function(t,n,i){var e,r,s,o;for(r in null==i&&(i={}),e={},s=b(b({},n=null==n?{}:n),i||{}))o=s[r],e[r]="function"==typeof o?o.bind(t):o;return e},l=function(t,n,i){for(var e=t;t&&t!==i;)t=t.parentNode;if(t!==i)return null;if(!n)return t;for(t=e;t&&t!==i&&(!t.matches||(t.matches,!t.matches(n)));)t=t.parentNode;return t!==i||i.matches&&i.matches(n)?t:null},(h=function(){return this.running=!1,this.time={now:0,last:0},this.fps(60),this.evtHandler={},this}).prototype=b(Object.create(Object.prototype),{on:function(t,i){var e=this;return(Array.isArray(t)?t:[t]).map(function(t){var n;return((n=e.evtHandler)[t]||(n[t]=[])).push(i)})},fire:function(t){for(var n,i,e,r,s=[],o=[],a=1,u=arguments.length;a<u;++a)o.push(arguments[a]);for(n=o,a=0,e=(i=this.evtHandler[t]||[]).length;a<e;++a)r=i[a],s.push(r.apply(this,n));return s},reset:function(){return this.time={now:0}},setTime:function(t){return this.time.now=t},getTime:function(){return this.time.now},isRunning:function(){return this.running},toggle:function(t){return null!=t&&(this.running=!t),this.running?this.pause():this.run()},pause:function(){return this.running=!1},render:function(t){return this.fire("tick",this.time.now,t=null==t?0:t)},run:function(t){var n=this;if(null!=t&&this.fps(t),!this.running)return this.running=!0,requestAnimationFrame(function(t){return n.handler(n.time.last=t,!0)})},throttle:function(t){return this.isThrottled=t=null==t?!0:t},fps:function(t){return null==t?this._fps_val:(this._fps_val=.01<t?t:.01,this._fps_delay=1e3/this._fps_val)},handler:function(t,n){var i,e,r=this;if(null==n&&(n=!1),this.running)return this.external&&this.external()?(this.time.last=t,requestAnimationFrame(function(t){return r.handler(t,!1)})):(this.time.now=t,i=this.isThrottled?1e3<(i=this._fps_delay)?i:1e3:this._fps_delay,(n||(e=this.time.now-this.time.last)>=i)&&(this.time.last=t,this.render(n?0:e)),requestAnimationFrame(function(t){return r.handler(t,!1)}))}}),d={list:[],init:function(){var t,i,e=this;return this.inited=!0,t=null==document.hidden&&null==document.msHidden&&null!=document.webkiHidden?["webkitHidden","webkitvisibilitychange"]:["hidden","visibilitychange"],i=t[0],document.addEventListener(t[1],debounce(150,function(){var n=!!document[i];return e.list.map(function(t){return t.throttle(n)})},!1))},add:function(t){return this.inited||this.init(),this.list.push(t)}},m={wm:new WeakMap,ro:new ResizeObserver(function(t){return t.map(function(t){return m.wm.get(t.target)._resize()})}),add:function(t,n){return this.wm.set(t,n),this.ro.observe(t)},delete:function(t){return this.ro.unobserve(t),this.wm.delete(t)}},y=function(t,n,i){return null==n&&(n={}),null==i&&(i={}),function(t,n,i){var e,r;for(e in n)r=n[e],null==t[e]?t[e]=r:"object"!=typeof t[e]||"object"!=typeof r||i[e]&&i[e].type||y(t[e],n[e],i[e]);return t}(t=null==t?{}:t,n=JSON.parse(JSON.stringify(n)),i)},g=function(t){var r=function(t,n){var i,e;for(i in null==n&&(n={}),t.child,t)(e=t[i]).type?e.default&&(n[i]=e.default):r(e,n[i]||(n[i]={}));return n};return r(t)},(_=function(t){var n,i,e,r=this;for(n in this.root="string"==typeof(t=null==t?{}:t).root?document.querySelector(t.root):t.root,this.useSample=null==t.useSample||t.useSample,this.autoSelect=null==t.autoSelect||t.autoSelect,this.forceInit=t.forceInit||!1,this.prepareSvg=null==t.prepareSvg||t.prepareSvg,this.layoutOpt=null==t.layout||t.layout,this.delayRender=t.delayRender||!1,this.dataAccessor=null!=t.dataAccessor?t.dataAccessor:function(t){return t?t.data._raw:null},this.data=[],this.raw=t.raw||null,this.mod=t.mod||{},this.cfg=t.config||{},this.seed=t.seed||Math.random(),this.binding=t.binding||{},this._normalizeBinding(),this.evtHandler={},this._subset=t.subset||null,this._frames=null,this._player={playing:!1,pos:0,origin:0,raf:null},s(this.raw)&&(this._setFrames(this.raw),this.raw=(null!=(t=this._frames.list[this._frames.index])?t.raw:void 0)||[]),i=_.scopes){if(e=i[n],null!=this[n])throw new Error("[@plotdb/chart] scope name `"+n+"` is already taken.");this[n]=u(this,e,this.mod[n])}if(null!=this.local)throw new Error("[@plotdb/chart] scope name `local` is already taken.");return this.local=u(this,{},this.mod.local),(_.utils||(_.utils={})).anim&&null==this.anim&&(this.anim=new _.utils.anim),this.anim&&this.anim.on("step",function(){if(r._player.playing)return r._playerTick()}),this.init=proxise.once(function(){return r._init()}),this._resize=null,this._inited=!1,this.autoSelect&&(this.root.addEventListener("click",this._select=function(t){if(t=l(t.target,".data",r.root))return r.fire("select",[{data:r.dataAccessor(t),node:t}])}),this.root.addEventListener("mouseover",this._hover=function(t){if(t=l(t.target,".data",r.root))return r.fire("hover",[{data:r.dataAccessor(t),node:t}])})),this}).prototype=b(Object.create(Object.prototype),{_init:function(){var i,t,n,e=this;return"static"===window.getComputedStyle(this.root).position&&(this.root.style.position="relative"),i=this.layoutOpt?"object"!=typeof this.layoutOpt?this.root.querySelector(".pdl-layout"):"string"==typeof this.layoutOpt.root?this.root.querySelector(this.layoutOpt.root):this.layoutOpt.root||null:null,this.prepareSvg&&!(this.svg=this.root.querySelector("svg"))&&(this.svg=document.createElementNS("http://www.w3.org/2000/svg","svg"),(t=this.svg.style).width="100%",t.height="100%",!this.layoutOpt||(i||console.error("[@plotdb/chart] layout enabled yet layout root isn't configured properly. "),n=i.querySelector("[data-type=render]"))||console.warn("[@plotdb/chart] prepareSvg and layout is configured at the same time,\nyet render container for layout is not found. svg is thus appended in the root."),(n||this.root).appendChild(this.svg)),this._aniloop=new h,d.add(this._aniloop),this._aniloop.on("tick",function(t,n){return e.tick(t,n)}),this.anim&&(this._aniloop.external=function(){return e.anim.manual()},this.anim.on("step",function(t,n){if(e._aniloop.isRunning())return e._aniloop.setTime(t),e._aniloop.render(n)})),Promise.resolve().then(function(){var t;return e.mod.config=y(e.mod.config||{},_.commonConfig),e._defcfg=t=g(e.mod.config),y(e.cfg,t),e.raw&&Array.isArray(e.raw)?{raw:e.raw,binding:e.binding}:e.useSample&&e.mod.sample?(t=e.mod.sample.apply(e)).then?t.then():Promise.resolve(t):void 0}).then(function(t){return e.raw=(t=t||{}).raw,e.binding=t.binding,e}).then(function(){var t,n;return e.raw||(e.raw=[]),e.layoutOpt&&("undefined"==typeof layout||null===layout?console.warn("[@plotdb/chart] layout-opt is set yet @plotdb/layout is not found."):(i||(console.error("[@plotdb/chart] cannot determine root node for @plotdb/layout."),console.error("[@plotdb/chart] config layout properly or disable layout by setting layout to false")),e.layout=new layout("object"==typeof e.layoutOpt?((n=b({},e.layoutOpt)).watchResize=!1,n):{root:i,watchResize:!1}))),t=proxise(function(){return m.add(e.root,e),null}),e._resize=function(){return t.resolve()},n=t(),(e.forceInit||!e.root.offsetParent||"none"===window.getComputedStyle(e.root).display||e.root.offsetWidth&&e.root.offsetHeight)&&t.resolve(),n}).then(function(){return e._resize=function(){}}).then(function(){var t,n=function(){if(e.mod.init)return e.mod.init.apply(e)};return(e.layout?(t=proxise(function(){return Promise.resolve(e.layout.init(n)),null}),e._layout=function(){return t.resolve()},e.layout.on("render",function(){return e._layout()}),t):n)()}).then(function(){e._layout=function(){},Promise.resolve().then(function(){if(e.delayRender&&!e._pendingRaw)return e.renderLock=proxise(function(){}),e.renderLock()}).then(function(){if(e._inited=!0,e._resize=function(){e.anim&&e.anim.immediate(!0);try{return e.resize(),e.render()}finally{e.anim&&e.anim.immediate(!1)}},e._layout=function(){return e.parse(),e.bind(),e.resize(),e.render()},e.parse(),e.bind(),e.resize(),e.render(),e._frames)return e._framesStart()})})},parse:function(){if(this.data=this._parseRows(this.raw),this._frames&&(this._frames.all=null),i.apply(this),this.mod.parse)return this.mod.parse.apply(this)},_parseRows:function(t){var l,n,h;return null==t&&(t=[]),l=(n=this.mod).dimension||(n.dimension={}),h=this.binding,t.map(function(n,t){var i,e,r,s,o={};for(i in e=l)r=e[i],(s=h[i])?(o[i]=r.multiple?(s.map?s:[s]).map(a):n[s.key],/[RIT]/.exec(r.type)&&!/[CN]/.exec(r.type)&&(o[i]=Array.isArray(o[i])?o[i].map(u):f(o[i]))):r.multiple&&(o[i]=[]);return o._raw=n,o._idx=t,o;function a(t){return n[t.key]}function u(t){return f(t)}})},bind:function(){if(this.mod.bind)return this.mod.bind.apply(this)},start:function(){if(this._aniloop.run(),this.mod.start)return this.mod.start.apply(this)},stop:function(){if(this._aniloop.pause(),this.mod.stop)return this.mod.stop.apply(this)},resize:function(){if(this._inited)return this.layout&&this.layout.update(!1),this.box=this.root.getBoundingClientRect(),this.mod.resize?this.mod.resize.apply(this):void 0},tick:function(t,n){if(this.mod.tick)return this.mod.tick.apply(this,[t,n])},render:function(){if(this._inited)return this._syncAnim(),this.mod.render?this.mod.render.apply(this):void 0},destroy:function(){var t=this;return Promise.resolve().then(function(){if(t._select&&t.root.removeEventListener("click",t._select),t._hover&&t.root.removeEventListener("mouseover",t._hover),m.delete(t.root),t.layout&&t.layout.destroy(),t.pause(),t.stop(),t.mod.destroy)return t.mod.destroy.apply(t)})},config:function(){var t,n,i;if(!arguments.length)return this.cfg;for(t={},n=0,i=arguments.length;n<i;++n)y(t,arguments[n],this.mod.config);return y(t,this.cfg,this.mod.config),y(t,this._defcfg,this.mod.config),b(this.cfg,t)},_normalizeBinding:function(t){var n,i,e,r,s,o,a,u=[];if(null==t){for(t in n=[],this.mod.dimension||{})n.push(t);t=n}for(i=0,e=(t=Array.isArray(t)?t:[t]).length;i<e;++i)r=t[i],s=(this.mod.dimension||{})[r]||{},o=this.binding[r],a=Array.isArray(o),!s.multiple!=!a&&(s.multiple||a)&&u.push(this.binding[r]=a?o[0]:o?[o]:[]);return u},setBind:function(t,n){if(this.binding[t]=n,this._normalizeBinding([t]),this._inited)return this.parse(),this.bind(),this.resize(),this.render()},setRaw:function(t,n,i){var e;return null==i&&(i=!1),!t||Array.isArray(t)||s(t)||("subset"in t&&(this._subset=t.subset||null),t=(e=t).raw,n=e.binding,i=e.reinit),s(t)?(this._setFrames(t),t=(null!=(e=this._frames.list[this._frames.index])?e.raw:void 0)||[]):null!=t&&this._frames&&(this.pause(),this._frames=null,this._player.pos=0,this.anim)&&this.anim.resume(),null!=t&&(this.raw=t),null!=n&&(this.binding=n,this._normalizeBinding()),this.renderLock?(this.renderLock.resolve(),this.renderLock=null):this._inited?(i&&this.mod.init&&this.mod.init.apply(this),this.parse(),this.bind(),this.resize(),this.render(),this._frames?this._framesStart():void 0):this._pendingRaw=!0},_animCfg:function(){return((this.cfg||{}).common||{}).animation||{}},_syncAnim:function(){var t;if(this.anim)return null!=(t=this._animCfg()).transition&&this.anim.duration(t.transition),this.anim.speed(null!=t.speed?t.speed:1)},_setFrames:function(t){var n,t=e(t);return this._frames={list:t,index:0,all:null},this._frames.index=this._frameAt((t=this._player.pos)<(n=this.duration())?t:n)},_interval:function(){return+this._animCfg().interval||1e3},_clock:function(){return this.anim?this.anim.time():("undefined"!=typeof performance&&null!==performance?performance:Date).now()},_frameAt:function(t){var n=this._frames?this._frames.list.length:0;return n?(t=0<(t=Math.floor(t/this._interval()))?t:0)<(n=n-1)?t:n:0},_framesStart:function(){if(this.fire("frame",{index:this._frames.index,id:this.frame.id()}),this._animCfg().autoplay&&!this._player.playing)return this.play()},_goto:function(t,n){var i,e,r,s=this;if(null==n&&(n=0),(i=this._frames)&&i.list.length&&(t=(e=0<t?t:0)<(r=i.list.length-1)?e:r,i.index=t,this.raw=i.list[t].raw,this._inited))return this.parse(),this.bind(),this.resize(),this.anim&&0<n?this.anim.ago(n,function(){return s.render()}):this.render(),this.fire("frame",{index:t,id:i.list[t].id})},duration:function(){return this._frames?this._frames.list.length*this._interval():0},position:function(){var t=this._player;return t.playing?this._clock()-t.origin:t.pos},playing:function(){return this._player.playing},play:function(){var t=this._player;if(this._frames&&!t.playing&&this._frames.list.length)return t.pos>=this.duration()&&(t.pos=0),this._syncAnim(),this.anim&&this.anim.resume(),t.origin=this._clock()-t.pos,t.playing=!0,this.fire("play"),this._playerLoop()},pause:function(){var t=this._player;if(t.playing)return t.pos=this.position(),t.playing=!1,t.raf&&cancelAnimationFrame(t.raf),t.raf=null,this.anim&&this.anim.pause(),this.fire("pause")},seek:function(t){var n,i,e,r;if(this._frames&&this._frames.list.length)return r=this._interval(),i=(t=(e=0<(e=+(t=t&&"object"==typeof t?((t.frame||0)+(t.progress||0))*r:t)||0)?e:0)<(n=this.duration())?e:n)-(n=this._frameAt(t))*r,e=(e=+this._animCfg().transition||0)<r?e:r,0<n&&i<e?(this._goto(n-1),this.anim&&this.anim.flush(),this._goto(n,i)):(this._goto(n),this.anim&&this.anim.flush()),(r=this._player).pos=t,r.playing&&(r.origin=this._clock()-t),this.fire("progress",{time:t,duration:this.duration(),index:n})},_playerLoop:function(){var t,n=this,i=this._player;if(!i.raf&&"undefined"!=typeof requestAnimationFrame&&null!==requestAnimationFrame)return i.raf=requestAnimationFrame(t=function(){if(i.raf=null,i.playing)return n.anim&&n.anim.manual()||n._playerTick(),i.playing?i.raf=requestAnimationFrame(t):void 0})},_playerTick:function(){var t,n,i=this._player,e=this._frames;if(e&&e.list.length){if((t=this.duration())<=(n=this.position())){if(!this._animCfg().loop)return i.pos=t,i.playing=!1,this.fire("progress",{time:t,duration:t,index:e.index}),void this.fire("end");n%=t,i.origin=this._clock()-n}return(i=this._frameAt(n))!==e.index&&this._goto(i,n-i*this._interval()),this.fire("progress",{time:n,duration:t,index:i})}},on:function(t,i){var e=this;return(Array.isArray(t)?t:[t]).map(function(t){var n;return((n=e.evtHandler)[t]||(n[t]=[])).push(i)})},fire:function(t){for(var n,i,e,r,s=[],o=[],a=1,u=arguments.length;a<u;++a)o.push(arguments[a]);for(n=o,a=0,e=(i=this.evtHandler[t]||[]).length;a<e;++a)r=i[a],s.push(r.apply(this,n));return s},filter:function(t,n){var i,e,r,s,o;for(e in null==t&&(t={}),null==n&&(n=!1),i=[],r=this.binding)s=r[e],o=(o=Array.isArray(s)?s:[s]).map(a),i=i.concat(o);for(e in t)s=t[e],i.filter(u).map(l);return n&&this.fire("filter",t),this.mod.filter&&this.mod.filter.apply(this,[t,n]),this.parse(),this.bind(),this.resize(),this.render();function a(t){return{k:e,v:t}}function u(t){return t.k===e}function l(t){return t.v.filter=s}},sample:function(){return this.mod.sample?this.mod.sample.apply(this):{raw:[],binding:{}}},filterDims:function(){var t;return(t=(this.mod||{}).filterDims)?t.call(this):(this.mod||{}).filter?["name"]:[]},canFilter:function(){return!!this.filterDims().length}}),_.commonConfig={common:{animation:{transition:{type:"number",default:350,min:0,max:5e3,step:10},interval:{type:"number",default:1e3,min:100,max:2e4,step:50},speed:{type:"number",default:1,min:.1,max:10,step:.1},loop:{type:"boolean",default:!0},autoplay:{type:"boolean",default:!0}},subset:{mode:{type:"choice",values:["dim","partial","shrink"],default:"dim"},opacity:{type:"number",default:.2,min:0,max:1,step:.05},fade:{type:"number",default:.72,min:0,max:1,step:.01},background:{type:"color",default:"transparent"}}}},_.scopes={frame:{active:function(){return!!this._frames},count:function(){return this._frames?this._frames.list.length:0},index:function(){return this._frames?this._frames.index:-1},id:function(t){return this._frames?(this._frames.list[null!=t?t:this._frames.index]||{}).id:null},ids:function(){return this._frames?this._frames.list.map(function(t){return t.id}):[]},all:function(){var t,n;return this._frames?null!=(n=(t=this._frames).all)?n:t.all=this._parseRows([].concat.apply([],this._frames.list.map(function(t){return t.raw}))):this._parseRows(this.raw)}},subset:{set:function(t){if(this._subset=t||null,this._inited)return this.parse(),this.bind(),this.resize(),this.render()},mode:function(){return(((this.cfg||{}).common||{}).subset||{}).mode||"dim"},ratio:function(t,n,i){return t&&t.subset?!(t=(i=null!=i?[(t[n]||[])[i],(t.subset[n]||[])[i]]:[t[n],t.subset[n]])[0])||(n=i[1]/t)<0?0:1<n?1:n:null},color:function(t,n){var i,e,r,s;return(e=a(t))?(i=.3*e[0]+.59*e[1]+.11*e[2],e=((this.cfg||{}).common||{}).subset||{},r=null!=(r=null!=n?n:e.fade)?r:.72,s=a(e.background)||a((this.cfg||{}).background)||[255,255,255],"rgb("+[0,1,2].map(function(t){return Math.round(i+(s[t]-i)*r)}).join(",")+")"):t}}},_.dataframe={is:s,split:function(t,i){var e={},r=[];return(t=null==t?[]:t).map(function(t){var n=t[i]+"";return e[n]||r.push(e[n]={id:t[i],raw:[]}),e[n].raw.push(t)}),{frames:r}}},"undefined"!=typeof module&&null!==module?module.exports=_:"undefined"!=typeof window&&null!==window&&(window.chart=_)}.call(this);
1
+ !function(){var w,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);
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.10.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.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"}}
package/utils/axis.js CHANGED
@@ -147,7 +147,7 @@
147
147
  var map, size, unit, count, itr, ref$, ends, k, v, this$ = this;
148
148
  map = {};
149
149
  size = this._n.layout.getBoundingClientRect()[this.dir < 2 ? 'width' : 'height'];
150
- unit = this.dir < 2 && this.cfg.label.direction === 'vertical' ? 12 : 25;
150
+ unit = this.dir < 2 && this.cfg.label.direction !== 'horizontal' ? 12 : 25;
151
151
  count = Math.round(size / unit);
152
152
  itr = (ref$ = Math.round(ticks.length / (count > 1 ? count : 1))) > 1 ? ref$ : 1;
153
153
  ends = this.cfg.label.strategy === 'ends';
@@ -290,13 +290,30 @@
290
290
  return this.adjust();
291
291
  },
292
292
  adjust: function(){
293
- var ticks, isHorizon, vertical, em, place, gap, fits, sel, k, i, res$, i$, to$, tol, ref$, lo, hi, pick, even, p, idx, picked, shown, mm3, md3, size, delta, box, xoff, yoff, this$ = this;
293
+ var ticks, isHorizon, em, gap, fits, place, modes, allIdx, res$, i$, to$, i, len$, mode, sel, k, tol, ref$, lo, hi, pick, even, p, idx, picked, shown, mm3, md3, size, delta, box, xoff, yoff, this$ = this;
294
294
  ticks = this._ticks;
295
295
  isHorizon = this.dir < 2;
296
- vertical = isHorizon && this.cfg.label.direction === 'vertical';
297
296
  em = parseFloat(getComputedStyle(this._n.wrap).fontSize) || 16;
298
- place = function(tick, idx){
299
- var pos, coord, box, offset, doOffset, r, toff;
297
+ gap = em * (this.cfg.label.gap != null ? this.cfg.label.gap : 1.5);
298
+ fits = function(idx){
299
+ var prev, i$, len$, i, tick;
300
+ prev = null;
301
+ for (i$ = 0, len$ = idx.length; i$ < len$; ++i$) {
302
+ i = idx[i$];
303
+ tick = ticks[i];
304
+ if (prev != null && tick._start - (prev._start + prev._size) < gap) {
305
+ return false;
306
+ }
307
+ prev = tick;
308
+ }
309
+ return true;
310
+ };
311
+ place = function(tick, idx, mode){
312
+ var vertical, angled, ang, ref$, cos, sin, pos, coord, box, offset, doOffset, r, toff;
313
+ vertical = isHorizon && mode === 'vertical';
314
+ angled = isHorizon && mode === 'angled';
315
+ ang = this$.cfg.label.angle != null ? this$.cfg.label.angle : 45;
316
+ ref$ = [Math.cos(ang * Math.PI / 180), Math.sin(ang * Math.PI / 180)], cos = ref$[0], sin = ref$[1];
300
317
  pos = !idx
301
318
  ? 0
302
319
  : idx === ticks.length - 1 ? 2 : 1;
@@ -319,6 +336,8 @@
319
336
  if (vertical) {
320
337
  offset.x -= box.width;
321
338
  offset.y -= box.height * r;
339
+ } else if (angled) {
340
+ offset.x -= box.width;
322
341
  } else if (isHorizon) {
323
342
  offset.x -= box.width * r;
324
343
  } else {
@@ -327,16 +346,24 @@
327
346
  tick.n.tt.setAttribute('transform', "translate(" + offset.x + "," + offset.y + ")");
328
347
  tick._size = vertical
329
348
  ? box.height
330
- : box[isHorizon ? 'width' : 'height'];
349
+ : angled
350
+ ? box.width * cos + box.height * sin
351
+ : box[isHorizon ? 'width' : 'height'];
331
352
  tick._sizeAlt = vertical
332
353
  ? box.width
333
- : box[isHorizon ? 'height' : 'width'];
334
- tick._start = coord - tick._size * r;
354
+ : angled
355
+ ? box.width * sin + box.height * cos
356
+ : box[isHorizon ? 'height' : 'width'];
357
+ tick._start = angled
358
+ ? coord - box.width * cos
359
+ : coord - tick._size * r;
335
360
  if (isHorizon) {
336
361
  tick.n.g.setAttribute('transform', "translate(" + coord + ",0)");
337
362
  tick.n.p.setAttribute('d', "M0 0L0 " + this$.cfg.tick.inner);
338
363
  toff = this$.cfg.tick.inner + this$.cfg.label.padding;
339
- tick.n.t.setAttribute('transform', ("translate(0," + toff + ")") + (vertical ? " rotate(-90)" : ""));
364
+ tick.n.t.setAttribute('transform', ("translate(0," + toff + ")") + (vertical
365
+ ? " rotate(-90)"
366
+ : angled ? " rotate(" + (-ang) + ")" : ""));
340
367
  } else {
341
368
  tick.n.g.setAttribute('transform', "translate(0," + coord + ")");
342
369
  tick.n.p.setAttribute('d', "M0 0L-" + this$.cfg.tick.inner + " 0");
@@ -344,26 +371,27 @@
344
371
  }
345
372
  return tick.n.p.style.stroke = this$.cfg.tick.color || '';
346
373
  };
347
- ticks.map(place);
348
- gap = em * (this.cfg.label.gap != null ? this.cfg.label.gap : 1.5);
349
- fits = function(idx){
350
- var prev, i$, len$, i, tick;
351
- prev = null;
352
- for (i$ = 0, len$ = idx.length; i$ < len$; ++i$) {
353
- i = idx[i$];
354
- tick = ticks[i];
355
- if (prev != null && tick._start - (prev._start + prev._size) < gap) {
356
- return false;
357
- }
358
- prev = tick;
374
+ modes = isHorizon && this.cfg.label.direction === 'auto'
375
+ ? ['horizontal', 'angled', 'vertical']
376
+ : [this.cfg.label.direction || 'horizontal'];
377
+ res$ = [];
378
+ for (i$ = 0, to$ = ticks.length; i$ < to$; ++i$) {
379
+ i = i$;
380
+ res$.push(i);
381
+ }
382
+ allIdx = res$;
383
+ for (i$ = 0, len$ = modes.length; i$ < len$; ++i$) {
384
+ mode = modes[i$];
385
+ ticks.map(fn$);
386
+ if (fits(allIdx)) {
387
+ break;
359
388
  }
360
- return true;
361
- };
389
+ }
362
390
  sel = [0];
363
391
  if (ticks.length > 1) {
364
392
  if (this.cfg.label.strategy !== 'ends') {
365
393
  k = 1;
366
- while (k < ticks.length && !fits((fn$()))) {
394
+ while (k < ticks.length && !fits((fn1$()))) {
367
395
  k++;
368
396
  }
369
397
  res$ = [];
@@ -482,7 +510,10 @@
482
510
  return n.setAttribute('transform', "translate(" + xoff + "," + yoff + ") rotate(90)");
483
511
  });
484
512
  }
485
- function fn$(){
513
+ function fn$(tick, i){
514
+ return place(tick, i, mode);
515
+ }
516
+ function fn1$(){
486
517
  var i$, step$, to$, results$ = [];
487
518
  for (i$ = 0, to$ = ticks.length, step$ = k; step$ < 0 ? i$ > to$ : i$ < to$; i$ += step$) {
488
519
  i = i$;
package/utils/axis.min.js CHANGED
@@ -1 +1 @@
1
- !function(){var c,t;function d(t,e){var n,i={}.hasOwnProperty;for(n in e)i.call(e,n)&&(t[n]=e[n]);return t}c=function(t){return document.createElementNS("http://www.w3.org/2000/svg",t)},(t=function(t){var i,e=this;return this.dir={bottom:0,left:2}[(t=null==t?{}:t).direction||"bottom"],this.name=t.name||"axis",this.layout=t.layout||new layout({root:this.root}),this._ticks=[],this._scale=t.scale||function(t){return t},this._format=chart.utils.format.simple,this._config(t.cfg),this._map={},this._n=i={root:c("g"),layout:this.layout.getNode(this.name),render:this.layout.getGroup(this.name),wrap:null,domain:c("path")},i.render.appendChild(i.root),i.root.appendChild(i.domain),i.label=c("text"),i.label.textContent="",(t=i.label).setAttribute("dominant-baseline","hanging"),t.setAttribute("text-anchor","middle"),i.root.appendChild(i.label),i.sideNote=[0,1].map(function(t){var e,n=c("text");return n.textContent="",(e=n).setAttribute("dominant-baseline","hanging"),e.setAttribute("text-anchor",["start","end"][t]),i.root.appendChild(n)}),this.wrapper(),(t=this.layout).on("update",function(){return e.update()}),t.on("render",function(){return e.render()}),this}).prototype=d(Object.create(Object.prototype),{wrapper:function(){var t,e=this._n;return e.wrap&&e.wrap.parentNode&&e.wrap.parentNode.removeChild(e.wrap),e.wrap=document.createElement("div"),d(((t=e.wrap.style).visibility="hidden",t.position="absolute",t.top=0,t.left=0,t.pointerEvents="none",t.userSelect="none",t.zIndex=0,t.wordBreak="break-all",t.lineHeight=".95em",t),this.dir<2&&null!=this.cfg.textWidth?{whiteSpace:"wrap",width:(1<(t=this.cfg.textWidth)?t:1)+"em"}:{whiteSpace:"pre",width:"4em"}),e.layout.appendChild(e.wrap)},_config:function(e){var t,n=this;return null==e&&(e={}),this.cfg={tick:{inner:8},baseline:{},label:{padding:1,direction:"horizontal",gap:1.5,strategy:"stride",tolerance:.2},caption:{padding:1},enabled:e.enabled,sideNoteStart:{padding:1},sideNoteEnd:{padding:1}},["tick","baseline","label","caption","sideNoteStart","sideNoteEnd"].map(function(t){return d(n.cfg[t],e[t]||{})}),(t=this.cfg.label).font||(t.font={}),(t=this.cfg.caption).font||(t.font={}),(t=this.cfg.sideNoteStart).font||(t.font={}),(t=this.cfg.sideNoteEnd).font||(t.font={}),this.format(this.cfg.label.format)},config:function(t){return null==t?this.cfg:(this._config(t),this.wrapper())},format:function(t){return null==t?this._format:this._format="string"==typeof t?chart.utils.format.from(t):t||chart.utils.format.simple},scale:function(t){return null!=t?this._scale=t:this._scale},caption:function(t){return arguments.length&&(this._caption=t),!this.cfg.enabled||null!=this.cfg.caption.show&&!this.cfg.caption.show?this._n.label.textContent="":this._n.label.textContent=this.cfg.caption.text||this._caption||""},update:function(){},ticks:function(n){var t,e,i,a=this,r={},s=this._n.layout.getBoundingClientRect()[this.dir<2?"width":"height"],o=this.dir<2&&"vertical"===this.cfg.label.direction?12:25,s=Math.round(s/o),l=1<(t=Math.round(n.length/(1<s?s:1)))?t:1,h="ends"===this.cfg.label.strategy;for(e in this._ticks=n.filter(function(t,e){return!(e%l)||h&&e===n.length-1}).map(function(t){var e,n;return r[(t="object"!=typeof t?{v:t}:t).v]=d((e=a._map)[n=t.v]||(e[n]={}),t)}),t=this._map)i=t[e],r[e]||i.n.g.parentNode.removeChild(i.n.g);return this._map=r,this._ticks.filter(function(t){return!t.n}).map(function(t){if(t.n={g:c("g"),p:c("path"),t:c("g")},t.n.g.appendChild(t.n.p),t.n.g.appendChild(t.n.t),a._n.root.appendChild(t.n.g),isNaN(+t.v))return t.t=t.v})},render:function(){var i,t,a,e,n,r,s,o=this,l=this._n,h=this.dir<2,c=l.wrap;if(c.style.fontSize=this.cfg.label.font.size?this.cfg.label.font.size+""||"":void 0,c.setAttribute("class",(this.cfg.label.font.family||{}).className||""),i=this._ticks,null==this.cfg.enabled||this.cfg.enabled)return h?((t=l.layout.style).height="",t.paddingTop="",t.paddingBottom=""):((t=l.layout.style).width="",t.paddingLeft="",t.paddingRight=""),l.domain.style.display="",i.map(function(t){return t.n.g.style.display=""}),a=getComputedStyle(c).fontSize,e=l.layout.getBoundingClientRect(),(t=l.domain.style).strokeWidth=1,t.stroke="currentColor",t.fill="none",i.map(function(t,e){var n,e=e?e===i.length-1?2:1:0;return t._c=null!=t.c?t.c:o._scale(t.v)+(o._scale.bandwidth?o._scale.bandwidth()/2:0),t._t=null!=t.t?t.t:o._format(t.v),(n=t.n.p.style).strokeWidth=1,n.stroke="currentColor",n.fill="none",c.textContent=t._t,c.style.textAlign=h?["left","center","right"][e]:["right","left"][o.dir-2],t.n.tt=wrapSvgText({node:c}),t.n.t.style.fontSize=a,t.n.t.style.fill=o.cfg.label.color,t.n.t.textContent="",t.n.t.appendChild(t.n.tt),t.n.t.setAttribute("class",(o.cfg.label.font||{}).className||"")}),i.sort(function(t,e){return t._c-e._c}),l.domain.style.stroke=this.cfg.baseline.show?this.cfg.baseline.color:"none",n=(this.cfg.caption.position||0)%3,r=Math.floor((this.cfg.caption.position||0)/3),(s=l.label).setAttribute("text-anchor",["start","middle","end"][n]),s.setAttribute("dominant-baseline",["baseline","hanging"][r]),l.sideNote.map(function(t,e){e=(o.cfg[["sideNoteStart","sideNoteEnd"][e]]||{}).position||0;return t.setAttribute("dominant-baseline",["baseline","hanging"][e])}),h?(l.domain.setAttribute("d","M0 0L"+e.width+" 0Z"),l.label.setAttribute("x",e.width/2),l.label.setAttribute("x",[2,e.width/2,e.width-2][n])):(l.domain.setAttribute("d","M0 0L0 "+e.height+"Z"),s=[2,e.height/2,e.height-2][n],l.label.setAttribute("transform","translate(0,"+s+") rotate(90)")),i.map(function(t){return t.box=t.n.t.getBBox()}),this.adjust();h?((t=l.layout.style).height="0px",t.paddingTop="0",t.paddingBottom="0"):((t=l.layout.style).width="0px",t.paddingLeft="0",t.paddingRight="0"),l.domain.style.display="none",i.map(function(t){return t.n.g.style.display="none"})},adjust:function(){var r,t,e,a,s,n,i,o,l,h,c,d,f,u,g,p,b,m,y,_=this,w=this._ticks,v=this.dir<2,x=v&&"vertical"===this.cfg.label.direction,A=parseFloat(getComputedStyle(this._n.wrap).fontSize)||16;if(w.map(function(t,e){var e=e?e===w.length-1?2:1:0,n=t._c,i=t.box,a={x:-i.x,y:-i.y},r=!_._scale.bandwidth&&(null!=_.cfg.tick.boundaryOffset?!!_.cfg.tick.boundaryOffset:_.dir<2),r=!x&&r?e/2:.5;return x?(a.x-=i.width,a.y-=i.height*r):v?a.x-=i.width*r:a.y-=i.height*r,t.n.tt.setAttribute("transform","translate("+a.x+","+a.y+")"),t._size=x?i.height:i[v?"width":"height"],t._sizeAlt=x?i.width:i[v?"height":"width"],t._start=n-t._size*r,v?(t.n.g.setAttribute("transform","translate("+n+",0)"),t.n.p.setAttribute("d","M0 0L0 "+_.cfg.tick.inner),e=_.cfg.tick.inner+_.cfg.label.padding,t.n.t.setAttribute("transform","translate(0,"+e+")"+(x?" rotate(-90)":""))):(t.n.g.setAttribute("transform","translate(0,"+n+")"),t.n.p.setAttribute("d","M0 0L-"+_.cfg.tick.inner+" 0"),t.n.t.setAttribute("transform","translate("+(-_.cfg.tick.inner-t._sizeAlt-1-_.cfg.label.padding)+",0)")),t.n.p.style.stroke=_.cfg.tick.color||""}),r=A*(null!=this.cfg.label.gap?this.cfg.label.gap:1.5),t=function(t){for(var e,n=null,i=0,a=t.length;i<a;++i){if(e=t[i],e=w[e],null!=n&&e._start-(n._start+n._size)<r)return!1;n=e}return!0},e=[0],1<w.length)if("ends"!==this.cfg.label.strategy){for(a=1;a<w.length&&!t((()=>{var t,e,n,i=[];for(t=0,n=w.length,e=a;e<0?n<t:t<n;t+=e)s=t,i.push(s);return i})());)a++;for(n=[],i=0,o=w.length;a<0?o<i:i<o;i+=a)s=i,n.push(s);e=n}else for(l=null!=this.cfg.label.tolerance?this.cfg.label.tolerance:.2,A=[w[0]._c,w[w.length-1]._c],h=A[0],c=A[1],d=function(t){for(var e,n,i,a,r,s=[],o=0;o<=t;++o){for(e=h+(c-h)*o/t,n=0,i=1,a=w.length;i<a;++i)r=i,Math.abs(w[r]._c-e)<Math.abs(w[n]._c-e)&&(n=r);s[s.length-1]!==n&&s.push(n)}return s},f=function(t){var e,n,i,a;if(!(t.length<3)&&(e=(w[t[t.length-1]]._c-w[t[0]]._c)/(t.length-1)))for(n=0,i=t.length-1;n<i;++n)if(a=w[t[(a=n)+1]]._c-w[t[a]]._c,Math.abs(a-e)>e*l+.5)return!1;return!0},i=w.length-1;1<=i;--i)if(1<(u=d(i)).length&&f(u)&&t(u)){e=u;break}return g={},e.map(function(t){return g[t]=!0}),w.map(function(t,e){return t.n.t.style.opacity=g[e]?1:0}),A=w.filter(function(t,e){return g[e]}),this._n.label.style.fill=this.cfg.caption.color,this._n.label.style.fontSize=this.cfg.caption.font.size?this.cfg.caption.font.size+""||"":void 0,this._n.label.setAttribute("class",(this.cfg.caption.font.family||{}).className||""),this.caption(),this._n.sideNote.map(function(t,e){var e=_.cfg[["sideNoteStart","sideNoteEnd"][e]]||{},n=e.font||{};return t.textContent=e.show&&e.text||"",t.style.fill=e.color,t.style.fontSize=n.size?n.size+""||"":void 0,t.setAttribute("class",(n.family||{}).className||"")}),p=(this.cfg.caption.position||0)%3,b=Math.floor((this.cfg.caption.position||0)/3),A=Math.max.apply(Math,[0].concat(A.map(function(t){return t._sizeAlt}))),m=this.cfg.tick.inner+this.cfg.label.padding+this.cfg.caption.padding+A,this.dir<2?(this._n.label.setAttribute("y",[-2,m][b]),this._n.layout.style.height=m+this._n.label.getBoundingClientRect().height+"px",y=this._n.layout.getBoundingClientRect(),this._n.sideNote.map(function(t,e){var n=_.cfg[["sideNoteStart","sideNoteEnd"][e]]||{},i=n.position||0;return t.setAttribute("x",[2,y.width-2][e]),t.setAttribute("y",[-2-n.padding,m+n.padding][i])})):(this._n.label.setAttribute("x",0),this._n.label.setAttribute("y",0),this._n.layout.style.width=m+this._n.label.getBoundingClientRect().width+"px",A=[2,(y=this._n.layout.getBoundingClientRect()).height/2,y.height-2][p],this._n.label.setAttribute("transform","translate("+[2,-m-2][b]+","+A+") rotate(90)"),this._n.root.setAttribute("transform","translate("+(y.width-1)+",0)"),this._n.sideNote.map(function(t,e){var n=_.cfg[["sideNoteStart","sideNoteEnd"][e]]||{},i=n.position||0,e=[2,y.height-2][e];return t.setAttribute("transform","translate("+[2+n.padding,-m-2-n.padding][i]+","+e+") rotate(90)")}))}}),"undefined"!=typeof chart&&null!==chart&&((chart.utils||(chart.utils={})).axis=t)}.call(this);
1
+ !function(){var c,t;function d(t,e){var n,i={}.hasOwnProperty;for(n in e)i.call(e,n)&&(t[n]=e[n]);return t}c=function(t){return document.createElementNS("http://www.w3.org/2000/svg",t)},(t=function(t){var i,e=this;return this.dir={bottom:0,left:2}[(t=null==t?{}:t).direction||"bottom"],this.name=t.name||"axis",this.layout=t.layout||new layout({root:this.root}),this._ticks=[],this._scale=t.scale||function(t){return t},this._format=chart.utils.format.simple,this._config(t.cfg),this._map={},this._n=i={root:c("g"),layout:this.layout.getNode(this.name),render:this.layout.getGroup(this.name),wrap:null,domain:c("path")},i.render.appendChild(i.root),i.root.appendChild(i.domain),i.label=c("text"),i.label.textContent="",(t=i.label).setAttribute("dominant-baseline","hanging"),t.setAttribute("text-anchor","middle"),i.root.appendChild(i.label),i.sideNote=[0,1].map(function(t){var e,n=c("text");return n.textContent="",(e=n).setAttribute("dominant-baseline","hanging"),e.setAttribute("text-anchor",["start","end"][t]),i.root.appendChild(n)}),this.wrapper(),(t=this.layout).on("update",function(){return e.update()}),t.on("render",function(){return e.render()}),this}).prototype=d(Object.create(Object.prototype),{wrapper:function(){var t,e=this._n;return e.wrap&&e.wrap.parentNode&&e.wrap.parentNode.removeChild(e.wrap),e.wrap=document.createElement("div"),d(((t=e.wrap.style).visibility="hidden",t.position="absolute",t.top=0,t.left=0,t.pointerEvents="none",t.userSelect="none",t.zIndex=0,t.wordBreak="break-all",t.lineHeight=".95em",t),this.dir<2&&null!=this.cfg.textWidth?{whiteSpace:"wrap",width:(1<(t=this.cfg.textWidth)?t:1)+"em"}:{whiteSpace:"pre",width:"4em"}),e.layout.appendChild(e.wrap)},_config:function(e){var t,n=this;return null==e&&(e={}),this.cfg={tick:{inner:8},baseline:{},label:{padding:1,direction:"horizontal",gap:1.5,strategy:"stride",tolerance:.2},caption:{padding:1},enabled:e.enabled,sideNoteStart:{padding:1},sideNoteEnd:{padding:1}},["tick","baseline","label","caption","sideNoteStart","sideNoteEnd"].map(function(t){return d(n.cfg[t],e[t]||{})}),(t=this.cfg.label).font||(t.font={}),(t=this.cfg.caption).font||(t.font={}),(t=this.cfg.sideNoteStart).font||(t.font={}),(t=this.cfg.sideNoteEnd).font||(t.font={}),this.format(this.cfg.label.format)},config:function(t){return null==t?this.cfg:(this._config(t),this.wrapper())},format:function(t){return null==t?this._format:this._format="string"==typeof t?chart.utils.format.from(t):t||chart.utils.format.simple},scale:function(t){return null!=t?this._scale=t:this._scale},caption:function(t){return arguments.length&&(this._caption=t),!this.cfg.enabled||null!=this.cfg.caption.show&&!this.cfg.caption.show?this._n.label.textContent="":this._n.label.textContent=this.cfg.caption.text||this._caption||""},update:function(){},ticks:function(n){var t,e,i,a=this,r={},o=this._n.layout.getBoundingClientRect()[this.dir<2?"width":"height"],s=this.dir<2&&"horizontal"!==this.cfg.label.direction?12:25,o=Math.round(o/s),l=1<(t=Math.round(n.length/(1<o?o:1)))?t:1,h="ends"===this.cfg.label.strategy;for(e in this._ticks=n.filter(function(t,e){return!(e%l)||h&&e===n.length-1}).map(function(t){var e,n;return r[(t="object"!=typeof t?{v:t}:t).v]=d((e=a._map)[n=t.v]||(e[n]={}),t)}),t=this._map)i=t[e],r[e]||i.n.g.parentNode.removeChild(i.n.g);return this._map=r,this._ticks.filter(function(t){return!t.n}).map(function(t){if(t.n={g:c("g"),p:c("path"),t:c("g")},t.n.g.appendChild(t.n.p),t.n.g.appendChild(t.n.t),a._n.root.appendChild(t.n.g),isNaN(+t.v))return t.t=t.v})},render:function(){var i,t,a,e,n,r,o,s=this,l=this._n,h=this.dir<2,c=l.wrap;if(c.style.fontSize=this.cfg.label.font.size?this.cfg.label.font.size+""||"":void 0,c.setAttribute("class",(this.cfg.label.font.family||{}).className||""),i=this._ticks,null==this.cfg.enabled||this.cfg.enabled)return h?((t=l.layout.style).height="",t.paddingTop="",t.paddingBottom=""):((t=l.layout.style).width="",t.paddingLeft="",t.paddingRight=""),l.domain.style.display="",i.map(function(t){return t.n.g.style.display=""}),a=getComputedStyle(c).fontSize,e=l.layout.getBoundingClientRect(),(t=l.domain.style).strokeWidth=1,t.stroke="currentColor",t.fill="none",i.map(function(t,e){var n,e=e?e===i.length-1?2:1:0;return t._c=null!=t.c?t.c:s._scale(t.v)+(s._scale.bandwidth?s._scale.bandwidth()/2:0),t._t=null!=t.t?t.t:s._format(t.v),(n=t.n.p.style).strokeWidth=1,n.stroke="currentColor",n.fill="none",c.textContent=t._t,c.style.textAlign=h?["left","center","right"][e]:["right","left"][s.dir-2],t.n.tt=wrapSvgText({node:c}),t.n.t.style.fontSize=a,t.n.t.style.fill=s.cfg.label.color,t.n.t.textContent="",t.n.t.appendChild(t.n.tt),t.n.t.setAttribute("class",(s.cfg.label.font||{}).className||"")}),i.sort(function(t,e){return t._c-e._c}),l.domain.style.stroke=this.cfg.baseline.show?this.cfg.baseline.color:"none",n=(this.cfg.caption.position||0)%3,r=Math.floor((this.cfg.caption.position||0)/3),(o=l.label).setAttribute("text-anchor",["start","middle","end"][n]),o.setAttribute("dominant-baseline",["baseline","hanging"][r]),l.sideNote.map(function(t,e){e=(s.cfg[["sideNoteStart","sideNoteEnd"][e]]||{}).position||0;return t.setAttribute("dominant-baseline",["baseline","hanging"][e])}),h?(l.domain.setAttribute("d","M0 0L"+e.width+" 0Z"),l.label.setAttribute("x",e.width/2),l.label.setAttribute("x",[2,e.width/2,e.width-2][n])):(l.domain.setAttribute("d","M0 0L0 "+e.height+"Z"),o=[2,e.height/2,e.height-2][n],l.label.setAttribute("transform","translate(0,"+o+") rotate(90)")),i.map(function(t){return t.box=t.n.t.getBBox()}),this.adjust();h?((t=l.layout.style).height="0px",t.paddingTop="0",t.paddingBottom="0"):((t=l.layout.style).width="0px",t.paddingLeft="0",t.paddingRight="0"),l.domain.style.display="none",i.map(function(t){return t.n.g.style.display="none"})},adjust:function(){for(var t,a,e,n,i,r,o,l,h,s,c,d,f,u,g,p,b,m,y=this,_=this._ticks,w=this.dir<2,x=(parseFloat(getComputedStyle(this._n.wrap).fontSize)||16)*(null!=this.cfg.label.gap?this.cfg.label.gap:1.5),v=function(t){for(var e,n=null,i=0,a=t.length;i<a;++i){if(e=t[i],e=_[e],null!=n&&e._start-(n._start+n._size)<x)return!1;n=e}return!0},A=function(t,e,n){var i=w&&"vertical"===n,n=w&&"angled"===n,a=null!=y.cfg.label.angle?y.cfg.label.angle:45,r=[Math.cos(a*Math.PI/180),Math.sin(a*Math.PI/180)],o=r[0],r=r[1],e=e?e===_.length-1?2:1:0,s=t._c,l=t.box,h={x:-l.x,y:-l.y},c=!y._scale.bandwidth&&(null!=y.cfg.tick.boundaryOffset?!!y.cfg.tick.boundaryOffset:y.dir<2),c=!i&&c?e/2:.5;return i?(h.x-=l.width,h.y-=l.height*c):n?h.x-=l.width:w?h.x-=l.width*c:h.y-=l.height*c,t.n.tt.setAttribute("transform","translate("+h.x+","+h.y+")"),t._size=i?l.height:n?l.width*o+l.height*r:l[w?"width":"height"],t._sizeAlt=i?l.width:n?l.width*r+l.height*o:l[w?"height":"width"],t._start=n?s-l.width*o:s-t._size*c,w?(t.n.g.setAttribute("transform","translate("+s+",0)"),t.n.p.setAttribute("d","M0 0L0 "+y.cfg.tick.inner),e=y.cfg.tick.inner+y.cfg.label.padding,t.n.t.setAttribute("transform","translate(0,"+e+")"+(i?" rotate(-90)":n?" rotate("+-a+")":""))):(t.n.g.setAttribute("transform","translate(0,"+s+")"),t.n.p.setAttribute("d","M0 0L-"+y.cfg.tick.inner+" 0"),t.n.t.setAttribute("transform","translate("+(-y.cfg.tick.inner-t._sizeAlt-1-y.cfg.label.padding)+",0)")),t.n.p.style.stroke=y.cfg.tick.color||""},N=w&&"auto"===this.cfg.label.direction?["horizontal","angled","vertical"]:[this.cfg.label.direction||"horizontal"],C=[],k=0,z=_.length;k<z;++k)a=k,C.push(a);for(t=C,k=0,e=N.length;k<e&&(n=N[k],_.map(S),!v(t));++k);if(i=[0],1<_.length)if("ends"!==this.cfg.label.strategy){for(r=1;r<_.length&&!v((()=>{var t,e,n,i=[];for(t=0,n=_.length,e=r;e<0?n<t:t<n;t+=e)a=t,i.push(a);return i})());)r++;for(C=[],k=0,z=_.length;r<0?z<k:k<z;k+=r)a=k,C.push(a);i=C}else for(o=null!=this.cfg.label.tolerance?this.cfg.label.tolerance:.2,m=[_[0]._c,_[_.length-1]._c],l=m[0],h=m[1],s=function(t){for(var e,n,i,a,r,o=[],s=0;s<=t;++s){for(e=l+(h-l)*s/t,n=0,i=1,a=_.length;i<a;++i)r=i,Math.abs(_[r]._c-e)<Math.abs(_[n]._c-e)&&(n=r);o[o.length-1]!==n&&o.push(n)}return o},c=function(t){var e,n,i,a;if(!(t.length<3)&&(e=(_[t[t.length-1]]._c-_[t[0]]._c)/(t.length-1)))for(n=0,i=t.length-1;n<i;++n)if(a=_[t[(a=n)+1]]._c-_[t[a]]._c,Math.abs(a-e)>e*o+.5)return!1;return!0},k=_.length-1;1<=k;--k)if(1<(d=s(k)).length&&c(d)&&v(d)){i=d;break}return f={},i.map(function(t){return f[t]=!0}),_.map(function(t,e){return t.n.t.style.opacity=f[e]?1:0}),m=_.filter(function(t,e){return f[e]}),this._n.label.style.fill=this.cfg.caption.color,this._n.label.style.fontSize=this.cfg.caption.font.size?this.cfg.caption.font.size+""||"":void 0,this._n.label.setAttribute("class",(this.cfg.caption.font.family||{}).className||""),this.caption(),this._n.sideNote.map(function(t,e){var e=y.cfg[["sideNoteStart","sideNoteEnd"][e]]||{},n=e.font||{};return t.textContent=e.show&&e.text||"",t.style.fill=e.color,t.style.fontSize=n.size?n.size+""||"":void 0,t.setAttribute("class",(n.family||{}).className||"")}),u=(this.cfg.caption.position||0)%3,g=Math.floor((this.cfg.caption.position||0)/3),m=Math.max.apply(Math,[0].concat(m.map(function(t){return t._sizeAlt}))),p=this.cfg.tick.inner+this.cfg.label.padding+this.cfg.caption.padding+m,this.dir<2?(this._n.label.setAttribute("y",[-2,p][g]),this._n.layout.style.height=p+this._n.label.getBoundingClientRect().height+"px",b=this._n.layout.getBoundingClientRect(),this._n.sideNote.map(function(t,e){var n=y.cfg[["sideNoteStart","sideNoteEnd"][e]]||{},i=n.position||0;return t.setAttribute("x",[2,b.width-2][e]),t.setAttribute("y",[-2-n.padding,p+n.padding][i])})):(this._n.label.setAttribute("x",0),this._n.label.setAttribute("y",0),this._n.layout.style.width=p+this._n.label.getBoundingClientRect().width+"px",m=[2,(b=this._n.layout.getBoundingClientRect()).height/2,b.height-2][u],this._n.label.setAttribute("transform","translate("+[2,-p-2][g]+","+m+") rotate(90)"),this._n.root.setAttribute("transform","translate("+(b.width-1)+",0)"),this._n.sideNote.map(function(t,e){var n=y.cfg[["sideNoteStart","sideNoteEnd"][e]]||{},i=n.position||0,e=[2,b.height-2][e];return t.setAttribute("transform","translate("+[2+n.padding,-p-2-n.padding][i]+","+e+") rotate(90)")}));function S(t,e){return A(t,e,n)}}}),"undefined"!=typeof chart&&null!==chart&&((chart.utils||(chart.utils={})).axis=t)}.call(this);
package/utils/bin.js CHANGED
@@ -196,14 +196,27 @@
196
196
  return ret;
197
197
  },
198
198
  parse: function(opt){
199
- var ref$, kv, ks, kn, cfg, sb, series, rows, all, info, vals, wts, counts, sub, shrink, labels, res$, i$, to$, i, data, d, ref1$, x0, x1;
199
+ var ref$, kv, ks, kn, cfg, sb, vk, keep, res$, i$, len$, i, b, series, rows, all, info, vals, wts, counts, sub, shrink, labels, to$, data, d, ref1$, x0, x1;
200
200
  opt == null && (opt = {});
201
201
  ref$ = [opt.value || 'value', opt.size || 'size', opt.name || 'name'], kv = ref$[0], ks = ref$[1], kn = ref$[2];
202
202
  cfg = opt.config || (this.cfg || {}).bin || {};
203
203
  sb = this.binding[ks];
204
- series = !sb
205
- ? 0
206
- : Array.isArray(sb) ? sb.length : 1;
204
+ sb = !sb
205
+ ? []
206
+ : Array.isArray(sb)
207
+ ? sb
208
+ : [sb];
209
+ vk = (this.binding[kv] || {}).key;
210
+ res$ = [];
211
+ for (i$ = 0, len$ = sb.length; i$ < len$; ++i$) {
212
+ i = i$;
213
+ b = sb[i$];
214
+ if (!(b && b.key === vk)) {
215
+ res$.push(i);
216
+ }
217
+ }
218
+ keep = res$;
219
+ series = keep.length;
207
220
  rows = this._parseRows(this.raw || []);
208
221
  all = this._frames && ((typeof chart != 'undefined' && chart !== null) && ((ref$ = chart.scopes) != null && ref$.frame)) ? chart.scopes.frame.all.call(this) : rows;
209
222
  info = bin.edges(all.map(function(it){
@@ -218,8 +231,12 @@
218
231
  if (!series) {
219
232
  return null;
220
233
  } else {
221
- return rs.map(function(it){
222
- return [].concat(it[ks]);
234
+ return rs.map(function(r){
235
+ var s;
236
+ s = [].concat(r[ks]);
237
+ return keep.map(function(it){
238
+ return s[it];
239
+ });
223
240
  });
224
241
  }
225
242
  };
@@ -273,7 +290,8 @@
273
290
  return {
274
291
  data: data,
275
292
  info: info,
276
- series: series || 1
293
+ series: series || 1,
294
+ keep: keep
277
295
  };
278
296
  function fn$(it){
279
297
  return !it;
package/utils/bin.min.js CHANGED
@@ -1 +1 @@
1
- !function(){var d,g,p,a,b,M,_;d=1e-9,g=function(t){return+(+t).toPrecision(12)},p=function(t){return Math.abs(t-Math.round(t))<d},a=function(t,e){var t=t/(1<e?e:1);return 0<t?(t=(t=t/(e=Math.pow(10,Math.floor(Math.log10(t)))))>=Math.sqrt(50)?10:t>=Math.sqrt(10)?5:t>=Math.sqrt(2)?2:1,g(t*e)):1},b=function(t,e,n,r){r=0<r.count?r.count:Math.ceil(Math.log2(1<(r=t.length)?r:1))+1;return n===e&&p(e)||(n=e<n?n-e:Math.abs(e)||1,e=a(n,r),t.every(p)&&e<1)?1:e},M=function(t,e){t=(t-e.start)/e.width;return Math.abs(t-Math.round(t))<d&&(t=Math.round(t)),"right"===e.closed?Math.ceil(t)-1:Math.floor(t)},_={edges:function(t,e){var n,r,a,s,i,u,l,o,h,c,f;if(null==e&&(e={}),t=(t=null==t?[]:t).filter(function(t){return"number"==typeof t&&isFinite(t)}),n="right"===e.closed?"right":"left",r=isFinite(+e.anchor)?+e.anchor:0,a=e.max||500,!t.length)return{start:r,width:+e.width||1,anchor:r,closed:n,discrete:!1,n:0,edges:[]};for(u={width:i=a<((s=(a=[Math.min.apply(Math,t),Math.max.apply(Math,t)])[1])-(l=a[0]))/(i=0<+e.width?+e.width:b(t,l,s,e))?b(t,l,s,{count:e.count}):i,anchor:r,closed:n,discrete:e=p(i)&&p(r)&&t.every(p)},t=(l-r)/i,Math.abs(t-Math.round(t))<d&&(t=Math.round(t)),u.start=g(r+i*("left"==n?Math.floor(t):!e&&p(t)?t:Math.ceil(t)-1)),l=M(s,u),!e&&"left"==n&&0<l&&p((s-u.start)/i)&&(l-=1),u.n=1<(a=l+1)?a:1,o=[],h=0,c=u.n;h<=c;++h)f=h,o.push(g(u.start+i*f));return u.edges=o,u},index:function(t,e){var n;return"number"!=typeof t||!isFinite(t)||!e.n||(n=M(t,e),e.discrete||-1===(n=n===e.n&&"left"===e.closed&&Math.abs(t-e.edges[e.n])<d*e.width?e.n-1:n)&&"right"===e.closed&&Math.abs(t-e.edges[0])<d*e.width&&(n=0),n<0)||n>=e.n?-1:n},range:function(t,e){var t=[e.edges[t],e.edges[t+1]],n=t[0],t=t[1];return e.discrete?"right"===e.closed?[g(n+1),t]:[n,g(t-1)]:[n,t]},label:function(t,e,n){var r,a=(n=null==n?{}:n).format&&"undefined"!=typeof chart&&null!==chart&&null!=(r=chart.utils)&&r.format?chart.utils.format.from(n.format):function(t){return g(t)+""},s=(r=_.range(t,e))[0],i=r[1];switch(n.label){case"start":return a(s);case"center":return a(g((e.edges[t]+e.edges[t+1])/2));default:return s===i?a(s):a(s)+"–"+a(i)}},count:function(t,e,n){var r,a,s,i,u,l,o,h,c,f,d,g,p;for(null==t&&(t=[]),r=n&&1<(a=(n[0]||[]).length)?a:1,i=[],u=0,l=e.n;u<l;++u)o=u,i.push(((t,e)=>{for(var n=[];0<e;(e>>=1)&&(t=t.concat(t)))1&e&&n.push.apply(n,t);return n})([0],r));for(s=i,u=0,h=t.length;u<h;++u)if(f=t[c=u],!((o=_.index(f,e))<0))if(n)for(d=0;d<r;++d)g=d,p=+(n[c]||[])[g],isFinite(p)&&(s[o][g]+=p);else s[o][0]+=1;return s},parse:function(t){for(var e,n,r,a,s,i,u,l=[(t=null==t?{}:t).value||"value",t.size||"size",t.name||"name"],o=l[0],h=l[1],c=l[2],f=t.config||(this.cfg||{}).bin||{},t=this.binding[h],d=t?Array.isArray(t)?t.length:1:0,t=this._parseRows(this.raw||[]),l=this._frames&&"undefined"!=typeof chart&&null!==chart&&null!=(l=chart.scopes)&&l.frame?chart.scopes.frame.all.call(this):t,g=_.edges(l.map(function(t){return t[o]}),f),l=function(t){return d?t.map(function(t){return[].concat(t[h])}):null},p=_.count((e=function(t){return t.map(function(t){return t[o]})})(t),g,l(t)),b=this._subset?_.count(e(this._parseRows(this._subset)),g,l(this._parseRows(this._subset))):null,M="shrink"===(((this.cfg||{}).common||{}).subset||{}).mode,m=[],v=0,y=g.n;v<y;++v)r=v,m.push(_.label(r,g,f));if(n=m,new Set(n).size!==n.length){for(m=[],v=0,y=g.n;v<y;++v)r=v,m.push(_.label(r,g,{label:f.label}));n=m}for(a=[],v=0,y=g.n;v<y;++v)r=v,!1===f.empty&&p[r].every(w)||((s={})[c]=n[r],s[h]=p[r],u=(i=[g.edges[r],g.edges[r+1]])[0],s.bin={x0:u,x1:i[1],index:r},b&&(s.subset={},s.subset[h]=b[r],M)&&(s[h]=b[r]),s._idx=a.length,s._raw=((i=((t,e)=>{var n,r={}.hasOwnProperty;for(n in e)r.call(e,n)&&(t[n]=e[n]);return t})({},s.bin)).count=p[r],i),a.push(s));return{data:a,info:g,series:d||1};function w(t){return!t}},filter:function(t,e,n){var r=[n.edges[t],n.edges[e+1]],a=n.closed;return n.discrete||"right"===(a="left"===a&&e===n.n-1?"both":a)&&0===t&&(a="both"),{type:"range",value:[r[0],r[1]],closed:a}},select:function(t,e){var n,r,a,s,i,u;if(!t||"range"!==t.type||!Array.isArray(t.value)||!e.n)return null;for(n=(t=t.value)[0],r=t[1],a=[],s=0,i=e.n;s<i;++s)u=s,e.edges[u+1]>n&&e.edges[u]<r&&a.push(u);return(t=a).length?[t[0],t[t.length-1]]:null}},"undefined"!=typeof chart&&null!==chart&&((chart.utils||(chart.utils={})).bin=_)}.call(this);
1
+ !function(){var d,g,p,a,b,M,q;d=1e-9,g=function(t){return+(+t).toPrecision(12)},p=function(t){return Math.abs(t-Math.round(t))<d},a=function(t,e){var t=t/(1<e?e:1);return 0<t?(t=(t=t/(e=Math.pow(10,Math.floor(Math.log10(t)))))>=Math.sqrt(50)?10:t>=Math.sqrt(10)?5:t>=Math.sqrt(2)?2:1,g(t*e)):1},b=function(t,e,n,r){r=0<r.count?r.count:Math.ceil(Math.log2(1<(r=t.length)?r:1))+1;return n===e&&p(e)||(n=e<n?n-e:Math.abs(e)||1,e=a(n,r),t.every(p)&&e<1)?1:e},M=function(t,e){t=(t-e.start)/e.width;return Math.abs(t-Math.round(t))<d&&(t=Math.round(t)),"right"===e.closed?Math.ceil(t)-1:Math.floor(t)},q={edges:function(t,e){var n,r,a,s,i,u,l,o,h,c,f;if(null==e&&(e={}),t=(t=null==t?[]:t).filter(function(t){return"number"==typeof t&&isFinite(t)}),n="right"===e.closed?"right":"left",r=isFinite(+e.anchor)?+e.anchor:0,a=e.max||500,!t.length)return{start:r,width:+e.width||1,anchor:r,closed:n,discrete:!1,n:0,edges:[]};for(u={width:i=a<((s=(a=[Math.min.apply(Math,t),Math.max.apply(Math,t)])[1])-(l=a[0]))/(i=0<+e.width?+e.width:b(t,l,s,e))?b(t,l,s,{count:e.count}):i,anchor:r,closed:n,discrete:e=p(i)&&p(r)&&t.every(p)},t=(l-r)/i,Math.abs(t-Math.round(t))<d&&(t=Math.round(t)),u.start=g(r+i*("left"==n?Math.floor(t):!e&&p(t)?t:Math.ceil(t)-1)),l=M(s,u),!e&&"left"==n&&0<l&&p((s-u.start)/i)&&(l-=1),u.n=1<(a=l+1)?a:1,o=[],h=0,c=u.n;h<=c;++h)f=h,o.push(g(u.start+i*f));return u.edges=o,u},index:function(t,e){var n;return"number"!=typeof t||!isFinite(t)||!e.n||(n=M(t,e),e.discrete||-1===(n=n===e.n&&"left"===e.closed&&Math.abs(t-e.edges[e.n])<d*e.width?e.n-1:n)&&"right"===e.closed&&Math.abs(t-e.edges[0])<d*e.width&&(n=0),n<0)||n>=e.n?-1:n},range:function(t,e){var t=[e.edges[t],e.edges[t+1]],n=t[0],t=t[1];return e.discrete?"right"===e.closed?[g(n+1),t]:[n,g(t-1)]:[n,t]},label:function(t,e,n){var r,a=(n=null==n?{}:n).format&&"undefined"!=typeof chart&&null!==chart&&null!=(r=chart.utils)&&r.format?chart.utils.format.from(n.format):function(t){return g(t)+""},s=(r=q.range(t,e))[0],i=r[1];switch(n.label){case"start":return a(s);case"center":return a(g((e.edges[t]+e.edges[t+1])/2));default:return s===i?a(s):a(s)+"–"+a(i)}},count:function(t,e,n){var r,a,s,i,u,l,o,h,c,f,d,g,p;for(null==t&&(t=[]),r=n&&1<(a=(n[0]||[]).length)?a:1,i=[],u=0,l=e.n;u<l;++u)o=u,i.push(((t,e)=>{for(var n=[];0<e;(e>>=1)&&(t=t.concat(t)))1&e&&n.push.apply(n,t);return n})([0],r));for(s=i,u=0,h=t.length;u<h;++u)if(f=t[c=u],!((o=q.index(f,e))<0))if(n)for(d=0;d<r;++d)g=d,p=+(n[c]||[])[g],isFinite(p)&&(s[o][g]+=p);else s[o][0]+=1;return s},parse:function(t){for(var n,e,r,a,s,i,u,l,o,h,c,f,d,g,p,b=[(t=null==t?{}:t).value||"value",t.size||"size",t.name||"name"],M=b[0],m=b[1],v=b[2],y=t.config||(this.cfg||{}).bin||{},w=(w=this.binding[m])?Array.isArray(w)?w:[w]:[],_=(this.binding[M]||{}).key,x=[],k=0,A=w.length;k<A;++k)(r=w[e=k])&&r.key===_||x.push(e);for(a=(n=x).length,t=this._parseRows(this.raw||[]),b=this._frames&&"undefined"!=typeof chart&&null!==chart&&null!=(b=chart.scopes)&&b.frame?chart.scopes.frame.all.call(this):t,s=q.edges(b.map(function(t){return t[M]}),y),b=function(t){return a?t.map(function(t){var e=[].concat(t[m]);return n.map(function(t){return e[t]})}):null},u=q.count((i=function(t){return t.map(function(t){return t[M]})})(t),s,b(t)),l=this._subset?q.count(i(this._parseRows(this._subset)),s,b(this._parseRows(this._subset))):null,o="shrink"===(((this.cfg||{}).common||{}).subset||{}).mode,x=[],k=0,c=s.n;k<c;++k)e=k,x.push(q.label(e,s,y));if(h=x,new Set(h).size!==h.length){for(x=[],k=0,c=s.n;k<c;++k)e=k,x.push(q.label(e,s,{label:y.label}));h=x}for(f=[],k=0,c=s.n;k<c;++k)e=k,!1===y.empty&&u[e].every(F)||((d={})[v]=h[e],d[m]=u[e],p=(g=[s.edges[e],s.edges[e+1]])[0],d.bin={x0:p,x1:g[1],index:e},l&&(d.subset={},d.subset[m]=l[e],o)&&(d[m]=l[e]),d._idx=f.length,d._raw=((g=((t,e)=>{var n,r={}.hasOwnProperty;for(n in e)r.call(e,n)&&(t[n]=e[n]);return t})({},d.bin)).count=u[e],g),f.push(d));return{data:f,info:s,series:a||1,keep:n};function F(t){return!t}},filter:function(t,e,n){var r=[n.edges[t],n.edges[e+1]],a=n.closed;return n.discrete||"right"===(a="left"===a&&e===n.n-1?"both":a)&&0===t&&(a="both"),{type:"range",value:[r[0],r[1]],closed:a}},select:function(t,e){var n,r,a,s,i,u;if(!t||"range"!==t.type||!Array.isArray(t.value)||!e.n)return null;for(n=(t=t.value)[0],r=t[1],a=[],s=0,i=e.n;s<i;++s)u=s,e.edges[u+1]>n&&e.edges[u]<r&&a.push(u);return(t=a).length?[t[0],t[t.length-1]]:null}},"undefined"!=typeof chart&&null!==chart&&((chart.utils||(chart.utils={})).bin=q)}.call(this);
package/utils/config.js CHANGED
@@ -86,6 +86,10 @@
86
86
  type: 'boolean',
87
87
  'default': true
88
88
  },
89
+ actions: {
90
+ type: 'boolean',
91
+ 'default': true
92
+ },
89
93
  enabled: {
90
94
  type: 'boolean',
91
95
  'default': true
@@ -226,7 +230,14 @@
226
230
  direction: {
227
231
  type: 'choice',
228
232
  'default': 'horizontal',
229
- values: ['horizontal', 'vertical']
233
+ values: ['horizontal', 'angled', 'vertical', 'auto']
234
+ },
235
+ angle: {
236
+ type: 'number',
237
+ 'default': 45,
238
+ min: 0,
239
+ max: 90,
240
+ step: 1
230
241
  },
231
242
  gap: {
232
243
  type: 'number',