@plotdb/chart 2.1.37 → 2.1.38

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,12 @@
1
1
  # Change Logs
2
2
 
3
+ ## v2.1.38
4
+
5
+ - axis, config utilities: support side note
6
+ - fix bug: chart doesn't render correctly when passing raw / binding via constructor option
7
+ - upgrade dependencies
8
+
9
+
3
10
  ## v2.1.37
4
11
 
5
12
  - support configurable axis caption position
package/index.js CHANGED
@@ -339,7 +339,10 @@
339
339
  this$._defcfg = defcfg = defaultConfig(this$.mod.config || {});
340
340
  withDefault(this$.cfg, defcfg);
341
341
  if (this$.raw && Array.isArray(this$.raw)) {
342
- return;
342
+ return {
343
+ raw: this$.raw,
344
+ binding: this$.binding
345
+ };
343
346
  }
344
347
  if (!this$.useSample || !this$.mod.sample) {
345
348
  return;
package/index.min.js CHANGED
@@ -1 +1 @@
1
- !function(){var e,c,n,i,o,s,u,a,t;function l(t,e,d){function f(t,e){return n.call(t,e)}var p={}.toString,n={}.hasOwnProperty,m=!0;return function t(e,n,r){var i,o,s,u,a,l,h,c;if(null==e||null==n)return e===n;if(e.__placeholder__||n.__placeholder__)return!0;if(e===n)return 0!==e||1/e==1/n;i=p.call(e);if(p.call(n)!=i)return!1;switch(i){case"[object String]":return e==String(n);case"[object Number]":return e!=+e?n!=+n:0==e?1/e==1/n:e==+n;case"[object Date]":case"[object Boolean]":return+e==+n;case"[object RegExp]":return e.source==n.source&&e.global==n.global&&e.multiline==n.multiline&&e.ignoreCase==n.ignoreCase}if("object"!=typeof e||"object"!=typeof n)return!1;o=r.length;for(;o--;)if(r[o]==e)return!0;r.push(e);s=0;u=!0;if("[object Array]"==i){if(a=e.length,l=n.length,m){switch(d){case"===":u=a===l;break;case"<==":u=a<=l;break;case"<<=":u=a<l}s=a,m=!1}else u=a===l,s=a;if(u)for(;s--&&(u=s in e==s in n&&t(e[s],n[s],r)););}else{if("constructor"in e!="constructor"in n||e.constructor!=n.constructor)return!1;for(h in e)if(f(e,h)&&(s++,!(u=f(n,h)&&t(e[h],n[h],r))))break;if(u){for(h in c=0,n)f(n,h)&&++c;u=m?"<<="===d?s<c:"<=="===d?s<=c:s===c:(m=!1,s===c)}}r.pop();return u}(t,e,[])}function h(t,e){var n,r={}.hasOwnProperty;for(n in e)r.call(e,n)&&(t[n]=e[n]);return t}e=new function(t){var n=new Intl.NumberFormat(t),e=n.formatToParts(12345.6),t=Array.from({length:10}).map(function(t,e){return n.format(e)}),r=new Map(t.map(function(t,e){return[t,e]}));return this._group=new RegExp("["+e.find(function(t){return l(t.type,"group","===")}).value+"]","g"),this._decimal=new RegExp("["+e.find(function(t){return l(t.type,"decimal","===")}).value+"]"),this._numeral=new RegExp("["+t.join("")+"]","g"),this._index=function(t){return r.get(t)},this}("en-US"),c=function(t){return(t=((t=null==t?"":t)+"").trim().replace(e._group,"").replace(e._decimal,".").replace(e._numeral,e._index))?+t:NaN},n=function(t,e,n){for(var r=t;t&&t!==n;)t=t.parentNode;if(t!==n)return null;if(!e)return t;for(t=r;t&&t!==n&&(!t.matches||t.matches&&!t.matches(e));)t=t.parentNode;return t!==n||n.matches&&n.matches(e)?t:null},(i=function(){return this.running=!1,this.time={now:0,last:0},this.fps(60),this.evtHandler={},this}).prototype=h(Object.create(Object.prototype),{on:function(t,n){var r=this;return(Array.isArray(t)?t:[t]).map(function(t){var e;return((e=r.evtHandler)[t]||(e[t]=[])).push(n)})},fire:function(t){for(var e,n,r,i,o=[],s=[],u=1,a=arguments.length;u<a;++u)s.push(arguments[u]);for(e=s,u=0,r=(n=this.evtHandler[t]||[]).length;u<r;++u)i=n[u],o.push(i.apply(this,e));return o},reset:function(){return this.time={now:0}},setTime:function(t){return this.time.now=t},getTime:function(){return this.time.now},isRunning:function(){return this.running},toggle:function(t){return null!=t&&(this.running=!t),this.running?this.pause():this.run()},pause:function(){return this.running=!1},render:function(){return this.fire("tick",this.time.now)},run:function(t){var e=this;if(null!=t&&this.fps(t),!this.running)return this.running=!0,requestAnimationFrame(function(t){return e.handler(e.time.last=t,!0)})},throttle:function(t){return this.isThrottled=t=null==t?!0:t},fps:function(t){return null==t?this._fps_val:(this._fps_val=.01<t?t:.01,this._fps_delay=1e3/this._fps_val)},handler:function(t,e){var n,r=this;if(null==e&&(e=!1),this.running)return this.time.now=t,n=this.isThrottled?1e3<(n=this._fps_delay)?n:1e3:this._fps_delay,(e||this.time.now-this.time.last>=n)&&(this.time.last=t,this.render()),requestAnimationFrame(function(t){return r.handler(t,!1)})}}),o={list:[],init:function(){var t,n,r=this;return this.inited=!0,t=null==document.hidden&&null==document.msHidden&&null!=document.webkiHidden?["webkitHidden","webkitvisibilitychange"]:["hidden","visibilitychange"],n=t[0],document.addEventListener(t[1],debounce(150,function(){var e=!!document[n];return r.list.map(function(t){return t.throttle(e)})},!1))},add:function(t){return this.inited||this.init(),this.list.push(t)}},s={wm:new WeakMap,ro:new ResizeObserver(function(t){return t.map(function(t){return s.wm.get(t.target)._resize()})}),add:function(t,e){return this.wm.set(t,e),this.ro.observe(t)},delete:function(t){return this.ro.unobserve(t),this.wm.delete(t)}},u=function(t,e,n){return null==e&&(e={}),null==n&&(n={}),function(t,e,n){var r,i;for(r in e)i=e[r],null==t[r]?t[r]=i:"object"!=typeof t[r]||"object"!=typeof i||n[r]&&n[r].type||u(t[r],e[r],n[r]);return t}(t=null==t?{}:t,e=JSON.parse(JSON.stringify(e)),n)},a=function(t){var o=function(t,e){var n,r,i;for(r in null==e&&(e={}),n=t.child,t)(i=t[r]).type?i.default&&(e[r]=i.default):o(i,e[r]||(e[r]={}));return e};return o(t)},(t=function(t){var e=this;return 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.init=proxise.once(function(){return e._init()}),this._resize=null,this.autoSelect&&(this.root.addEventListener("click",this._select=function(t){if(t=n(t.target,".data",e.root))return e.fire("select",[{data:e.dataAccessor(t),node:t}])}),this.root.addEventListener("mouseover",this._hover=function(t){if(t=ld$.parent(t.target,".data",e.root))return e.fire("hover",[{data:e.dataAccessor(t),node:t}])})),this}).prototype=h(Object.create(Object.prototype),{_init:function(){var n,t,e,r=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. "),(e=n.querySelector("[data-type=render]"))||console.warn("[@plotdb/chart] prepareSvg and layout is configured at the same time,\nyet render container for layout is not found. svg is thus appended in the root.")),(e||this.root).appendChild(this.svg)),this._aniloop=new i,o.add(this._aniloop),this._aniloop.on("tick",function(){return r.tick()}),Promise.resolve().then(function(){var t;if(r._defcfg=t=a(r.mod.config||{}),u(r.cfg,t),(!r.raw||!Array.isArray(r.raw))&&r.useSample&&r.mod.sample)return(t=r.mod.sample.apply(r)).then?t.then():Promise.resolve(t)}).then(function(t){return r.raw=(t=t||{}).raw,r.binding=t.binding,r}).then(function(){var t,e;if(r.raw||(r.raw=[]),r.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")),r.layout=new layout("object"==typeof r.layoutOpt?((t=h({},r.layoutOpt)).watchResize=!1,t):{root:n,watchResize:!1}))),e=proxise(function(){return s.add(r.root,r),null}),!r.forceInit&&r.root.offsetParent&&"none"!==window.getComputedStyle(r.root).display)return r._resize=function(){return e.resolve()},e()}).then(function(){return r._resize=function(){}}).then(function(){var t,e=function(){if(r.mod.init)return r.mod.init.apply(r)};return r.layout?(t=proxise(function(){return Promise.resolve(r.layout.init(e)),null}),r._layout=function(){return t.resolve()},r.layout.on("render",function(){return r._layout()}),t()):e()}).then(function(){r._layout=function(){},Promise.resolve().then(function(){if(r.delayRender)return r.renderLock=proxise(function(){}),r.renderLock()}).then(function(){return r._resize=function(){return r.resize(),r.render()},r._layout=function(){return r.parse(),r.bind(),r.resize(),r.render()},r.parse(),r.bind(),r.resize(),r.render()})})},parse:function(){var t,l=(t=this.mod).dimension||(t.dimension={}),h=this.binding;if(this.data=this.raw.map(function(e,t){var n,r,i,o,s={};for(n in r=l)i=r[n],(o=h[n])?(s[n]=i.multiple?(o.map?o:[o]).map(u):e[o.key],/[RIT]/.exec(i.type)&&!/[CN]/.exec(i.type)&&(s[n]=Array.isArray(s[n])?s[n].map(a):c(s[n]))):i.multiple&&(s[n]=[]);return s._raw=e,s._idx=t,s;function u(t){return e[t.key]}function a(t){return c(t)}}),this.mod.parse)return this.mod.parse.apply(this)},bind:function(){if(this.mod.bind)return this.mod.bind.apply(this)},start:function(){if(this._aniloop.run(),this.mod.start)return this.mod.start.apply(this)},stop:function(){if(this._aniloop.pause(),this.mod.stop)return this.mod.stop.apply(this)},resize:function(){if(this.layout&&this.layout.update(!1),this.box=this.root.getBoundingClientRect(),this.mod.resize)return this.mod.resize.apply(this)},tick:function(){if(this.mod.tick)return this.mod.tick.apply(this)},render:function(){if(this.mod.render)return this.mod.render.apply(this)},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),s.delete(t.root),t.layout&&t.layout.destroy(),t.stop(),t.mod.destroy)return t.mod.destroy.apply(t)})},config:function(){var t,e,n;if(!arguments.length)return this.cfg;for(t={},e=0,n=arguments.length;e<n;++e)u(t,arguments[e],this.mod.config);return u(t,this.cfg,this.mod.config),u(t,this._defcfg,this.mod.config),h(this.cfg,t)},_normalizeBinding:function(t){var e,n,r,i,o,s,u,a=[];if(null==t){for(t in e=[],this.mod.dimension||{})e.push(t);t=e}for(n=0,r=(t=!Array.isArray(t)?[t]:t).length;n<r;++n)i=t[n],o=(this.mod.dimension||{})[i]||{},s=this.binding[i],u=Array.isArray(s),!o.multiple!=!u&&(o.multiple||u)&&a.push(this.binding[i]=u?s[0]:s?[s]:[]);return a},setBind:function(t,e){return this.binding[t]=e,this._normalizeBinding([t]),this.parse(),this.bind(),this.resize(),this.render()},setRaw:function(t,e,n){var r;return null==n&&(n=!1),Array.isArray(t)||(t=(r=t).raw,e=r.binding,n=r.reinit),null!=t&&(this.raw=t),null!=e&&(this.binding=e,this._normalizeBinding()),this.renderLock?(this.renderLock.resolve(),this.renderLock=null):(n&&this.mod.init&&this.mod.init.apply(this),this.parse(),this.bind(),this.resize(),this.render())},on:function(t,n){var r=this;return(Array.isArray(t)?t:[t]).map(function(t){var e;return((e=r.evtHandler)[t]||(e[t]=[])).push(n)})},fire:function(t){for(var e,n,r,i,o=[],s=[],u=1,a=arguments.length;u<a;++u)s.push(arguments[u]);for(e=s,u=0,r=(n=this.evtHandler[t]||[]).length;u<r;++u)i=n[u],o.push(i.apply(this,e));return o},filter:function(t,e){var n,r,i,o,s;for(r in null==t&&(t={}),null==e&&(e=!1),n=[],i=this.binding)o=i[r],s=(s=Array.isArray(o)?o:[o]).map(u),n=n.concat(s);for(r in t)o=t[r],n.filter(a).map(l);return e&&this.fire("filter",t),this.mod.filter&&this.mod.filter.apply(this,[t,e]),this.parse(),this.bind(),this.resize(),this.render();function u(t){return{k:r,v:t}}function a(t){return t.k===r}function l(t){return t.v.filter=o}},sample:function(){return this.mod.sample?this.mod.sample.apply(this):{raw:[],binding:{}}}}),"undefined"!=typeof module&&null!==module?module.exports=t:"undefined"!=typeof window&&null!==window&&(window.chart=t)}.call(this);
1
+ !function(){var e,c,n,i,o,s,u,a,t;function l(t,e,d){function f(t,e){return n.call(t,e)}var p={}.toString,n={}.hasOwnProperty,m=!0;return function t(e,n,r){var i,o,s,u,a,l,h,c;if(null==e||null==n)return e===n;if(e.__placeholder__||n.__placeholder__)return!0;if(e===n)return 0!==e||1/e==1/n;i=p.call(e);if(p.call(n)!=i)return!1;switch(i){case"[object String]":return e==String(n);case"[object Number]":return e!=+e?n!=+n:0==e?1/e==1/n:e==+n;case"[object Date]":case"[object Boolean]":return+e==+n;case"[object RegExp]":return e.source==n.source&&e.global==n.global&&e.multiline==n.multiline&&e.ignoreCase==n.ignoreCase}if("object"!=typeof e||"object"!=typeof n)return!1;o=r.length;for(;o--;)if(r[o]==e)return!0;r.push(e);s=0;u=!0;if("[object Array]"==i){if(a=e.length,l=n.length,m){switch(d){case"===":u=a===l;break;case"<==":u=a<=l;break;case"<<=":u=a<l}s=a,m=!1}else u=a===l,s=a;if(u)for(;s--&&(u=s in e==s in n&&t(e[s],n[s],r)););}else{if("constructor"in e!="constructor"in n||e.constructor!=n.constructor)return!1;for(h in e)if(f(e,h)&&(s++,!(u=f(n,h)&&t(e[h],n[h],r))))break;if(u){for(h in c=0,n)f(n,h)&&++c;u=m?"<<="===d?s<c:"<=="===d?s<=c:s===c:(m=!1,s===c)}}r.pop();return u}(t,e,[])}function h(t,e){var n,r={}.hasOwnProperty;for(n in e)r.call(e,n)&&(t[n]=e[n]);return t}e=new function(t){var n=new Intl.NumberFormat(t),e=n.formatToParts(12345.6),t=Array.from({length:10}).map(function(t,e){return n.format(e)}),r=new Map(t.map(function(t,e){return[t,e]}));return this._group=new RegExp("["+e.find(function(t){return l(t.type,"group","===")}).value+"]","g"),this._decimal=new RegExp("["+e.find(function(t){return l(t.type,"decimal","===")}).value+"]"),this._numeral=new RegExp("["+t.join("")+"]","g"),this._index=function(t){return r.get(t)},this}("en-US"),c=function(t){return(t=((t=null==t?"":t)+"").trim().replace(e._group,"").replace(e._decimal,".").replace(e._numeral,e._index))?+t:NaN},n=function(t,e,n){for(var r=t;t&&t!==n;)t=t.parentNode;if(t!==n)return null;if(!e)return t;for(t=r;t&&t!==n&&(!t.matches||t.matches&&!t.matches(e));)t=t.parentNode;return t!==n||n.matches&&n.matches(e)?t:null},(i=function(){return this.running=!1,this.time={now:0,last:0},this.fps(60),this.evtHandler={},this}).prototype=h(Object.create(Object.prototype),{on:function(t,n){var r=this;return(Array.isArray(t)?t:[t]).map(function(t){var e;return((e=r.evtHandler)[t]||(e[t]=[])).push(n)})},fire:function(t){for(var e,n,r,i,o=[],s=[],u=1,a=arguments.length;u<a;++u)s.push(arguments[u]);for(e=s,u=0,r=(n=this.evtHandler[t]||[]).length;u<r;++u)i=n[u],o.push(i.apply(this,e));return o},reset:function(){return this.time={now:0}},setTime:function(t){return this.time.now=t},getTime:function(){return this.time.now},isRunning:function(){return this.running},toggle:function(t){return null!=t&&(this.running=!t),this.running?this.pause():this.run()},pause:function(){return this.running=!1},render:function(){return this.fire("tick",this.time.now)},run:function(t){var e=this;if(null!=t&&this.fps(t),!this.running)return this.running=!0,requestAnimationFrame(function(t){return e.handler(e.time.last=t,!0)})},throttle:function(t){return this.isThrottled=t=null==t?!0:t},fps:function(t){return null==t?this._fps_val:(this._fps_val=.01<t?t:.01,this._fps_delay=1e3/this._fps_val)},handler:function(t,e){var n,r=this;if(null==e&&(e=!1),this.running)return this.time.now=t,n=this.isThrottled?1e3<(n=this._fps_delay)?n:1e3:this._fps_delay,(e||this.time.now-this.time.last>=n)&&(this.time.last=t,this.render()),requestAnimationFrame(function(t){return r.handler(t,!1)})}}),o={list:[],init:function(){var t,n,r=this;return this.inited=!0,t=null==document.hidden&&null==document.msHidden&&null!=document.webkiHidden?["webkitHidden","webkitvisibilitychange"]:["hidden","visibilitychange"],n=t[0],document.addEventListener(t[1],debounce(150,function(){var e=!!document[n];return r.list.map(function(t){return t.throttle(e)})},!1))},add:function(t){return this.inited||this.init(),this.list.push(t)}},s={wm:new WeakMap,ro:new ResizeObserver(function(t){return t.map(function(t){return s.wm.get(t.target)._resize()})}),add:function(t,e){return this.wm.set(t,e),this.ro.observe(t)},delete:function(t){return this.ro.unobserve(t),this.wm.delete(t)}},u=function(t,e,n){return null==e&&(e={}),null==n&&(n={}),function(t,e,n){var r,i;for(r in e)i=e[r],null==t[r]?t[r]=i:"object"!=typeof t[r]||"object"!=typeof i||n[r]&&n[r].type||u(t[r],e[r],n[r]);return t}(t=null==t?{}:t,e=JSON.parse(JSON.stringify(e)),n)},a=function(t){var o=function(t,e){var n,r,i;for(r in null==e&&(e={}),n=t.child,t)(i=t[r]).type?i.default&&(e[r]=i.default):o(i,e[r]||(e[r]={}));return e};return o(t)},(t=function(t){var e=this;return 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.init=proxise.once(function(){return e._init()}),this._resize=null,this.autoSelect&&(this.root.addEventListener("click",this._select=function(t){if(t=n(t.target,".data",e.root))return e.fire("select",[{data:e.dataAccessor(t),node:t}])}),this.root.addEventListener("mouseover",this._hover=function(t){if(t=ld$.parent(t.target,".data",e.root))return e.fire("hover",[{data:e.dataAccessor(t),node:t}])})),this}).prototype=h(Object.create(Object.prototype),{_init:function(){var n,t,e,r=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. "),(e=n.querySelector("[data-type=render]"))||console.warn("[@plotdb/chart] prepareSvg and layout is configured at the same time,\nyet render container for layout is not found. svg is thus appended in the root.")),(e||this.root).appendChild(this.svg)),this._aniloop=new i,o.add(this._aniloop),this._aniloop.on("tick",function(){return r.tick()}),Promise.resolve().then(function(){var t;return r._defcfg=t=a(r.mod.config||{}),u(r.cfg,t),r.raw&&Array.isArray(r.raw)?{raw:r.raw,binding:r.binding}:r.useSample&&r.mod.sample?(t=r.mod.sample.apply(r)).then?t.then():Promise.resolve(t):void 0}).then(function(t){return r.raw=(t=t||{}).raw,r.binding=t.binding,r}).then(function(){var t,e;if(r.raw||(r.raw=[]),r.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")),r.layout=new layout("object"==typeof r.layoutOpt?((t=h({},r.layoutOpt)).watchResize=!1,t):{root:n,watchResize:!1}))),e=proxise(function(){return s.add(r.root,r),null}),!r.forceInit&&r.root.offsetParent&&"none"!==window.getComputedStyle(r.root).display)return r._resize=function(){return e.resolve()},e()}).then(function(){return r._resize=function(){}}).then(function(){var t,e=function(){if(r.mod.init)return r.mod.init.apply(r)};return r.layout?(t=proxise(function(){return Promise.resolve(r.layout.init(e)),null}),r._layout=function(){return t.resolve()},r.layout.on("render",function(){return r._layout()}),t()):e()}).then(function(){r._layout=function(){},Promise.resolve().then(function(){if(r.delayRender)return r.renderLock=proxise(function(){}),r.renderLock()}).then(function(){return r._resize=function(){return r.resize(),r.render()},r._layout=function(){return r.parse(),r.bind(),r.resize(),r.render()},r.parse(),r.bind(),r.resize(),r.render()})})},parse:function(){var t,l=(t=this.mod).dimension||(t.dimension={}),h=this.binding;if(this.data=this.raw.map(function(e,t){var n,r,i,o,s={};for(n in r=l)i=r[n],(o=h[n])?(s[n]=i.multiple?(o.map?o:[o]).map(u):e[o.key],/[RIT]/.exec(i.type)&&!/[CN]/.exec(i.type)&&(s[n]=Array.isArray(s[n])?s[n].map(a):c(s[n]))):i.multiple&&(s[n]=[]);return s._raw=e,s._idx=t,s;function u(t){return e[t.key]}function a(t){return c(t)}}),this.mod.parse)return this.mod.parse.apply(this)},bind:function(){if(this.mod.bind)return this.mod.bind.apply(this)},start:function(){if(this._aniloop.run(),this.mod.start)return this.mod.start.apply(this)},stop:function(){if(this._aniloop.pause(),this.mod.stop)return this.mod.stop.apply(this)},resize:function(){if(this.layout&&this.layout.update(!1),this.box=this.root.getBoundingClientRect(),this.mod.resize)return this.mod.resize.apply(this)},tick:function(){if(this.mod.tick)return this.mod.tick.apply(this)},render:function(){if(this.mod.render)return this.mod.render.apply(this)},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),s.delete(t.root),t.layout&&t.layout.destroy(),t.stop(),t.mod.destroy)return t.mod.destroy.apply(t)})},config:function(){var t,e,n;if(!arguments.length)return this.cfg;for(t={},e=0,n=arguments.length;e<n;++e)u(t,arguments[e],this.mod.config);return u(t,this.cfg,this.mod.config),u(t,this._defcfg,this.mod.config),h(this.cfg,t)},_normalizeBinding:function(t){var e,n,r,i,o,s,u,a=[];if(null==t){for(t in e=[],this.mod.dimension||{})e.push(t);t=e}for(n=0,r=(t=!Array.isArray(t)?[t]:t).length;n<r;++n)i=t[n],o=(this.mod.dimension||{})[i]||{},s=this.binding[i],u=Array.isArray(s),!o.multiple!=!u&&(o.multiple||u)&&a.push(this.binding[i]=u?s[0]:s?[s]:[]);return a},setBind:function(t,e){return this.binding[t]=e,this._normalizeBinding([t]),this.parse(),this.bind(),this.resize(),this.render()},setRaw:function(t,e,n){var r;return null==n&&(n=!1),Array.isArray(t)||(t=(r=t).raw,e=r.binding,n=r.reinit),null!=t&&(this.raw=t),null!=e&&(this.binding=e,this._normalizeBinding()),this.renderLock?(this.renderLock.resolve(),this.renderLock=null):(n&&this.mod.init&&this.mod.init.apply(this),this.parse(),this.bind(),this.resize(),this.render())},on:function(t,n){var r=this;return(Array.isArray(t)?t:[t]).map(function(t){var e;return((e=r.evtHandler)[t]||(e[t]=[])).push(n)})},fire:function(t){for(var e,n,r,i,o=[],s=[],u=1,a=arguments.length;u<a;++u)s.push(arguments[u]);for(e=s,u=0,r=(n=this.evtHandler[t]||[]).length;u<r;++u)i=n[u],o.push(i.apply(this,e));return o},filter:function(t,e){var n,r,i,o,s;for(r in null==t&&(t={}),null==e&&(e=!1),n=[],i=this.binding)o=i[r],s=(s=Array.isArray(o)?o:[o]).map(u),n=n.concat(s);for(r in t)o=t[r],n.filter(a).map(l);return e&&this.fire("filter",t),this.mod.filter&&this.mod.filter.apply(this,[t,e]),this.parse(),this.bind(),this.resize(),this.render();function u(t){return{k:r,v:t}}function a(t){return t.k===r}function l(t){return t.v.filter=o}},sample:function(){return this.mod.sample?this.mod.sample.apply(this):{raw:[],binding:{}}}}),"undefined"!=typeof module&&null!==module?module.exports=t:"undefined"!=typeof window&&null!==window&&(window.chart=t)}.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":"2.1.37","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"},"devDependencies":{"@loadingio/bootstrap.ext":"^0.0.9","@loadingio/ldquery":"^3.0.4","@loadingio/loading.css":"^3.1.0","@loadingio/vscroll":"^0.0.11","@plotdb/layout":"^0.0.12","@plotdb/pdmap-world":"^0.0.5","@plotdb/semver":"^0.0.3","@plotdb/sheet":"^0.5.8","@xlfont/choose":"^0.0.16","@xlfont/load":"^2.1.2","@zbryikt/template":"^2.3.45","bootstrap":"^4.6.1","bootstrap.native":"^3.0.15","fedep":"^1.1.11","jsdom":"^22.1.0","ldbutton":"^2.0.1","ldfile":"^2.0.1","ldiconfont":"^0.2.4","ldloader":"^3.0.2","ldview":"^1.4.0","livescript":"^1.6.0","pdmaptw":"2.2.1","uglify-js":"^3.13.1","uglifycss":"^0.0.29","zmgr":"^2.2.3"},"frontendDependencies":{"root":"web/static/assets/lib","modules":["bootstrap","bootstrap.native","@loadingio/bootstrap.ext","@loadingio/ldquery","@loadingio/loading.css","@loadingio/ldcolorpicker","@loadingio/debounce.js","@loadingio/vscroll","@plotdb/pdmap-world","@plotdb/block","@plotdb/csscope","@plotdb/rescope","@plotdb/layout","@plotdb/sheet","@plotdb/konfig","@plotdb/semver","@xlfont/choose","@xlfont/load","@zbryikt/voronoijs","d3","d3-array","d3-axis","d3-brush","d3-color","d3-dispatch","d3-drag","d3-ease","d3-force","d3-force-boundary","d3-format","d3-hierarchy","d3-interpolate","d3-path","d3-quadtree","d3-random","d3-scale-chromatic","d3-selection","d3-shape","d3-timer","d3-transition","choosefont.js","pdmaptw","proxise","ldiconfont","ldloader","ldbutton","ldcover","ldcolor","ldfile","ldslider","wrap-svg-text","ldpalettepicker","zmgr","ldview"]},"dependencies":{"@loadingio/debounce.js":"^1.0.1","@loadingio/ldcolorpicker":"^3.0.5","@plotdb/block":"^5.2.2","@plotdb/csscope":"^5.0.3","@plotdb/konfig":"^4.8.12","@plotdb/rescope":"^5.0.9","@zbryikt/voronoijs":"^1.0.0","choosefont.js":"^0.0.1","d3":"^4.13.0","d3-array":"^3.1.1","d3-axis":"^3.0.0","d3-brush":"^3.0.0","d3-color":"^3.1.0","d3-dispatch":"^3.0.1","d3-drag":"^3.0.0","d3-ease":"^3.0.1","d3-force":"^3.0.0","d3-force-boundary":"^0.0.2","d3-format":"^3.1.0","d3-hierarchy":"^3.1.1","d3-interpolate":"^3.0.1","d3-path":"^3.0.1","d3-quadtree":"^3.0.1","d3-random":"^3.0.1","d3-scale-chromatic":"^3.0.0","d3-selection":"^3.0.0","d3-shape":"^3.1.0","d3-timer":"^3.0.1","d3-transition":"^3.0.1","ldcolor":"^1.1.3","ldcover":"^3.5.1","ldpalettepicker":"^4.0.4","ldslider":"^3.1.1","proxise":"^1.0.1","wrap-svg-text":"^0.0.7"}}
1
+ {"author":"zbryikt","name":"@plotdb/chart","license":"MIT","description":"plotdb charts","style":"index.min.css","browser":"index.min.js","main":"index.min.js","version":"2.1.38","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"},"devDependencies":{"@loadingio/bootstrap.ext":"^0.0.12","@loadingio/ldquery":"^3.0.6","@loadingio/loading.css":"^3.2.1","@loadingio/vscroll":"^0.0.11","@plotdb/layout":"^0.0.12","@plotdb/pdmap-world":"^0.0.5","@plotdb/semver":"^0.0.3","@plotdb/sheet":"^0.7.0","@xlfont/choose":"^0.0.32","@xlfont/load":"^2.1.5","@zbryikt/template":"^2.4.1","bootstrap":"^4.6.1","bootstrap.native":"^3.0.15","fedep":"^1.5.0","jsdom":"^22.1.0","ldbutton":"^2.0.5","ldfile":"^2.0.1","ldiconfont":"^0.2.8","ldloader":"^3.0.3","ldview":"^1.5.1","livescript":"^1.6.0","pdmaptw":"2.2.1","uglify-js":"^3.13.1","uglifycss":"^0.0.29","zmgr":"^2.2.3"},"frontendDependencies":{"root":"web/static/assets/lib","modules":["bootstrap","bootstrap.native","@loadingio/bootstrap.ext","@loadingio/ldquery","@loadingio/loading.css","@loadingio/ldcolorpicker","@loadingio/debounce.js","@loadingio/vscroll","@plotdb/pdmap-world","@plotdb/block","@plotdb/csscope","@plotdb/rescope","@plotdb/layout","@plotdb/sheet","@plotdb/konfig","@plotdb/semver","@xlfont/choose","@xlfont/load","@zbryikt/voronoijs","d3","d3-array","d3-axis","d3-brush","d3-color","d3-dispatch","d3-drag","d3-ease","d3-force","d3-force-boundary","d3-format","d3-hierarchy","d3-interpolate","d3-path","d3-quadtree","d3-random","d3-scale-chromatic","d3-selection","d3-shape","d3-timer","d3-transition","choosefont.js","pdmaptw","proxise","ldiconfont","ldloader","ldbutton","ldcover","ldcolor","ldfile","ldslider","wrap-svg-text","ldpalettepicker","zmgr","ldview"]},"dependencies":{"@loadingio/debounce.js":"^1.0.1","@loadingio/ldcolorpicker":"^3.0.5","@plotdb/block":"^5.2.2","@plotdb/csscope":"^5.0.3","@plotdb/konfig":"^4.8.12","@plotdb/rescope":"^5.0.9","@zbryikt/voronoijs":"^1.0.0","choosefont.js":"^0.0.1","d3":"^4.13.0","d3-array":"^3.1.1","d3-axis":"^3.0.0","d3-brush":"^3.0.0","d3-color":"^3.1.0","d3-dispatch":"^3.0.1","d3-drag":"^3.0.0","d3-ease":"^3.0.1","d3-force":"^3.0.0","d3-force-boundary":"^0.0.2","d3-format":"^3.1.0","d3-hierarchy":"^3.1.1","d3-interpolate":"^3.0.1","d3-path":"^3.0.1","d3-quadtree":"^3.0.1","d3-random":"^3.0.1","d3-scale-chromatic":"^3.0.0","d3-selection":"^3.0.0","d3-shape":"^3.1.0","d3-timer":"^3.0.1","d3-transition":"^3.0.1","ldcolor":"^1.1.3","ldcover":"^3.5.1","ldpalettepicker":"^4.0.4","ldslider":"^3.1.1","proxise":"^1.0.1","wrap-svg-text":"^0.0.7"}}
package/utils/axis.js CHANGED
@@ -36,6 +36,15 @@
36
36
  x$.setAttribute('dominant-baseline', 'hanging');
37
37
  x$.setAttribute('text-anchor', 'middle');
38
38
  n.root.appendChild(n.label);
39
+ n.sideNote = [0, 1].map(function(i){
40
+ var ret, x$;
41
+ ret = ceNS('text');
42
+ ret.textContent = '';
43
+ x$ = ret;
44
+ x$.setAttribute('dominant-baseline', 'hanging');
45
+ x$.setAttribute('text-anchor', ['start', 'end'][i]);
46
+ return n.root.appendChild(ret);
47
+ });
39
48
  this.wrapper();
40
49
  y$ = this.layout;
41
50
  y$.on('update', function(){
@@ -79,13 +88,17 @@
79
88
  caption: {
80
89
  padding: 1
81
90
  },
82
- enabled: c.enabled
91
+ enabled: c.enabled,
92
+ sideNoteStart: {},
93
+ sideNoteEnd: {}
83
94
  };
84
- ['tick', 'baseline', 'label', 'caption'].map(function(n){
95
+ ['tick', 'baseline', 'label', 'caption', 'sideNoteStart', 'sideNoteEnd'].map(function(n){
85
96
  return import$(this$.cfg[n], c[n] || {});
86
97
  });
87
98
  (ref$ = this.cfg.label).font || (ref$.font = {});
88
99
  (ref$ = this.cfg.caption).font || (ref$.font = {});
100
+ (ref$ = this.cfg.sideNoteStart).font || (ref$.font = {});
101
+ (ref$ = this.cfg.sideNoteEnd).font || (ref$.font = {});
89
102
  return this.format(this.cfg.label.format);
90
103
  },
91
104
  config: function(c){
@@ -247,6 +260,11 @@
247
260
  x$ = n.label;
248
261
  x$.setAttribute('text-anchor', ['start', 'middle', 'end'][mm3]);
249
262
  x$.setAttribute('dominant-baseline', ['baseline', 'hanging'][md3]);
263
+ n.sideNote.map(function(n, i){
264
+ var pos;
265
+ pos = (this$.cfg[['sideNoteStart', 'sideNoteEnd'][i]] || {}).position || 0;
266
+ return n.setAttribute('dominant-baseline', ['baseline', 'hanging'][pos]);
267
+ });
250
268
  if (isHorizon) {
251
269
  n.domain.setAttribute('d', "M0 0L" + box.width + " 0Z");
252
270
  n.label.setAttribute('x', box.width / 2);
@@ -369,6 +387,17 @@
369
387
  this$._n.label.style.fontSize = this$.cfg.caption.font.size ? this$.cfg.caption.font.size + "" || '' : void 8;
370
388
  this$._n.label.setAttribute('class', (this$.cfg.caption.font.family || {}).className || '');
371
389
  this$.caption();
390
+ this$._n.sideNote.map(function(n, i){
391
+ var cfg, font;
392
+ cfg = this$.cfg[['sideNoteStart', 'sideNoteEnd'][i]] || {};
393
+ font = cfg.font || {};
394
+ n.textContent = !cfg.show
395
+ ? ''
396
+ : cfg.text || '';
397
+ n.style.fill = cfg.color;
398
+ n.style.fontSize = font.size ? font.size + "" || '' : void 8;
399
+ return n.setAttribute('class', (font.family || {}).className || '');
400
+ });
372
401
  mm3 = (this$.cfg.caption.position || 0) % 3;
373
402
  md3 = Math.floor((this$.cfg.caption.position || 0) / 3);
374
403
  size = Math.max.apply(Math, [0].concat(lc.picked.map(function(it){
@@ -377,7 +406,15 @@
377
406
  delta = this$.cfg.tick.inner + this$.cfg.label.padding + this$.cfg.caption.padding + size;
378
407
  if (this$.dir < 2) {
379
408
  this$._n.label.setAttribute('y', [-2, delta][md3]);
380
- return this$._n.layout.style.height = (delta + this$._n.label.getBoundingClientRect().height) + "px";
409
+ this$._n.layout.style.height = (delta + this$._n.label.getBoundingClientRect().height) + "px";
410
+ box = this$._n.layout.getBoundingClientRect();
411
+ return this$._n.sideNote.map(function(n, i){
412
+ var cfg, pos;
413
+ cfg = this$.cfg[['sideNoteStart', 'sideNoteEnd'][i]] || {};
414
+ pos = cfg.position || 0;
415
+ n.setAttribute('x', [2, box.width - 2][i]);
416
+ return n.setAttribute('y', [-2 - cfg.padding, delta + cfg.padding][pos]);
417
+ });
381
418
  } else {
382
419
  this$._n.label.setAttribute('x', 0);
383
420
  this$._n.label.setAttribute('y', 0);
@@ -386,7 +423,15 @@
386
423
  xoff = [2, -delta - 2][md3];
387
424
  yoff = [2, box.height / 2, box.height - 2][mm3];
388
425
  this$._n.label.setAttribute('transform', "translate(" + xoff + "," + yoff + ") rotate(90)");
389
- return this$._n.root.setAttribute('transform', "translate(" + (box.width - 1) + ",0)");
426
+ this$._n.root.setAttribute('transform', "translate(" + (box.width - 1) + ",0)");
427
+ return this$._n.sideNote.map(function(n, i){
428
+ var cfg, pos, xoff, yoff;
429
+ cfg = this$.cfg[['sideNoteStart', 'sideNoteEnd'][i]] || {};
430
+ pos = cfg.position || 0;
431
+ xoff = [2 + cfg.padding, -delta - 2 - cfg.padding][pos];
432
+ yoff = [2, box.height - 2][i];
433
+ return n.setAttribute('transform', "translate(" + xoff + "," + yoff + ") rotate(90)");
434
+ });
390
435
  }
391
436
  };
392
437
  return bfs(5);
package/utils/axis.min.js CHANGED
@@ -1 +1 @@
1
- !function(){var s,t;function c(t,e){var n,i={}.hasOwnProperty;for(n in e)i.call(e,n)&&(t[n]=e[n]);return t}s=function(t){return document.createElementNS("http://www.w3.org/2000/svg",t)},(t=function(t){var e,n=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=e={root:s("g"),layout:this.layout.getNode(this.name),render:this.layout.getGroup(this.name),wrap:null,domain:s("path")},e.render.appendChild(e.root),e.root.appendChild(e.domain),e.label=s("text"),e.label.textContent="",(t=e.label).setAttribute("dominant-baseline","hanging"),t.setAttribute("text-anchor","middle"),e.root.appendChild(e.label),this.wrapper(),(e=this.layout).on("update",function(){return n.update()}),e.on("render",function(){return n.render()}),this}).prototype=c(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"),c(((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},caption:{padding:1},enabled:e.enabled},["tick","baseline","label","caption"].map(function(t){return c(n.cfg[t],e[t]||{})}),(t=this.cfg.label).font||(t.font={}),(t=this.cfg.caption).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,o={},r=this._n.layout.getBoundingClientRect()[this.dir<2?"width":"height"],r=Math.round(r/25),l=1<(t=Math.round(n.length/(1<r?r:1)))?t:1;for(e in this._ticks=n.filter(function(t,e){return!(e%l)||e===n.length-1}).map(function(t){var e,n;return o[(t="object"!=typeof t?{v:t}:t).v]=c((e=a._map)[n=t.v]||(e[n]={}),t)}),t=this._map)i=t[e],o[e]||i.n.g.parentNode.removeChild(i.n.g);return this._map=o,this._ticks.filter(function(t){return!t.n}).map(function(t){if(t.n={g:s("g"),p:s("path"),t:s("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,o,r,l=this,s=this._n,c=this.dir<2,h=s.wrap;return h.style.fontSize=this.cfg.label.font.size?this.cfg.label.font.size+""||"":void 0,h.setAttribute("class",(this.cfg.label.font.family||{}).className||""),i=this._ticks,null==this.cfg.enabled||this.cfg.enabled?(c?((t=s.layout.style).height="",t.paddingTop="",t.paddingBottom=""):((t=s.layout.style).width="",t.paddingLeft="",t.paddingRight=""),s.domain.style.display="",i.map(function(t){return t.n.g.style.display=""}),a=getComputedStyle(h).fontSize,e=s.layout.getBoundingClientRect(),(t=s.domain.style).strokeWidth=1,t.stroke="currentColor",t.fill="none",i.map(function(t,e){var n=e?e===i.length-1?2:1:0;return t._c=null!=t.c?t.c:l._scale(t.v)+(l._scale.bandwidth?l._scale.bandwidth()/2:0),t._t=null!=t.t?t.t:l._format(t.v),(e=t.n.p.style).strokeWidth=1,e.stroke="currentColor",e.fill="none",h.textContent=t._t,h.style.textAlign=c?["left","center","right"][n]:["right","left"][l.dir-2],t.n.tt=wrapSvgText({node:h}),t.n.t.style.fontSize=a,t.n.t.style.fill=l.cfg.label.color,t.n.t.textContent="",t.n.t.appendChild(t.n.tt),t.n.t.setAttribute("class",(l.cfg.label.font||{}).className||"")}),i.sort(function(t,e){return t._c-e._c}),s.domain.style.stroke=this.cfg.baseline.show?this.cfg.baseline.color:"none",r=(this.cfg.caption.position||0)%3,n=Math.floor((this.cfg.caption.position||0)/3),(o=s.label).setAttribute("text-anchor",["start","middle","end"][r]),o.setAttribute("dominant-baseline",["baseline","hanging"][n]),c?(s.domain.setAttribute("d","M0 0L"+e.width+" 0Z"),s.label.setAttribute("x",e.width/2),s.label.setAttribute("x",[2,e.width/2,e.width-2][r])):(s.domain.setAttribute("d","M0 0L0 "+e.height+"Z"),r=[2,e.height/2,e.height-2][r],s.label.setAttribute("transform","translate(0,"+r+") rotate(90)")),i.map(function(t){return t.box=t.n.t.getBBox()}),this.adjust()):(c?((t=s.layout.style).height="0px",t.paddingTop="0",t.paddingBottom="0"):((t=s.layout.style).width="0px",t.paddingLeft="0",t.paddingRight="0"),s.domain.style.display="none",void i.map(function(t){return t.n.g.style.display="none"}))},adjust:function(){var u=this,f=this._ticks,d=this.dir<2,p=function(t,e,n){var i,a,o,r,l,s,c,h;if(!n.checked[t])return n.checked[t]=!0,i=f[t],r=t?t===f.length-1?2:1:0,h=[i._c,i._t][0],o={x:-(a=i.box).x,y:-a.y},r=!u._scale.bandwidth&&(null!=u.cfg.tick.boundaryOffset?!!u.cfg.tick.boundaryOffset:u.dir<2)?r/2:.5,d?o.x-=a.width*r:o.y-=a.height*r,i.n.tt.setAttribute("transform","translate("+o.x+","+o.y+")"),(a={size:a[d?"width":"height"],sizeAlt:a[d?"height":"width"],lv:e,tick:i,idx:t}).coord=h-a.size*r,d?(i.n.g.setAttribute("transform","translate("+h+",0)"),i.n.p.setAttribute("d","M0 0L0 "+u.cfg.tick.inner),i.n.t.setAttribute("transform","translate(0,"+(u.cfg.tick.inner+u.cfg.label.padding)+")")):(i.n.g.setAttribute("transform","translate(0,"+h+")"),i.n.p.setAttribute("d","M0 0L-"+u.cfg.tick.inner+" 0"),i.n.t.setAttribute("transform","translate("+(-u.cfg.tick.inner-a.sizeAlt-1-u.cfg.label.padding)+",0)")),h=[a.coord,a.coord+a.size],s=(h=[(l=h[0])-2,h[1]+2])[0],c=h[1],h=n.picked.filter(function(t){var e=[t.coord,t.coord+t.size],t=e[0];return(e=[t-2,e[1]+2])[0]<l&&l<e[1]||s<t&&t<c}).length,i.n.t.style.opacity=h?0:1,i.n.p.style.stroke=u.cfg.tick.color||"",n.picked.push(a),!h};return function(t){var e,n,i,a,o,r,l,s,c,h,d;for(null==t&&(t=1),e=[{checked:{},picked:[],node:u._n.wrap},[]],n=e[0],i=e[1],n.fontSize=getComputedStyle(n.node).fontSize,f.map(function(t){return t.n.t.style.opacity=0}),f.length&&(i.push([0,f.length-1,0]),[0,f.length-1].map(function(t){return p(t,0,n)}));i.length;)a=(e=i.splice(0,1)[0])[0],o=e[1],t<=(r=e[2])||(l=Math.floor((a+o)/2),p(l,r,n),a+1<l&&i.push([a,l,r+1]),l+1<o&&i.push([l,o,r+1]));return u._n.label.style.fill=u.cfg.caption.color,u._n.label.style.fontSize=u.cfg.caption.font.size?u.cfg.caption.font.size+""||"":void 0,u._n.label.setAttribute("class",(u.cfg.caption.font.family||{}).className||""),u.caption(),d=(u.cfg.caption.position||0)%3,s=Math.floor((u.cfg.caption.position||0)/3),h=Math.max.apply(Math,[0].concat(n.picked.map(function(t){return t.sizeAlt}))),c=u.cfg.tick.inner+u.cfg.label.padding+u.cfg.caption.padding+h,u.dir<2?(u._n.label.setAttribute("y",[-2,c][s]),u._n.layout.style.height=c+u._n.label.getBoundingClientRect().height+"px"):(u._n.label.setAttribute("x",0),u._n.label.setAttribute("y",0),u._n.layout.style.width=c+u._n.label.getBoundingClientRect().width+"px",d=[2,(h=u._n.layout.getBoundingClientRect()).height/2,h.height-2][d],u._n.label.setAttribute("transform","translate("+[2,-c-2][s]+","+d+") rotate(90)"),u._n.root.setAttribute("transform","translate("+(h.width-1)+",0)"))}(5)}}),"undefined"!=typeof chart&&null!==chart&&((chart.utils||(chart.utils={})).axis=t)}.call(this);
1
+ !function(){var l,t;function c(t,e){var n,i={}.hasOwnProperty;for(n in e)i.call(e,n)&&(t[n]=e[n]);return t}l=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:l("g"),layout:this.layout.getNode(this.name),render:this.layout.getGroup(this.name),wrap:null,domain:l("path")},i.render.appendChild(i.root),i.root.appendChild(i.domain),i.label=l("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=l("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=c(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"),c(((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},caption:{padding:1},enabled:e.enabled,sideNoteStart:{},sideNoteEnd:{}},["tick","baseline","label","caption","sideNoteStart","sideNoteEnd"].map(function(t){return c(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,o=this,a={},r=this._n.layout.getBoundingClientRect()[this.dir<2?"width":"height"],r=Math.round(r/25),s=1<(t=Math.round(n.length/(1<r?r:1)))?t:1;for(e in this._ticks=n.filter(function(t,e){return!(e%s)||e===n.length-1}).map(function(t){var e,n;return a[(t="object"!=typeof t?{v:t}:t).v]=c((e=o._map)[n=t.v]||(e[n]={}),t)}),t=this._map)i=t[e],a[e]||i.n.g.parentNode.removeChild(i.n.g);return this._map=a,this._ticks.filter(function(t){return!t.n}).map(function(t){if(t.n={g:l("g"),p:l("path"),t:l("g")},t.n.g.appendChild(t.n.p),t.n.g.appendChild(t.n.t),o._n.root.appendChild(t.n.g),isNaN(+t.v))return t.t=t.v})},render:function(){var i,t,o,e,n,a,r,s=this,l=this._n,c=this.dir<2,d=l.wrap;return d.style.fontSize=this.cfg.label.font.size?this.cfg.label.font.size+""||"":void 0,d.setAttribute("class",(this.cfg.label.font.family||{}).className||""),i=this._ticks,null==this.cfg.enabled||this.cfg.enabled?(c?((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=""}),o=getComputedStyle(d).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===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),(e=t.n.p.style).strokeWidth=1,e.stroke="currentColor",e.fill="none",d.textContent=t._t,d.style.textAlign=c?["left","center","right"][n]:["right","left"][s.dir-2],t.n.tt=wrapSvgText({node:d}),t.n.t.style.fontSize=o,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",r=(this.cfg.caption.position||0)%3,n=Math.floor((this.cfg.caption.position||0)/3),(a=l.label).setAttribute("text-anchor",["start","middle","end"][r]),a.setAttribute("dominant-baseline",["baseline","hanging"][n]),l.sideNote.map(function(t,e){e=(s.cfg[["sideNoteStart","sideNoteEnd"][e]]||{}).position||0;return t.setAttribute("dominant-baseline",["baseline","hanging"][e])}),c?(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][r])):(l.domain.setAttribute("d","M0 0L0 "+e.height+"Z"),r=[2,e.height/2,e.height-2][r],l.label.setAttribute("transform","translate(0,"+r+") rotate(90)")),i.map(function(t){return t.box=t.n.t.getBBox()}),this.adjust()):(c?((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",void i.map(function(t){return t.n.g.style.display="none"}))},adjust:function(){var f=this,p=this._ticks,h=this.dir<2,g=function(t,e,n){var i,o,a,r,s,l,c,d;if(!n.checked[t])return n.checked[t]=!0,i=p[t],r=t?t===p.length-1?2:1:0,d=[i._c,i._t][0],a={x:-(o=i.box).x,y:-o.y},r=!f._scale.bandwidth&&(null!=f.cfg.tick.boundaryOffset?!!f.cfg.tick.boundaryOffset:f.dir<2)?r/2:.5,h?a.x-=o.width*r:a.y-=o.height*r,i.n.tt.setAttribute("transform","translate("+a.x+","+a.y+")"),(o={size:o[h?"width":"height"],sizeAlt:o[h?"height":"width"],lv:e,tick:i,idx:t}).coord=d-o.size*r,h?(i.n.g.setAttribute("transform","translate("+d+",0)"),i.n.p.setAttribute("d","M0 0L0 "+f.cfg.tick.inner),i.n.t.setAttribute("transform","translate(0,"+(f.cfg.tick.inner+f.cfg.label.padding)+")")):(i.n.g.setAttribute("transform","translate(0,"+d+")"),i.n.p.setAttribute("d","M0 0L-"+f.cfg.tick.inner+" 0"),i.n.t.setAttribute("transform","translate("+(-f.cfg.tick.inner-o.sizeAlt-1-f.cfg.label.padding)+",0)")),d=[o.coord,o.coord+o.size],l=(d=[(s=d[0])-2,d[1]+2])[0],c=d[1],d=n.picked.filter(function(t){var e=[t.coord,t.coord+t.size],t=e[0];return(e=[t-2,e[1]+2])[0]<s&&s<e[1]||l<t&&t<c}).length,i.n.t.style.opacity=d?0:1,i.n.p.style.stroke=f.cfg.tick.color||"",n.picked.push(o),!d};return function(t){var e,n,i,o,a,r,s,l,c,d,h,u;for(null==t&&(t=1),e=[{checked:{},picked:[],node:f._n.wrap},[]],n=e[0],i=e[1],n.fontSize=getComputedStyle(n.node).fontSize,p.map(function(t){return t.n.t.style.opacity=0}),p.length&&(i.push([0,p.length-1,0]),[0,p.length-1].map(function(t){return g(t,0,n)}));i.length;)o=(e=i.splice(0,1)[0])[0],a=e[1],t<=(r=e[2])||(s=Math.floor((o+a)/2),g(s,r,n),o+1<s&&i.push([o,s,r+1]),s+1<a&&i.push([s,a,r+1]));return f._n.label.style.fill=f.cfg.caption.color,f._n.label.style.fontSize=f.cfg.caption.font.size?f.cfg.caption.font.size+""||"":void 0,f._n.label.setAttribute("class",(f.cfg.caption.font.family||{}).className||""),f.caption(),f._n.sideNote.map(function(t,e){var n=f.cfg[["sideNoteStart","sideNoteEnd"][e]]||{},e=n.font||{};return t.textContent=n.show&&n.text||"",t.style.fill=n.color,t.style.fontSize=e.size?e.size+""||"":void 0,t.setAttribute("class",(e.family||{}).className||"")}),u=(f.cfg.caption.position||0)%3,l=Math.floor((f.cfg.caption.position||0)/3),c=Math.max.apply(Math,[0].concat(n.picked.map(function(t){return t.sizeAlt}))),d=f.cfg.tick.inner+f.cfg.label.padding+f.cfg.caption.padding+c,f.dir<2?(f._n.label.setAttribute("y",[-2,d][l]),f._n.layout.style.height=d+f._n.label.getBoundingClientRect().height+"px",h=f._n.layout.getBoundingClientRect(),f._n.sideNote.map(function(t,e){var n=f.cfg[["sideNoteStart","sideNoteEnd"][e]]||{},i=n.position||0;return t.setAttribute("x",[2,h.width-2][e]),t.setAttribute("y",[-2-n.padding,d+n.padding][i])})):(f._n.label.setAttribute("x",0),f._n.label.setAttribute("y",0),f._n.layout.style.width=d+f._n.label.getBoundingClientRect().width+"px",u=[2,(h=f._n.layout.getBoundingClientRect()).height/2,h.height-2][u],f._n.label.setAttribute("transform","translate("+[2,-d-2][l]+","+u+") rotate(90)"),f._n.root.setAttribute("transform","translate("+(h.width-1)+",0)"),f._n.sideNote.map(function(t,e){var n=f.cfg[["sideNoteStart","sideNoteEnd"][e]]||{},i=n.position||0,i=[2+n.padding,-d-2-n.padding][i],e=[2,h.height-2][e];return t.setAttribute("transform","translate("+i+","+e+") rotate(90)")}))}(5)}}),"undefined"!=typeof chart&&null!==chart&&((chart.utils||(chart.utils={})).axis=t)}.call(this);
package/utils/config.js CHANGED
@@ -220,6 +220,76 @@
220
220
  ]
221
221
  },
222
222
  font: font
223
+ },
224
+ sideNoteStart: {
225
+ show: {
226
+ type: 'boolean',
227
+ 'default': false
228
+ },
229
+ text: {
230
+ type: 'text',
231
+ 'default': ''
232
+ },
233
+ position: {
234
+ type: 'choice',
235
+ 'default': 0,
236
+ values: [
237
+ {
238
+ name: 'in',
239
+ value: 0
240
+ }, {
241
+ name: 'out',
242
+ value: 1
243
+ }
244
+ ]
245
+ },
246
+ font: font,
247
+ color: {
248
+ type: 'color',
249
+ 'default': 'currentColor'
250
+ },
251
+ padding: {
252
+ type: 'number',
253
+ 'default': 1,
254
+ min: 0,
255
+ max: 100,
256
+ step: 0.5
257
+ }
258
+ },
259
+ sideNoteEnd: {
260
+ show: {
261
+ type: 'boolean',
262
+ 'default': false
263
+ },
264
+ text: {
265
+ type: 'text',
266
+ 'default': ''
267
+ },
268
+ position: {
269
+ type: 'choice',
270
+ 'default': 0,
271
+ values: [
272
+ {
273
+ name: 'in',
274
+ value: 0
275
+ }, {
276
+ name: 'out',
277
+ value: 1
278
+ }
279
+ ]
280
+ },
281
+ font: font,
282
+ color: {
283
+ type: 'color',
284
+ 'default': 'currentColor'
285
+ },
286
+ padding: {
287
+ type: 'number',
288
+ 'default': 1,
289
+ min: 0,
290
+ max: 100,
291
+ step: 0.5
292
+ }
223
293
  }
224
294
  }
225
295
  }
@@ -1 +1 @@
1
- !function(){var e;e={from:function(e){var l=this,n=function(e,t){var a,o;for(a in t.preset&&function(e,t){var a,o={}.hasOwnProperty;for(a in t)o.call(t,a)&&(e[a]=t[a])}(e,JSON.parse(JSON.stringify(l.preset[t.preset]))),t)o=t[a],"preset"!==a&&("string"==typeof o?e[a]=JSON.parse(JSON.stringify(l.preset[o]))||{}:n(e[a]||(e[a]={}),o));return e};return n({},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"}}},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"]},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}}}},"undefined"!=typeof chart&&null!==chart&&((chart.utils||(chart.utils={})).config=e)}.call(this);
1
+ !function(){var e;e={from:function(e){var l=this,n=function(e,t){var a,o;for(a in t.preset&&function(e,t){var a,o={}.hasOwnProperty;for(a in t)o.call(t,a)&&(e[a]=t[a])}(e,JSON.parse(JSON.stringify(l.preset[t.preset]))),t)o=t[a],"preset"!==a&&("string"==typeof o?e[a]=JSON.parse(JSON.stringify(l.preset[o]))||{}:n(e[a]||(e[a]={}),o));return e};return n({},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"}}},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"]},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);