@plotdb/chart 3.9.1 → 3.10.1

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.min.js CHANGED
@@ -1 +1 @@
1
- !function(){var i,f,c,p,t,n,s,r,o,e,a,u,l,h,m,d,y,g,_;function v(t,i,c){function p(t,i){return n.call(t,i)}var m={}.toString,n={}.hasOwnProperty,d=!0;return function t(i,n,e){var r,s,o,a,u,l,h,f;if(null==i||null==n)return i===n;if(i.__placeholder__||n.__placeholder__)return!0;if(i===n)return 0!==i||1/i==1/n;r=m.call(i);if(m.call(n)!=r)return!1;switch(r){case"[object String]":return i==String(n);case"[object Number]":return i!=+i?n!=+n:0==i?1/i==1/n:i==+n;case"[object Date]":case"[object Boolean]":return+i==+n;case"[object RegExp]":return i.source==n.source&&i.global==n.global&&i.multiline==n.multiline&&i.ignoreCase==n.ignoreCase}if("object"!=typeof i||"object"!=typeof n)return!1;s=e.length;for(;s--;)if(e[s]==i)return!0;e.push(i);o=0;a=!0;if("[object Array]"==r){if(u=i.length,l=n.length,d){switch(c){case"===":a=u===l;break;case"<==":a=u<=l;break;case"<<=":a=u<l}o=u,d=!1}else a=u===l,o=u;if(a)for(;o--&&(a=o in i==o in n&&t(i[o],n[o],e)););}else{if("constructor"in i!="constructor"in n||i.constructor!=n.constructor)return!1;for(h in i)if(p(i,h)&&(o++,!(a=p(n,h)&&t(i[h],n[h],e))))break;if(a){for(h in f=0,n)p(n,h)&&++f;a=d?"<<="===c?o<f:"<=="===c?o<=f:o===f:(d=!1,o===f)}}e.pop();return a}(t,i,[])}function b(t,i){var n,e={}.hasOwnProperty;for(n in i)e.call(i,n)&&(t[n]=i[n]);return t}i=new function(t){var n=new Intl.NumberFormat(t),t=n.formatToParts(12345.6),i=Array.from({length:10}).map(function(t,i){return n.format(i)}),e=new Map(i.map(function(t,i){return[t,i]}));return this._group=new RegExp("["+t.find(function(t){return v(t.type,"group","===")}).value+"]","g"),this._decimal=new RegExp("["+t.find(function(t){return v(t.type,"decimal","===")}).value+"]"),this._numeral=new RegExp("["+i.join("")+"]","g"),this._index=function(t){return e.get(t)},this}("en-US"),f=function(t){return(t=((t=null==t?"":t)+"").trim().replace(i._group,"").replace(i._decimal,".").replace(i._numeral,i._index))?+t:NaN},c=function(t){return"number"==typeof t?t:!t&&0!==t||isNaN(+t)?0:+t},p=function(t){return!(!/[RIT]/.exec((t=null==t?{}:t).type||"")||/[CN]/.exec(t.type||""))},t=function(i){var t,n,e,r,s,o=[];for(n in i=null==i?{}:i)o.push(n);for(t=o,e=0,s=(r=["name","order"]).length;e<s;++e)if(i[n=r[e]]&&!p(i[n]))return n;return t.filter(function(t){return!p(i[t])})[0]},n=function(){var u,l,h,a=this,f=(this.mod||{}).dimension||{};if(this._subset)return u=t(f),l=this._subset.map(function(i){var t,n,e,r,s={};for(t in n=f)e=n[t],(r=a.binding[t])&&(s[t]=e.multiple?(r.map?r:[r]).map(o):i[r.key],p(e))&&(s[t]=Array.isArray(s[t])?s[t].map(c):c(s[t]));return s;function o(t){return i[t.key]}}),h={},u&&l.map(function(t){return h[t[u]+""]=t}),this.data.map(function(t,i){var n,e,r,s=u?h[t[u]+""]:l[i],o={};for(n in e=f)r=e[n],p(r)&&(o[n]=r.multiple?(t[n]||[]).map(a):s?c(s[n]):0);return t.subset=o;function a(t,i){return s?c((s[n]||[])[i]):0}}),"shrink"===(((this.cfg||{}).common||{}).subset||{}).mode?this.data.map(function(t){var i,n,e,r=[];for(i in n=f)e=n[i],p(e)&&r.push(t[i]=t.subset[i]);return r}):void 0;this.data.map(function(t){var i=t.subset;return delete t.subset,i})},s=function(t){return!(!t||Array.isArray(t)||!Array.isArray(t.frames))},r=function(t){return"number"==typeof t||"string"==typeof t&&t.trim()&&!isNaN(+t)},o=function(t){return t instanceof Date||"string"==typeof t&&!isNaN(Date.parse(t))},e=function(t){var i,n,s,e;return i=((t=null==t?{}:t).frames||[]).map(function(t,i){return{id:null!=t.id?t.id:i,raw:t.raw||[]}}),t=t.frameOrder,Array.isArray(t)&&t.length?(n={},i.map(function(t){return n[t.id+""]=t}),(s=t.map(function(t){return n[t+""]}).filter(function(t){return t})).concat(i.filter(function(t){for(var i=t,n=s,e=-1,r=n.length>>>0;++e<r;)if(i===n[e])return!1;return!0}))):(t=i.map(function(t){return t.id})).length&&t.every(r)?i.map(function(t,i){return{f:t,i:i}}).sort(function(t,i){return+t.f.id-+i.f.id||t.i-i.i}).map(function(t){return t.f}):t.length&&t.every(o)?(e=function(t){return t instanceof Date?t.getTime():Date.parse(t)},i.map(function(t,i){return{f:t,i:i}}).sort(function(t,i){return e(t.f.id)-e(i.f.id)||t.i-i.i}).map(function(t){return t.f})):i},a=function(t){var i,n;if("string"!=typeof t)return null;if(t=t.trim(),i=/^#([0-9a-f]{3})$/i.exec(t)){for(var e,r=[],s=0,o=(e=i[1].split("")).length;s<o;++s)n=e[s],r.push(parseInt(n+n,16));return r}return(i=/^#([0-9a-f]{6})$/i.exec(t))?[0,1,2].map(function(t){return parseInt(i[1].substr(2*t,2),16)}):(i=/^rgba?\(([^)]+)\)$/i.exec(t))&&3===(t=i[1].split(",").slice(0,3).map(function(t){return parseFloat(t.trim())})).length&&t.every(function(t){return!isNaN(t)})?t:null},u=function(t,i,n){var e,r,s,o;for(r in null==n&&(n={}),e={},s=b(b({},i=null==i?{}:i),n||{}))o=s[r],e[r]="function"==typeof o?o.bind(t):o;return e},l=function(t,i,n){for(var e=t;t&&t!==n;)t=t.parentNode;if(t!==n)return null;if(!i)return t;for(t=e;t&&t!==n&&(!t.matches||(t.matches,!t.matches(i)));)t=t.parentNode;return t!==n||n.matches&&n.matches(i)?t:null},(h=function(){return this.running=!1,this.time={now:0,last:0},this.fps(60),this.evtHandler={},this}).prototype=b(Object.create(Object.prototype),{on:function(t,n){var e=this;return(Array.isArray(t)?t:[t]).map(function(t){var i;return((i=e.evtHandler)[t]||(i[t]=[])).push(n)})},fire:function(t){for(var i,n,e,r,s=[],o=[],a=1,u=arguments.length;a<u;++a)o.push(arguments[a]);for(i=o,a=0,e=(n=this.evtHandler[t]||[]).length;a<e;++a)r=n[a],s.push(r.apply(this,i));return s},reset:function(){return this.time={now:0}},setTime:function(t){return this.time.now=t},getTime:function(){return this.time.now},isRunning:function(){return this.running},toggle:function(t){return null!=t&&(this.running=!t),this.running?this.pause():this.run()},pause:function(){return this.running=!1},render:function(t){return this.fire("tick",this.time.now,t=null==t?0:t)},run:function(t){var i=this;if(null!=t&&this.fps(t),!this.running)return this.running=!0,requestAnimationFrame(function(t){return i.handler(i.time.last=t,!0)})},throttle:function(t){return this.isThrottled=t=null==t?!0:t},fps:function(t){return null==t?this._fps_val:(this._fps_val=.01<t?t:.01,this._fps_delay=1e3/this._fps_val)},handler:function(t,i){var n,e,r=this;if(null==i&&(i=!1),this.running)return this.external&&this.external()?(this.time.last=t,requestAnimationFrame(function(t){return r.handler(t,!1)})):(this.time.now=t,n=this.isThrottled?1e3<(n=this._fps_delay)?n:1e3:this._fps_delay,(i||(e=this.time.now-this.time.last)>=n)&&(this.time.last=t,this.render(i?0:e)),requestAnimationFrame(function(t){return r.handler(t,!1)}))}}),m={list:[],init:function(){var t,n,e=this;return this.inited=!0,t=null==document.hidden&&null==document.msHidden&&null!=document.webkiHidden?["webkitHidden","webkitvisibilitychange"]:["hidden","visibilitychange"],n=t[0],document.addEventListener(t[1],debounce(150,function(){var i=!!document[n];return e.list.map(function(t){return t.throttle(i)})},!1))},add:function(t){return this.inited||this.init(),this.list.push(t)}},d={wm:new WeakMap,ro:new ResizeObserver(function(t){return t.map(function(t){return d.wm.get(t.target)._resize()})}),add:function(t,i){return this.wm.set(t,i),this.ro.observe(t)},delete:function(t){return this.ro.unobserve(t),this.wm.delete(t)}},y=function(t,i,n){return null==i&&(i={}),null==n&&(n={}),function(t,i,n){var e,r;for(e in i)r=i[e],null==t[e]?t[e]=r:"object"!=typeof t[e]||"object"!=typeof r||n[e]&&n[e].type||y(t[e],i[e],n[e]);return t}(t=null==t?{}:t,i=JSON.parse(JSON.stringify(i)),n)},g=function(t){var r=function(t,i){var n,e;for(n in null==i&&(i={}),t.child,t)(e=t[n]).type?e.default&&(i[n]=e.default):r(e,i[n]||(i[n]={}));return i};return r(t)},(_=function(t){var i,n,e,r=this;for(i in this.root="string"==typeof(t=null==t?{}:t).root?document.querySelector(t.root):t.root,this.useSample=null==t.useSample||t.useSample,this.autoSelect=null==t.autoSelect||t.autoSelect,this.forceInit=t.forceInit||!1,this.prepareSvg=null==t.prepareSvg||t.prepareSvg,this.layoutOpt=null==t.layout||t.layout,this.delayRender=t.delayRender||!1,this.dataAccessor=null!=t.dataAccessor?t.dataAccessor:function(t){return t?t.data._raw:null},this.data=[],this.raw=t.raw||null,this.mod=t.mod||{},this.cfg=t.config||{},this.seed=t.seed||Math.random(),this.binding=t.binding||{},this._normalizeBinding(),this.evtHandler={},this._subset=t.subset||null,this._frames=null,this._player={playing:!1,pos:0,origin:0,raf:null},s(this.raw)&&(this._setFrames(this.raw),this.raw=(null!=(t=this._frames.list[this._frames.index])?t.raw:void 0)||[]),n=_.scopes){if(e=n[i],null!=this[i])throw new Error("[@plotdb/chart] scope name `"+i+"` is already taken.");this[i]=u(this,e,this.mod[i])}if(null!=this.local)throw new Error("[@plotdb/chart] scope name `local` is already taken.");return this.local=u(this,{},this.mod.local),(_.utils||(_.utils={})).anim&&null==this.anim&&(this.anim=new _.utils.anim),this.anim&&this.anim.on("step",function(){if(r._player.playing)return r._playerTick()}),this.init=proxise.once(function(){return r._init()}),this._resize=null,this._inited=!1,this.autoSelect&&(this.root.addEventListener("click",this._select=function(t){if(t=l(t.target,".data",r.root))return r.fire("select",[{data:r.dataAccessor(t),node:t}])}),this.root.addEventListener("mouseover",this._hover=function(t){if(t=l(t.target,".data",r.root))return r.fire("hover",[{data:r.dataAccessor(t),node:t}])})),this}).prototype=b(Object.create(Object.prototype),{_init:function(){var n,t,i,e=this;return"static"===window.getComputedStyle(this.root).position&&(this.root.style.position="relative"),n=this.layoutOpt?"object"!=typeof this.layoutOpt?this.root.querySelector(".pdl-layout"):"string"==typeof this.layoutOpt.root?this.root.querySelector(this.layoutOpt.root):this.layoutOpt.root||null:null,this.prepareSvg&&!(this.svg=this.root.querySelector("svg"))&&(this.svg=document.createElementNS("http://www.w3.org/2000/svg","svg"),(t=this.svg.style).width="100%",t.height="100%",!this.layoutOpt||(n||console.error("[@plotdb/chart] layout enabled yet layout root isn't configured properly. "),i=n.querySelector("[data-type=render]"))||console.warn("[@plotdb/chart] prepareSvg and layout is configured at the same time,\nyet render container for layout is not found. svg is thus appended in the root."),(i||this.root).appendChild(this.svg)),this._aniloop=new h,m.add(this._aniloop),this._aniloop.on("tick",function(t,i){return e.tick(t,i)}),this.anim&&(this._aniloop.external=function(){return e.anim.manual()},this.anim.on("step",function(t,i){if(e._aniloop.isRunning())return e._aniloop.setTime(t),e._aniloop.render(i)})),Promise.resolve().then(function(){var t;return e.mod.config=y(e.mod.config||{},_.commonConfig),e._defcfg=t=g(e.mod.config),y(e.cfg,t),e.raw&&Array.isArray(e.raw)?{raw:e.raw,binding:e.binding}:e.useSample&&e.mod.sample?(t=e.mod.sample.apply(e)).then?t.then():Promise.resolve(t):void 0}).then(function(t){return e.raw=(t=t||{}).raw,e.binding=t.binding,e}).then(function(){var t,i;return e.raw||(e.raw=[]),e.layoutOpt&&("undefined"==typeof layout||null===layout?console.warn("[@plotdb/chart] layout-opt is set yet @plotdb/layout is not found."):(n||(console.error("[@plotdb/chart] cannot determine root node for @plotdb/layout."),console.error("[@plotdb/chart] config layout properly or disable layout by setting layout to false")),e.layout=new layout("object"==typeof e.layoutOpt?((i=b({},e.layoutOpt)).watchResize=!1,i):{root:n,watchResize:!1}))),t=proxise(function(){return d.add(e.root,e),null}),e._resize=function(){return t.resolve()},i=t(),(e.forceInit||!e.root.offsetParent||"none"===window.getComputedStyle(e.root).display||e.root.offsetWidth&&e.root.offsetHeight)&&t.resolve(),i}).then(function(){return e._resize=function(){}}).then(function(){var t,i=function(){if(e.mod.init)return e.mod.init.apply(e)};return(e.layout?(t=proxise(function(){return Promise.resolve(e.layout.init(i)),null}),e._layout=function(){return t.resolve()},e.layout.on("render",function(){return e._layout()}),t):i)()}).then(function(){e._layout=function(){},Promise.resolve().then(function(){if(e.delayRender&&!e._pendingRaw)return e.renderLock=proxise(function(){}),e.renderLock()}).then(function(){if(e._inited=!0,e._resize=function(){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),n.apply(this),this.mod.parse)return this.mod.parse.apply(this)},_parseRows:function(t){var l,i,h;return null==t&&(t=[]),l=(i=this.mod).dimension||(i.dimension={}),h=this.binding,t.map(function(i,t){var n,e,r,s,o={};for(n in e=l)r=e[n],(s=h[n])?(o[n]=r.multiple?(s.map?s:[s]).map(a):i[s.key],/[RIT]/.exec(r.type)&&!/[CN]/.exec(r.type)&&(o[n]=Array.isArray(o[n])?o[n].map(u):f(o[n]))):r.multiple&&(o[n]=[]);return o._raw=i,o._idx=t,o;function a(t){return i[t.key]}function u(t){return f(t)}})},bind:function(){if(this.mod.bind)return this.mod.bind.apply(this)},start:function(){if(this._aniloop.run(),this.mod.start)return this.mod.start.apply(this)},stop:function(){if(this._aniloop.pause(),this.mod.stop)return this.mod.stop.apply(this)},resize:function(){if(this._inited)return this.layout&&this.layout.update(!1),this.box=this.root.getBoundingClientRect(),this.mod.resize?this.mod.resize.apply(this):void 0},tick:function(t,i){if(this.mod.tick)return this.mod.tick.apply(this,[t,i])},render:function(){if(this._inited)return this._syncAnim(),this.mod.render?this.mod.render.apply(this):void 0},destroy:function(){var t=this;return Promise.resolve().then(function(){if(t._select&&t.root.removeEventListener("click",t._select),t._hover&&t.root.removeEventListener("mouseover",t._hover),d.delete(t.root),t.layout&&t.layout.destroy(),t.pause(),t.stop(),t.mod.destroy)return t.mod.destroy.apply(t)})},config:function(){var t,i,n;if(!arguments.length)return this.cfg;for(t={},i=0,n=arguments.length;i<n;++i)y(t,arguments[i],this.mod.config);return y(t,this.cfg,this.mod.config),y(t,this._defcfg,this.mod.config),b(this.cfg,t)},_normalizeBinding:function(t){var i,n,e,r,s,o,a,u=[];if(null==t){for(t in i=[],this.mod.dimension||{})i.push(t);t=i}for(n=0,e=(t=Array.isArray(t)?t:[t]).length;n<e;++n)r=t[n],s=(this.mod.dimension||{})[r]||{},o=this.binding[r],a=Array.isArray(o),!s.multiple!=!a&&(s.multiple||a)&&u.push(this.binding[r]=a?o[0]:o?[o]:[]);return u},setBind:function(t,i){if(this.binding[t]=i,this._normalizeBinding([t]),this._inited)return this.parse(),this.bind(),this.resize(),this.render()},setRaw:function(t,i,n){var e;return null==n&&(n=!1),!t||Array.isArray(t)||s(t)||("subset"in t&&(this._subset=t.subset||null),t=(e=t).raw,i=e.binding,n=e.reinit),s(t)?(this._setFrames(t),t=(null!=(e=this._frames.list[this._frames.index])?e.raw:void 0)||[]):null!=t&&this._frames&&(this.pause(),this._frames=null,this._player.pos=0,this.anim)&&this.anim.resume(),null!=t&&(this.raw=t),null!=i&&(this.binding=i,this._normalizeBinding()),this.renderLock?(this.renderLock.resolve(),this.renderLock=null):this._inited?(n&&this.mod.init&&this.mod.init.apply(this),this.parse(),this.bind(),this.resize(),this.render(),this._frames?this._framesStart():void 0):this._pendingRaw=!0},_animCfg:function(){return((this.cfg||{}).common||{}).animation||{}},_syncAnim:function(){var t;if(this.anim)return null!=(t=this._animCfg()).transition&&this.anim.duration(t.transition),this.anim.speed(null!=t.speed?t.speed:1)},_setFrames:function(t){var i,t=e(t);return this._frames={list:t,index:0,all:null},this._frames.index=this._frameAt((t=this._player.pos)<(i=this.duration())?t:i)},_interval:function(){return+this._animCfg().interval||1e3},_clock:function(){return this.anim?this.anim.time():("undefined"!=typeof performance&&null!==performance?performance:Date).now()},_frameAt:function(t){var i=this._frames?this._frames.list.length:0;return i?(t=0<(t=Math.floor(t/this._interval()))?t:0)<(i=i-1)?t:i:0},_framesStart:function(){if(this.fire("frame",{index:this._frames.index,id:this.frame.id()}),this._animCfg().autoplay&&!this._player.playing)return this.play()},_goto:function(t,i){var n,e,r,s=this;if(null==i&&(i=0),(n=this._frames)&&n.list.length&&(t=(e=0<t?t:0)<(r=n.list.length-1)?e:r,n.index=t,this.raw=n.list[t].raw,this._inited))return this.parse(),this.bind(),this.resize(),this.anim&&0<i?this.anim.ago(i,function(){return s.render()}):this.render(),this.fire("frame",{index:t,id:n.list[t].id})},duration:function(){return this._frames?this._frames.list.length*this._interval():0},position:function(){var t=this._player;return t.playing?this._clock()-t.origin:t.pos},playing:function(){return this._player.playing},play:function(){var t=this._player;if(this._frames&&!t.playing&&this._frames.list.length)return t.pos>=this.duration()&&(t.pos=0),this._syncAnim(),this.anim&&this.anim.resume(),t.origin=this._clock()-t.pos,t.playing=!0,this.fire("play"),this._playerLoop()},pause:function(){var t=this._player;if(t.playing)return t.pos=this.position(),t.playing=!1,t.raf&&cancelAnimationFrame(t.raf),t.raf=null,this.anim&&this.anim.pause(),this.fire("pause")},seek:function(t){var i,n,e,r;if(this._frames&&this._frames.list.length)return r=this._interval(),n=(t=(e=0<(e=+(t=t&&"object"==typeof t?((t.frame||0)+(t.progress||0))*r:t)||0)?e:0)<(i=this.duration())?e:i)-(i=this._frameAt(t))*r,e=(e=+this._animCfg().transition||0)<r?e:r,0<i&&n<e?(this._goto(i-1),this.anim&&this.anim.flush(),this._goto(i,n)):(this._goto(i),this.anim&&this.anim.flush()),(r=this._player).pos=t,r.playing&&(r.origin=this._clock()-t),this.fire("progress",{time:t,duration:this.duration(),index:i})},_playerLoop:function(){var t,i=this,n=this._player;if(!n.raf&&"undefined"!=typeof requestAnimationFrame&&null!==requestAnimationFrame)return n.raf=requestAnimationFrame(t=function(){if(n.raf=null,n.playing)return i.anim&&i.anim.manual()||i._playerTick(),n.playing?n.raf=requestAnimationFrame(t):void 0})},_playerTick:function(){var t,i,n=this._player,e=this._frames;if(e&&e.list.length){if((t=this.duration())<=(i=this.position())){if(!this._animCfg().loop)return n.pos=t,n.playing=!1,this.fire("progress",{time:t,duration:t,index:e.index}),void this.fire("end");i%=t,n.origin=this._clock()-i}return(n=this._frameAt(i))!==e.index&&this._goto(n,i-n*this._interval()),this.fire("progress",{time:i,duration:t,index:n})}},on:function(t,n){var e=this;return(Array.isArray(t)?t:[t]).map(function(t){var i;return((i=e.evtHandler)[t]||(i[t]=[])).push(n)})},fire:function(t){for(var i,n,e,r,s=[],o=[],a=1,u=arguments.length;a<u;++a)o.push(arguments[a]);for(i=o,a=0,e=(n=this.evtHandler[t]||[]).length;a<e;++a)r=n[a],s.push(r.apply(this,i));return s},filter:function(t,i){var n,e,r,s,o;for(e in null==t&&(t={}),null==i&&(i=!1),n=[],r=this.binding)s=r[e],o=(o=Array.isArray(s)?s:[s]).map(a),n=n.concat(o);for(e in t)s=t[e],n.filter(u).map(l);return i&&this.fire("filter",t),this.mod.filter&&this.mod.filter.apply(this,[t,i]),this.parse(),this.bind(),this.resize(),this.render();function a(t){return{k:e,v:t}}function u(t){return t.k===e}function l(t){return t.v.filter=s}},sample:function(){return this.mod.sample?this.mod.sample.apply(this):{raw:[],binding:{}}},filterDims:function(){var t;return(t=(this.mod||{}).filterDims)?t.call(this):(this.mod||{}).filter?["name"]:[]},canFilter:function(){return!!this.filterDims().length}}),_.commonConfig={common:{animation:{transition:{type:"number",default:350,min:0,max:5e3,step:10},interval:{type:"number",default:1e3,min:100,max:2e4,step:50},speed:{type:"number",default:1,min:.1,max:10,step:.1},loop:{type:"boolean",default:!0},autoplay:{type:"boolean",default:!0}},subset:{mode:{type:"choice",values:["dim","partial","shrink"],default:"dim"},opacity:{type:"number",default:.2,min:0,max:1,step:.05},fade:{type:"number",default:.72,min:0,max:1,step:.01}}}},_.scopes={frame:{active:function(){return!!this._frames},count:function(){return this._frames?this._frames.list.length:0},index:function(){return this._frames?this._frames.index:-1},id:function(t){return this._frames?(this._frames.list[null!=t?t:this._frames.index]||{}).id:null},ids:function(){return this._frames?this._frames.list.map(function(t){return t.id}):[]},all:function(){var t,i;return this._frames?null!=(i=(t=this._frames).all)?i:t.all=this._parseRows([].concat.apply([],this._frames.list.map(function(t){return t.raw}))):this._parseRows(this.raw)}},subset:{set:function(t){if(this._subset=t||null,this._inited)return this.parse(),this.bind(),this.resize(),this.render()},mode:function(){return(((this.cfg||{}).common||{}).subset||{}).mode||"dim"},ratio:function(t,i,n){return t&&t.subset?!(t=(n=null!=n?[(t[i]||[])[n],(t.subset[i]||[])[n]]:[t[i],t.subset[i]])[0])||(i=n[1]/t)<0?0:1<i?1:i:null},color:function(t,i){var n;return(n=a(t))?(n=.3*n[0]+.59*n[1]+.11*n[2],i=null!=i?i:(((this.cfg||{}).common||{}).subset||{}).fade,"rgb("+(n=Math.round(n+(255-n)*(null!=i?i:.72)))+","+n+","+n+")"):t}}},_.dataframe={is:s,split:function(t,n){var e={},r=[];return(t=null==t?[]:t).map(function(t){var i=t[n]+"";return e[i]||r.push(e[i]={id:t[n],raw:[]}),e[i].raw.push(t)}),{frames:r}}},"undefined"!=typeof module&&null!==module?module.exports=_:"undefined"!=typeof window&&null!==window&&(window.chart=_)}.call(this);
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);
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.9.1","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.10.1","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/bin.js ADDED
@@ -0,0 +1,352 @@
1
+ (function(){
2
+ var eps, clean, isInt, niceStep, autoWidth, rawIndex, bin;
3
+ eps = 1e-9;
4
+ clean = function(v){
5
+ return +(+v).toPrecision(12);
6
+ };
7
+ isInt = function(v){
8
+ return Math.abs(v - Math.round(v)) < eps;
9
+ };
10
+ niceStep = function(span, count){
11
+ var raw, p, e, m;
12
+ raw = span / (count > 1 ? count : 1);
13
+ if (!(raw > 0)) {
14
+ return 1;
15
+ }
16
+ p = Math.pow(10, Math.floor(Math.log10(raw)));
17
+ e = raw / p;
18
+ m = e >= Math.sqrt(50)
19
+ ? 10
20
+ : e >= Math.sqrt(10)
21
+ ? 5
22
+ : e >= Math.sqrt(2) ? 2 : 1;
23
+ return clean(m * p);
24
+ };
25
+ autoWidth = function(vs, lo, hi, opt){
26
+ var count, ref$, span, w;
27
+ count = opt.count > 0
28
+ ? opt.count
29
+ : Math.ceil(Math.log2((ref$ = vs.length) > 1 ? ref$ : 1)) + 1;
30
+ if (hi === lo && isInt(lo)) {
31
+ return 1;
32
+ }
33
+ span = hi > lo
34
+ ? hi - lo
35
+ : Math.abs(lo) || 1;
36
+ w = niceStep(span, count);
37
+ if (vs.every(isInt) && w < 1) {
38
+ w = 1;
39
+ }
40
+ return w;
41
+ };
42
+ rawIndex = function(v, info){
43
+ var k;
44
+ k = (v - info.start) / info.width;
45
+ if (Math.abs(k - Math.round(k)) < eps) {
46
+ k = Math.round(k);
47
+ }
48
+ if (info.closed === 'right') {
49
+ return Math.ceil(k) - 1;
50
+ } else {
51
+ return Math.floor(k);
52
+ }
53
+ };
54
+ bin = {
55
+ edges: function(values, opt){
56
+ var vs, closed, anchor, max, ref$, lo, hi, width, discrete, info, k, last, res$, i$, to$, i;
57
+ values == null && (values = []);
58
+ opt == null && (opt = {});
59
+ vs = values.filter(function(it){
60
+ return typeof it === 'number' && isFinite(it);
61
+ });
62
+ closed = opt.closed === 'right' ? 'right' : 'left';
63
+ anchor = isFinite(+opt.anchor) ? +opt.anchor : 0;
64
+ max = opt.max || 500;
65
+ if (!vs.length) {
66
+ return {
67
+ start: anchor,
68
+ width: +opt.width || 1,
69
+ anchor: anchor,
70
+ closed: closed,
71
+ discrete: false,
72
+ n: 0,
73
+ edges: []
74
+ };
75
+ }
76
+ ref$ = [Math.min.apply(Math, vs), Math.max.apply(Math, vs)], lo = ref$[0], hi = ref$[1];
77
+ width = +opt.width > 0
78
+ ? +opt.width
79
+ : autoWidth(vs, lo, hi, opt);
80
+ if ((hi - lo) / width > max) {
81
+ width = autoWidth(vs, lo, hi, {
82
+ count: opt.count
83
+ });
84
+ }
85
+ discrete = isInt(width) && isInt(anchor) && vs.every(isInt);
86
+ info = {
87
+ width: width,
88
+ anchor: anchor,
89
+ closed: closed,
90
+ discrete: discrete
91
+ };
92
+ k = (lo - anchor) / width;
93
+ if (Math.abs(k - Math.round(k)) < eps) {
94
+ k = Math.round(k);
95
+ }
96
+ info.start = clean(anchor + width * (closed === 'left'
97
+ ? Math.floor(k)
98
+ : !discrete && isInt(k)
99
+ ? k
100
+ : Math.ceil(k) - 1));
101
+ last = rawIndex(hi, info);
102
+ if (!discrete && closed === 'left' && last > 0 && isInt((hi - info.start) / width)) {
103
+ last = last - 1;
104
+ }
105
+ info.n = (ref$ = last + 1) > 1 ? ref$ : 1;
106
+ res$ = [];
107
+ for (i$ = 0, to$ = info.n; i$ <= to$; ++i$) {
108
+ i = i$;
109
+ res$.push(clean(info.start + width * i));
110
+ }
111
+ info.edges = res$;
112
+ return info;
113
+ },
114
+ index: function(v, info){
115
+ var i;
116
+ if (!(typeof v === 'number' && isFinite(v)) || !info.n) {
117
+ return -1;
118
+ }
119
+ i = rawIndex(v, info);
120
+ if (!info.discrete) {
121
+ if (i === info.n && info.closed === 'left' && Math.abs(v - info.edges[info.n]) < eps * info.width) {
122
+ i = info.n - 1;
123
+ }
124
+ if (i === -1 && info.closed === 'right' && Math.abs(v - info.edges[0]) < eps * info.width) {
125
+ i = 0;
126
+ }
127
+ }
128
+ if (i < 0 || i >= info.n) {
129
+ return -1;
130
+ } else {
131
+ return i;
132
+ }
133
+ },
134
+ range: function(i, info){
135
+ var ref$, a, b;
136
+ ref$ = [info.edges[i], info.edges[i + 1]], a = ref$[0], b = ref$[1];
137
+ if (!info.discrete) {
138
+ return [a, b];
139
+ }
140
+ if (info.closed === 'right') {
141
+ return [clean(a + 1), b];
142
+ } else {
143
+ return [a, clean(b - 1)];
144
+ }
145
+ },
146
+ label: function(i, info, opt){
147
+ var f, ref$, ref1$, a, b;
148
+ opt == null && (opt = {});
149
+ f = opt.format && ((typeof chart != 'undefined' && chart !== null) && ((ref$ = chart.utils) != null && ref$.format))
150
+ ? chart.utils.format.from(opt.format)
151
+ : function(it){
152
+ return clean(it) + "";
153
+ };
154
+ ref1$ = bin.range(i, info), a = ref1$[0], b = ref1$[1];
155
+ switch (opt.label) {
156
+ case 'start':
157
+ return f(a);
158
+ case 'center':
159
+ return f(clean((info.edges[i] + info.edges[i + 1]) / 2));
160
+ default:
161
+ if (a === b) {
162
+ return f(a);
163
+ } else {
164
+ return f(a) + "–" + f(b);
165
+ }
166
+ }
167
+ },
168
+ count: function(values, info, weights){
169
+ var m, ref$, ret, res$, i$, to$, i, len$, j, v, j$, k, w;
170
+ values == null && (values = []);
171
+ m = weights ? (ref$ = (weights[0] || []).length) > 1 ? ref$ : 1 : 1;
172
+ res$ = [];
173
+ for (i$ = 0, to$ = info.n; i$ < to$; ++i$) {
174
+ i = i$;
175
+ res$.push(repeatArray$([0], m));
176
+ }
177
+ ret = res$;
178
+ for (i$ = 0, len$ = values.length; i$ < len$; ++i$) {
179
+ j = i$;
180
+ v = values[i$];
181
+ if ((i = bin.index(v, info)) < 0) {
182
+ continue;
183
+ }
184
+ if (!weights) {
185
+ ret[i][0] += 1;
186
+ continue;
187
+ }
188
+ for (j$ = 0; j$ < m; ++j$) {
189
+ k = j$;
190
+ w = +(weights[j] || [])[k];
191
+ if (isFinite(w)) {
192
+ ret[i][k] += w;
193
+ }
194
+ }
195
+ }
196
+ return ret;
197
+ },
198
+ parse: function(opt){
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
+ opt == null && (opt = {});
201
+ ref$ = [opt.value || 'value', opt.size || 'size', opt.name || 'name'], kv = ref$[0], ks = ref$[1], kn = ref$[2];
202
+ cfg = opt.config || (this.cfg || {}).bin || {};
203
+ sb = this.binding[ks];
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;
220
+ rows = this._parseRows(this.raw || []);
221
+ all = this._frames && ((typeof chart != 'undefined' && chart !== null) && ((ref$ = chart.scopes) != null && ref$.frame)) ? chart.scopes.frame.all.call(this) : rows;
222
+ info = bin.edges(all.map(function(it){
223
+ return it[kv];
224
+ }), cfg);
225
+ vals = function(rs){
226
+ return rs.map(function(it){
227
+ return it[kv];
228
+ });
229
+ };
230
+ wts = function(rs){
231
+ if (!series) {
232
+ return null;
233
+ } else {
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
+ });
240
+ });
241
+ }
242
+ };
243
+ counts = bin.count(vals(rows), info, wts(rows));
244
+ sub = !this._subset
245
+ ? null
246
+ : bin.count(vals(this._parseRows(this._subset)), info, wts(this._parseRows(this._subset)));
247
+ shrink = (((this.cfg || {}).common || {}).subset || {}).mode === 'shrink';
248
+ res$ = [];
249
+ for (i$ = 0, to$ = info.n; i$ < to$; ++i$) {
250
+ i = i$;
251
+ res$.push(bin.label(i, info, cfg));
252
+ }
253
+ labels = res$;
254
+ if (new Set(labels).size !== labels.length) {
255
+ res$ = [];
256
+ for (i$ = 0, to$ = info.n; i$ < to$; ++i$) {
257
+ i = i$;
258
+ res$.push(bin.label(i, info, {
259
+ label: cfg.label
260
+ }));
261
+ }
262
+ labels = res$;
263
+ }
264
+ data = [];
265
+ for (i$ = 0, to$ = info.n; i$ < to$; ++i$) {
266
+ i = i$;
267
+ if (cfg.empty === false && counts[i].every(fn$)) {
268
+ continue;
269
+ }
270
+ d = {};
271
+ d[kn] = labels[i];
272
+ d[ks] = counts[i];
273
+ ref1$ = [info.edges[i], info.edges[i + 1]], x0 = ref1$[0], x1 = ref1$[1];
274
+ d.bin = {
275
+ x0: x0,
276
+ x1: x1,
277
+ index: i
278
+ };
279
+ if (sub) {
280
+ d.subset = {};
281
+ d.subset[ks] = sub[i];
282
+ if (shrink) {
283
+ d[ks] = sub[i];
284
+ }
285
+ }
286
+ d._idx = data.length;
287
+ d._raw = (ref1$ = import$({}, d.bin), ref1$.count = counts[i], ref1$);
288
+ data.push(d);
289
+ }
290
+ return {
291
+ data: data,
292
+ info: info,
293
+ series: series || 1,
294
+ keep: keep
295
+ };
296
+ function fn$(it){
297
+ return !it;
298
+ }
299
+ },
300
+ filter: function(a, b, info){
301
+ var ref$, x0, x1, closed;
302
+ ref$ = [info.edges[a], info.edges[b + 1]], x0 = ref$[0], x1 = ref$[1];
303
+ closed = info.closed;
304
+ if (!info.discrete) {
305
+ if (closed === 'left' && b === info.n - 1) {
306
+ closed = 'both';
307
+ }
308
+ if (closed === 'right' && a === 0) {
309
+ closed = 'both';
310
+ }
311
+ }
312
+ return {
313
+ type: 'range',
314
+ value: [x0, x1],
315
+ closed: closed
316
+ };
317
+ },
318
+ select: function(f, info){
319
+ var ref$, lo, hi, idx, res$, i$, to$, i;
320
+ if (!(f && f.type === 'range' && Array.isArray(f.value)) || !info.n) {
321
+ return null;
322
+ }
323
+ ref$ = f.value, lo = ref$[0], hi = ref$[1];
324
+ res$ = [];
325
+ for (i$ = 0, to$ = info.n; i$ < to$; ++i$) {
326
+ i = i$;
327
+ if (info.edges[i + 1] > lo && info.edges[i] < hi) {
328
+ res$.push(i);
329
+ }
330
+ }
331
+ idx = res$;
332
+ if (!idx.length) {
333
+ return null;
334
+ } else {
335
+ return [idx[0], idx[idx.length - 1]];
336
+ }
337
+ }
338
+ };
339
+ if (typeof chart != 'undefined' && chart !== null) {
340
+ (chart.utils || (chart.utils = {})).bin = bin;
341
+ }
342
+ function repeatArray$(arr, n){
343
+ for (var r = []; n > 0; (n >>= 1) && (arr = arr.concat(arr)))
344
+ if (n & 1) r.push.apply(r, arr);
345
+ return r;
346
+ }
347
+ function import$(obj, src){
348
+ var own = {}.hasOwnProperty;
349
+ for (var key in src) if (own.call(src, key)) obj[key] = src[key];
350
+ return obj;
351
+ }
352
+ }).call(this);
@@ -0,0 +1 @@
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
@@ -126,6 +126,51 @@
126
126
  'default': false
127
127
  }
128
128
  },
129
+ bin: {
130
+ enabled: {
131
+ type: 'boolean',
132
+ 'default': false
133
+ },
134
+ width: {
135
+ type: 'number',
136
+ 'default': 0,
137
+ min: 0,
138
+ max: 1000000,
139
+ step: 0.01
140
+ },
141
+ count: {
142
+ type: 'number',
143
+ 'default': 0,
144
+ min: 0,
145
+ max: 100,
146
+ step: 1
147
+ },
148
+ anchor: {
149
+ type: 'number',
150
+ 'default': 0,
151
+ min: -1000000,
152
+ max: 1000000,
153
+ step: 0.01
154
+ },
155
+ closed: {
156
+ type: 'choice',
157
+ values: ['left', 'right'],
158
+ 'default': 'left'
159
+ },
160
+ label: {
161
+ type: 'choice',
162
+ values: ['range', 'start', 'center'],
163
+ 'default': 'range'
164
+ },
165
+ format: {
166
+ type: 'format',
167
+ 'default': ''
168
+ },
169
+ empty: {
170
+ type: 'boolean',
171
+ 'default': true
172
+ }
173
+ },
129
174
  axis: {
130
175
  enabled: {
131
176
  type: 'boolean',
@@ -1 +1 @@
1
- !function(){var e;e={from:function(e){var i=this,p=function(e,t){var a,o;if(t.preset){var l,n=e,r=JSON.parse(JSON.stringify(i.preset[t.preset])),u={}.hasOwnProperty;for(l in r)u.call(r,l)&&(n[l]=r[l])}for(a in t)o=t[a],"preset"!==a&&("string"==typeof o?e[a]=JSON.parse(JSON.stringify(i.preset[o]))||{}:p(e[a]||(e[a]={}),o));return e};return p({},e)},preset:{default:{margin:{type:"number"},font:e={family:{type:"font"},size:{type:"quantity",default:"1em",units:[{name:"em",max:10,step:.01,default:1},{name:"px",max:256,step:1,default:16}]}},color:{type:"color",default:"currentColor"},palette:{type:"palette"},background:{type:"color",default:"transparent"}},font:e,tip:{enabled:{type:"boolean",default:!0},format:{type:"format",default:".3s"}},label:{format:{type:"format",default:".3s"}},legend:{selectable:{type:"boolean",default:!0},enabled:{type:"boolean",default:!0},position:{type:"choice",values:["bottom","right"],default:"right"},sort:{direction:{type:"choice",values:["asc","desc"],default:"desc"},mode:{type:"choice",values:["label","value","none"],default:"value"}},subset:{mode:{type:"choice",values:["shrink","dim","partial"],default:"shrink"},opacity:{type:"number",default:.2,min:0,max:1,step:.05}},crossfilter:{type:"boolean",default:!1}},axis:{enabled:{type:"boolean",default:!0},center:{type:"boolean",default:!1},tick:{inner:{type:"number",name:"Inner Tick Size",default:8,min:0,max:40,step:.1},color:{type:"color",default:"currentColor"},count:{type:"number",default:4,min:1,max:40},boundaryOffset:{type:"boolean",default:!0}},baseline:{show:{type:"boolean",default:!0},color:{type:"color",default:"currentColor"}},label:{color:{type:"color",default:"currentColor"},format:{type:"format",default:".3s"},direction:{type:"choice",default:"horizontal",values:["horizontal","vertical"]},gap:{type:"number",default:1.5,min:0,max:10,step:.1},strategy:{type:"choice",default:"stride",values:["stride","ends"]},tolerance:{type:"number",default:.2,min:0,max:1,step:.05},padding:{type:"number",default:1,min:0,max:100,step:.5},font:e},caption:{color:{type:"color",default:"currentColor"},text:{type:"text",default:""},show:{type:"boolean",default:!0},padding:{type:"number",default:1,min:0,max:100,step:.5},position:{type:"choice",default:4,values:[{name:"in / start",value:0},{name:"in / middle",value:1},{name:"in / end",value:2},{name:"out / start",value:3},{name:"out / middle",value:4},{name:"out / end",value:5}]},font:e},sideNoteStart:{show:{type:"boolean",default:!1},text:{type:"text",default:""},position:{type:"choice",default:0,values:[{name:"in",value:0},{name:"out",value:1}]},font:e,color:{type:"color",default:"currentColor"},padding:{type:"number",default:1,min:0,max:100,step:.5}},sideNoteEnd:{show:{type:"boolean",default:!1},text:{type:"text",default:""},position:{type:"choice",default:0,values:[{name:"in",value:0},{name:"out",value:1}]},font:e,color:{type:"color",default:"currentColor"},padding:{type:"number",default:1,min:0,max:100,step:.5}}}}},"undefined"!=typeof chart&&null!==chart&&((chart.utils||(chart.utils={})).config=e)}.call(this);
1
+ !function(){var e;e={from:function(e){var p=this,i=function(e,t){var a,l;if(t.preset){var o,n=e,r=JSON.parse(JSON.stringify(p.preset[t.preset])),u={}.hasOwnProperty;for(o in r)u.call(r,o)&&(n[o]=r[o])}for(a in t)l=t[a],"preset"!==a&&("string"==typeof l?e[a]=JSON.parse(JSON.stringify(p.preset[l]))||{}:i(e[a]||(e[a]={}),l));return e};return i({},e)},preset:{default:{margin:{type:"number"},font:e={family:{type:"font"},size:{type:"quantity",default:"1em",units:[{name:"em",max:10,step:.01,default:1},{name:"px",max:256,step:1,default:16}]}},color:{type:"color",default:"currentColor"},palette:{type:"palette"},background:{type:"color",default:"transparent"}},font:e,tip:{enabled:{type:"boolean",default:!0},format:{type:"format",default:".3s"}},label:{format:{type:"format",default:".3s"}},legend:{selectable:{type:"boolean",default:!0},enabled:{type:"boolean",default:!0},position:{type:"choice",values:["bottom","right"],default:"right"},sort:{direction:{type:"choice",values:["asc","desc"],default:"desc"},mode:{type:"choice",values:["label","value","none"],default:"value"}},subset:{mode:{type:"choice",values:["shrink","dim","partial"],default:"shrink"},opacity:{type:"number",default:.2,min:0,max:1,step:.05}},crossfilter:{type:"boolean",default:!1}},bin:{enabled:{type:"boolean",default:!1},width:{type:"number",default:0,min:0,max:1e6,step:.01},count:{type:"number",default:0,min:0,max:100,step:1},anchor:{type:"number",default:0,min:-1e6,max:1e6,step:.01},closed:{type:"choice",values:["left","right"],default:"left"},label:{type:"choice",values:["range","start","center"],default:"range"},format:{type:"format",default:""},empty:{type:"boolean",default:!0}},axis:{enabled:{type:"boolean",default:!0},center:{type:"boolean",default:!1},tick:{inner:{type:"number",name:"Inner Tick Size",default:8,min:0,max:40,step:.1},color:{type:"color",default:"currentColor"},count:{type:"number",default:4,min:1,max:40},boundaryOffset:{type:"boolean",default:!0}},baseline:{show:{type:"boolean",default:!0},color:{type:"color",default:"currentColor"}},label:{color:{type:"color",default:"currentColor"},format:{type:"format",default:".3s"},direction:{type:"choice",default:"horizontal",values:["horizontal","vertical"]},gap:{type:"number",default:1.5,min:0,max:10,step:.1},strategy:{type:"choice",default:"stride",values:["stride","ends"]},tolerance:{type:"number",default:.2,min:0,max:1,step:.05},padding:{type:"number",default:1,min:0,max:100,step:.5},font:e},caption:{color:{type:"color",default:"currentColor"},text:{type:"text",default:""},show:{type:"boolean",default:!0},padding:{type:"number",default:1,min:0,max:100,step:.5},position:{type:"choice",default:4,values:[{name:"in / start",value:0},{name:"in / middle",value:1},{name:"in / end",value:2},{name:"out / start",value:3},{name:"out / middle",value:4},{name:"out / end",value:5}]},font:e},sideNoteStart:{show:{type:"boolean",default:!1},text:{type:"text",default:""},position:{type:"choice",default:0,values:[{name:"in",value:0},{name:"out",value:1}]},font:e,color:{type:"color",default:"currentColor"},padding:{type:"number",default:1,min:0,max:100,step:.5}},sideNoteEnd:{show:{type:"boolean",default:!1},text:{type:"text",default:""},position:{type:"choice",default:0,values:[{name:"in",value:0},{name:"out",value:1}]},font:e,color:{type:"color",default:"currentColor"},padding:{type:"number",default:1,min:0,max:100,step:.5}}}}},"undefined"!=typeof chart&&null!==chart&&((chart.utils||(chart.utils={})).config=e)}.call(this);