@plotdb/chart 2.1.3 → 2.1.5

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,47 @@
1
1
  # Change Logs
2
2
 
3
+ ## v2.1.5
4
+
5
+ - support `position` and `enabled` option in `chart.utils.config.preset.legend`
6
+ - voronoi treemap:
7
+ - support default and legend options
8
+ - add additional options in voronoi treemap to prevent lagging
9
+ - bubble chart:
10
+ - use default font config
11
+ - tweak wedges colors
12
+ - line chart:
13
+ - tweak config
14
+ - reset revision
15
+ - rename various config in charts and utils
16
+ - `tick-count` to `tick.count`
17
+ - `tick-boundary-offset` to `tick.boundary-offset`
18
+ - `dot-size` to `dot.size`
19
+ - apply default config automatically when `config` is called.
20
+ - support multiple config object in `config` api calls
21
+
22
+
23
+ ## v2.1.4
24
+
25
+ - bug fix: line chart
26
+ - bug fix: in utils.legend: `_range` should be checked only if available
27
+ - bug fix: in utils.axis: offset vertical legend by -1
28
+ - upgrade modules for vulnerability fixing
29
+ - support `ranges` mode in tint util
30
+ - support exponential ticking
31
+ - support ranges ticking in taiwan map
32
+ - support additional configs in axis
33
+ - enable additional configs in bar chart
34
+ - bar chart:
35
+ - check element before dancing
36
+ - support legend toggling
37
+ - support exit animation
38
+ - set default options if they are available in base block
39
+ - sync chart text for font
40
+ - add default options in pie chart and percent list chart
41
+ - use `willReadFrequently` to speedup wordcloud canvas rendering
42
+ - bug fix: `force-init` boolean test should be `or` instead of `and` to make it work without other condition
43
+
44
+
3
45
  ## v2.1.3
4
46
 
5
47
  - wordcloud: support text-based color
package/index.js CHANGED
@@ -299,7 +299,7 @@
299
299
  });
300
300
  return p = Promise.resolve().then(function(){
301
301
  var defcfg, ret;
302
- defcfg = defaultConfig(this$.mod.config || {});
302
+ this$._defcfg = defcfg = defaultConfig(this$.mod.config || {});
303
303
  withDefault(this$.cfg, defcfg);
304
304
  if (this$.raw && Array.isArray(this$.raw)) {
305
305
  return;
@@ -339,7 +339,7 @@
339
339
  resizeObserver.add(this$.root, this$);
340
340
  return null;
341
341
  });
342
- if (this$.forceInit && !this$.root.offsetParent || window.getComputedStyle(this$.root).display === 'none') {
342
+ if (this$.forceInit || !this$.root.offsetParent || window.getComputedStyle(this$.root).display === 'none') {
343
343
  return;
344
344
  }
345
345
  this$._resize = function(){
@@ -495,11 +495,18 @@
495
495
  }
496
496
  });
497
497
  },
498
- config: function(opt){
499
- if (!(opt != null && opt)) {
498
+ config: function(){
499
+ var args, o, i$, to$, i;
500
+ if (!(args = arguments).length) {
500
501
  return this.cfg;
501
502
  }
502
- return import$(this.cfg, opt);
503
+ o = {};
504
+ for (i$ = 0, to$ = arguments.length; i$ < to$; ++i$) {
505
+ i = i$;
506
+ withDefault(o, arguments[i]);
507
+ }
508
+ withDefault(o, this._defcfg);
509
+ return import$(this.cfg, o);
503
510
  },
504
511
  setBind: function(n, b){
505
512
  this.binding[n] = b;
package/index.min.js CHANGED
@@ -1 +1 @@
1
- !function(){var n,i,o,s,u,a,t;function l(t,e){var n,r={}.hasOwnProperty;for(n in e)r.call(e,n)&&(t[n]=e[n]);return t}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=l(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){return null==e&&(e={}),function(t,e){var n,r;for(n in e)r=e[n],null==t[n]?t[n]=r:"object"==typeof t[n]&&"object"==typeof r&&u(t[n],e[n]);return t}(t=null==t?{}:t,e=JSON.parse(JSON.stringify(e)))},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.raw=t.raw||null,this.mod=t.mod||{},this.cfg=t.config||{},this.seed=t.seed||Math.random(),this.binding=t.binding||{},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=l(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=a(r.mod.config||{});if(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=l({},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 s=this;if(this.data=this.raw.map(function(i,t){var n,r,o={};return function(){var t,e=[];for(n in t=this.binding)r=t[n],e.push({k:n,v:r});return e}.call(s).map(function(t){var e,n=t.k,r=t.v;if(r)return o[n]=((t=(e=s.mod).dimension||(e.dimension={}))[n]||(t[n]={})).multiple?(r.map?r:[r]).map(function(t){return i[t.key]}):i[r.key],t=((t=(e=s.mod).dimension||(e.dimension={}))[n]||(t[n]={})).type,/[RIT]/.exec(t)&&!/[CN]/.exec(t)?o[n]=Array.isArray(o[n])?o[n].map(function(t){return parseFloat(t)}):parseFloat(o[n]):void 0}),o._raw=i,o._idx=t,o}),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(t){return null!=t&&t?l(this.cfg,t):this.cfg},setBind:function(t,e){return this.binding[t]=e,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.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 n,i,o,s,u,a,t;function l(t,e){var n,r={}.hasOwnProperty;for(n in e)r.call(e,n)&&(t[n]=e[n]);return t}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=l(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){return null==e&&(e={}),function(t,e){var n,r;for(n in e)r=e[n],null==t[n]?t[n]=r:"object"==typeof t[n]&&"object"==typeof r&&u(t[n],e[n]);return t}(t=null==t?{}:t,e=JSON.parse(JSON.stringify(e)))},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.raw=t.raw||null,this.mod=t.mod||{},this.cfg=t.config||{},this.seed=t.seed||Math.random(),this.binding=t.binding||{},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=l(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=l({},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 s=this;if(this.data=this.raw.map(function(i,t){var n,r,o={};return function(){var t,e=[];for(n in t=this.binding)r=t[n],e.push({k:n,v:r});return e}.call(s).map(function(t){var e,n=t.k,r=t.v;if(r)return o[n]=((t=(e=s.mod).dimension||(e.dimension={}))[n]||(t[n]={})).multiple?(r.map?r:[r]).map(function(t){return i[t.key]}):i[r.key],t=((t=(e=s.mod).dimension||(e.dimension={}))[n]||(t[n]={})).type,/[RIT]/.exec(t)&&!/[CN]/.exec(t)?o[n]=Array.isArray(o[n])?o[n].map(function(t){return parseFloat(t)}):parseFloat(o[n]):void 0}),o._raw=i,o._idx=t,o}),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]);return u(t,this._defcfg),l(this.cfg,t)},setBind:function(t,e){return this.binding[t]=e,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.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.3","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"},"devDependencies":{"@loadingio/bootstrap.ext":"^0.0.9","@loadingio/ldquery":"^3.0.4","@loadingio/loading.css":"^3.1.0","@loadingio/vscroll":"^0.0.8","@plotdb/layout":"^0.0.12","@plotdb/pdmap-world":"^0.0.5","@plotdb/semver":"^0.0.3","@plotdb/sheet":"^0.2.0","@zbryikt/template":"^2.3.38","bootstrap":"^4.6.1","bootstrap.native":"^3.0.15","fedep":"^1.1.7","ldiconfont":"^0.2.3","ldbutton":"^2.0.1","ldloader":"^3.0.1","ldview":"^1.2.1","livescript":"^1.6.0","pdmaptw":"2.1.0","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","@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","ldslider","wrap-svg-text","ldpalettepicker","zmgr","ldview"]},"dependencies":{"@loadingio/debounce.js":"^1.0.1","@loadingio/ldcolorpicker":"^3.0.0","@plotdb/block":"^4.6.1","@plotdb/csscope":"^4.0.6","@plotdb/konfig":"^4.2.7","@plotdb/rescope":"^4.1.6","@zbryikt/voronoijs":"^1.0.0","d3":"^4.13.0","d3-array":"^3.1.1","d3-axis":"^3.0.0","d3-brush":"^3.0.0","d3-color":"^3.0.1","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","choosefont.js":"^0.0.1","ldcolor":"^1.0.0","ldcover":"^3.2.1","ldpalettepicker":"^4.0.1","ldslider":"^3.0.4","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.5","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"},"devDependencies":{"@loadingio/bootstrap.ext":"^0.0.9","@loadingio/ldquery":"^3.0.4","@loadingio/loading.css":"^3.1.0","@loadingio/vscroll":"^0.0.8","@plotdb/layout":"^0.0.12","@plotdb/pdmap-world":"^0.0.5","@plotdb/semver":"^0.0.3","@plotdb/sheet":"^0.2.0","@xlfont/choose":"^0.0.13","@xlfont/load":"^2.1.0","@zbryikt/template":"^2.3.38","bootstrap":"^4.6.1","bootstrap.native":"^3.0.15","fedep":"^1.1.7","ldbutton":"^2.0.1","ldfile":"^2.0.0","ldiconfont":"^0.2.3","ldloader":"^3.0.1","ldview":"^1.2.1","livescript":"^1.6.0","pdmaptw":"2.1.0","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.0","@plotdb/block":"^4.6.1","@plotdb/csscope":"^4.0.6","@plotdb/konfig":"^4.2.7","@plotdb/rescope":"^4.1.6","@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.0.0","ldcover":"^3.2.1","ldpalettepicker":"^4.0.1","ldslider":"^3.1.1","proxise":"^1.0.1","wrap-svg-text":"^0.0.7"}}
package/utils/axis.js CHANGED
@@ -18,14 +18,8 @@
18
18
  this._scale = opt.scale || function(it){
19
19
  return it;
20
20
  };
21
- this._format = opt.format || (typeof chart != 'undefined' && chart !== null
22
- ? chart.utils.format.simple
23
- : function(it){
24
- return it;
25
- });
26
- this.cfg = import$({
27
- tickSize: 8
28
- }, opt.cfg);
21
+ this._format = chart.utils.format.simple;
22
+ this._config(opt.cfg);
29
23
  this._map = {};
30
24
  this._n = n = {
31
25
  root: ceNS('g'),
@@ -71,22 +65,41 @@
71
65
  });
72
66
  return n.layout.appendChild(n.wrap);
73
67
  },
74
- config: function(it){
75
- if (!(it != null)) {
68
+ _config: function(c){
69
+ var ref$, this$ = this;
70
+ c == null && (c = {});
71
+ this.cfg = {
72
+ tick: {
73
+ inner: 8
74
+ },
75
+ baseline: {},
76
+ label: {
77
+ padding: 1
78
+ },
79
+ caption: {},
80
+ enabled: c.enabled
81
+ };
82
+ ['tick', 'baseline', 'label', 'caption'].map(function(n){
83
+ return import$(this$.cfg[n], c[n] || {});
84
+ });
85
+ (ref$ = this.cfg.label).font || (ref$.font = {});
86
+ (ref$ = this.cfg.caption).font || (ref$.font = {});
87
+ return this.format(this.cfg.label.format);
88
+ },
89
+ config: function(c){
90
+ if (!(c != null)) {
76
91
  return this.cfg;
77
92
  }
78
- import$(this.cfg, it);
79
- if (this.cfg.format) {
80
- this.format(this.cfg.format);
81
- }
93
+ this._config(c);
82
94
  return this.wrapper();
83
95
  },
84
- format: function(it){
85
- if (it != null) {
86
- return this._format = it;
87
- } else {
96
+ format: function(f){
97
+ if (!(f != null)) {
88
98
  return this._format;
89
99
  }
100
+ return this._format = typeof f === 'string'
101
+ ? chart.utils.format.from(f)
102
+ : f || chart.utils.format.simple;
90
103
  },
91
104
  scale: function(it){
92
105
  if (it != null) {
@@ -96,10 +109,13 @@
96
109
  }
97
110
  },
98
111
  caption: function(it){
99
- if (this.cfg.showCaption != null && !this.cfg.showCaption) {
112
+ if (arguments.length) {
113
+ this._caption = it;
114
+ }
115
+ if (this.cfg.caption.show != null && !this.cfg.caption.show) {
100
116
  return this._n.label.textContent = '';
101
117
  } else {
102
- return this._n.label.textContent = it;
118
+ return this._n.label.textContent = this.cfg.caption.text || this._caption || '';
103
119
  }
104
120
  },
105
121
  update: function(){},
@@ -149,6 +165,8 @@
149
165
  n = this._n;
150
166
  isHorizon = this.dir < 2;
151
167
  wrap = n.wrap;
168
+ wrap.style.fontSize = this.cfg.label.font.size ? this.cfg.label.font.size + "px" || '' : void 8;
169
+ wrap.setAttribute('class', (this.cfg.label.font || {}).className || '');
152
170
  ticks = this._ticks;
153
171
  if (this.cfg.enabled != null && !this.cfg.enabled) {
154
172
  if (isHorizon) {
@@ -213,12 +231,15 @@
213
231
  node: wrap
214
232
  });
215
233
  o.n.t.style.fontSize = fontSize;
234
+ o.n.t.style.fill = this$.cfg.label.color;
216
235
  o.n.t.textContent = '';
217
- return o.n.t.appendChild(o.n.tt);
236
+ o.n.t.appendChild(o.n.tt);
237
+ return o.n.t.setAttribute('class', (this$.cfg.label.font || {}).className || '');
218
238
  });
219
239
  ticks.sort(function(a, b){
220
240
  return a._c - b._c;
221
241
  });
242
+ n.domain.style.stroke = this.cfg.baseline.show ? this.cfg.baseline.color : 'none';
222
243
  if (isHorizon) {
223
244
  n.domain.setAttribute('d', "M0 0L" + box.width + " 0Z");
224
245
  n.label.setAttribute('x', box.width / 2);
@@ -254,8 +275,8 @@
254
275
  };
255
276
  doOffset = this$._scale.bandwidth
256
277
  ? false
257
- : this$.cfg.boundaryTickOffset != null
258
- ? !!this$.cfg.boundaryTickOffset
278
+ : this$.cfg.tick.boundaryOffset != null
279
+ ? !!this$.cfg.tick.boundaryOffset
259
280
  : this$.dir < 2 ? true : false;
260
281
  r = doOffset
261
282
  ? pos / 2
@@ -276,12 +297,12 @@
276
297
  box.coord = coord - box.size * r;
277
298
  if (isHorizon) {
278
299
  tick.n.g.setAttribute('transform', "translate(" + coord + ",0)");
279
- tick.n.p.setAttribute('d', "M0 0L0 " + this$.cfg.tickSize);
280
- tick.n.t.setAttribute('transform', "translate(0," + this$.cfg.tickSize + ")");
300
+ tick.n.p.setAttribute('d', "M0 0L0 " + this$.cfg.tick.inner);
301
+ tick.n.t.setAttribute('transform', "translate(0," + (this$.cfg.tick.inner + this$.cfg.label.padding) + ")");
281
302
  } else {
282
303
  tick.n.g.setAttribute('transform', "translate(0," + coord + ")");
283
- tick.n.p.setAttribute('d', "M0 0L-" + this$.cfg.tickSize + " 0");
284
- tick.n.t.setAttribute('transform', "translate(" + (-this$.cfg.tickSize - box.sizeAlt - 1) + ",0)");
304
+ tick.n.p.setAttribute('d', "M0 0L-" + this$.cfg.tick.inner + " 0");
305
+ tick.n.t.setAttribute('transform', "translate(" + (-this$.cfg.tick.inner - box.sizeAlt - 1 - this$.cfg.label.padding) + ",0)");
285
306
  }
286
307
  m = 2;
287
308
  ref$ = [box.coord, box.coord + box.size], ip1 = ref$[0], ip2 = ref$[1];
@@ -293,11 +314,12 @@
293
314
  return (ip1 > oq1 && ip1 < oq2) || (iq1 > op1 && iq1 < op2);
294
315
  }).length;
295
316
  tick.n.t.style.opacity = overlap ? 0 : 1;
317
+ tick.n.p.style.stroke = this$.cfg.tick.color || '';
296
318
  lc.picked.push(box);
297
319
  return !overlap;
298
320
  };
299
321
  bfs = function(maxlv){
300
- var ref$, lc, fifo, L, R, D, M, size, box;
322
+ var ref$, lc, fifo, L, R, D, M, size, delta, box;
301
323
  maxlv == null && (maxlv = 1);
302
324
  ref$ = [
303
325
  {
@@ -334,19 +356,24 @@
334
356
  lc.picked.map -> if it.lv >= maxlv => it.tick.n.t.style.opacity = 0
335
357
  lc.picked = lc.picked.filter -> it.lv < maxlv
336
358
  */
359
+ this$._n.label.style.fill = this$.cfg.caption.color;
360
+ this$._n.label.style.fontSize = this$.cfg.caption.size;
361
+ this$._n.label.setAttribute('class', (this$.cfg.caption.font || {}).className || '');
362
+ this$.caption();
337
363
  size = Math.max.apply(Math, [0].concat(lc.picked.map(function(it){
338
364
  return it.sizeAlt;
339
365
  })));
366
+ delta = this$.cfg.tick.inner + this$.cfg.label.padding + size;
340
367
  if (this$.dir < 2) {
341
- this$._n.label.setAttribute('y', size + this$.cfg.tickSize);
342
- return this$._n.layout.style.height = (size + this$.cfg.tickSize + this$._n.label.getBoundingClientRect().height) + "px";
368
+ this$._n.label.setAttribute('y', delta);
369
+ return this$._n.layout.style.height = (delta + this$._n.label.getBoundingClientRect().height) + "px";
343
370
  } else {
344
371
  this$._n.label.setAttribute('x', 0);
345
372
  this$._n.label.setAttribute('y', 0);
346
- this$._n.layout.style.width = (size + this$.cfg.tickSize + this$._n.label.getBoundingClientRect().width) + "px";
373
+ this$._n.layout.style.width = (delta + this$._n.label.getBoundingClientRect().width) + "px";
347
374
  box = this$._n.layout.getBoundingClientRect();
348
- this$._n.label.setAttribute('transform', "translate(" + (-(size + this$.cfg.tickSize)) + "," + box.height / 2 + ") rotate(90)");
349
- return this$._n.root.setAttribute('transform', "translate(" + box.width + ",0)");
375
+ this$._n.label.setAttribute('transform', "translate(" + (-delta) + "," + box.height / 2 + ") rotate(90)");
376
+ return this$._n.root.setAttribute('transform', "translate(" + (box.width - 1) + ",0)");
350
377
  }
351
378
  };
352
379
  return bfs(5);
package/utils/axis.min.js CHANGED
@@ -1 +1 @@
1
- !function(){var s,t;function h(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=t.format||("undefined"!=typeof chart&&null!==chart?chart.utils.format.simple:function(t){return t}),this.cfg=h({tickSize:8},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=h(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"),h(((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(t){return null==t?this.cfg:(h(this.cfg,t),this.cfg.format&&this.format(this.cfg.format),this.wrapper())},format:function(t){return null!=t?this._format=t:this._format},scale:function(t){return null!=t?this._scale=t:this._scale},caption:function(t){return null==this.cfg.showCaption||this.cfg.showCaption?this._n.label.textContent=t:this._n.label.textContent=""},update:function(){},ticks:function(n){var t,e,i,r=this,a={},o=this._n.layout.getBoundingClientRect()[this.dir<2?"width":"height"],o=Math.round(o/25),l=1<(t=Math.round(n.length/(1<o?o: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 a[(t="object"!=typeof t?{v:t}:t).v]=h((e=r._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:s("g"),p:s("path"),t:s("g")},t.n.g.appendChild(t.n.p),t.n.g.appendChild(t.n.t),r._n.root.appendChild(t.n.g),isNaN(+t.v))return t.t=t.v})},render:function(){var t,i,e,r=this,n=this._n,a=this.dir<2,o=n.wrap,l=this._ticks;return null==this.cfg.enabled||this.cfg.enabled?(a?((t=n.layout.style).height="",t.paddingTop="",t.paddingBottom=""):((t=n.layout.style).width="",t.paddingLeft="",t.paddingRight=""),n.domain.style.display="",l.map(function(t){return t.n.g.style.display=""}),i=getComputedStyle(o).fontSize,e=n.layout.getBoundingClientRect(),(t=n.domain.style).strokeWidth=1,t.stroke="currentColor",t.fill="none",l.map(function(t,e){var n=e?e===l.length-1?2:1:0;return t._c=null!=t.c?t.c:r._scale(t.v)+(r._scale.bandwidth?r._scale.bandwidth()/2:0),t._t=null!=t.t?t.t:r._format(t.v),(e=t.n.p.style).strokeWidth=1,e.stroke="currentColor",e.fill="none",o.textContent=t._t,o.style.textAlign=a?["left","center","right"][n]:["right","left"][r.dir-2],t.n.tt=wrapSvgText({node:o}),t.n.t.style.fontSize=i,t.n.t.textContent="",t.n.t.appendChild(t.n.tt)}),l.sort(function(t,e){return t._c-e._c}),a?(n.domain.setAttribute("d","M0 0L"+e.width+" 0Z"),n.label.setAttribute("x",e.width/2)):(n.domain.setAttribute("d","M0 0L0 "+e.height+"Z"),n.label.setAttribute("transform","translate(0,"+e.height/2+") rotate(90)")),l.map(function(t){return t.box=t.n.t.getBBox()}),this.adjust()):(a?((t=n.layout.style).height="0px",t.paddingTop="0",t.paddingBottom="0"):((t=n.layout.style).width="0px",t.paddingLeft="0",t.paddingRight="0"),n.domain.style.display="none",void l.map(function(t){return t.n.g.style.display="none"}))},adjust:function(){var c=this,d=this._ticks,p=this.dir<2,u=function(t,e,n){var i,r,a,o,l,s,h,u;if(!n.checked[t])return n.checked[t]=!0,i=d[t],o=t?t===d.length-1?2:1:0,u=[i._c,i._t][0],a={x:-(r=i.box).x,y:-r.y},o=!c._scale.bandwidth&&(null!=c.cfg.boundaryTickOffset?!!c.cfg.boundaryTickOffset:c.dir<2)?o/2:.5,p?a.x-=r.width*o:a.y-=r.height*o,i.n.tt.setAttribute("transform","translate("+a.x+","+a.y+")"),(r={size:r[p?"width":"height"],sizeAlt:r[p?"height":"width"],lv:e,tick:i,idx:t}).coord=u-r.size*o,p?(i.n.g.setAttribute("transform","translate("+u+",0)"),i.n.p.setAttribute("d","M0 0L0 "+c.cfg.tickSize),i.n.t.setAttribute("transform","translate(0,"+c.cfg.tickSize+")")):(i.n.g.setAttribute("transform","translate(0,"+u+")"),i.n.p.setAttribute("d","M0 0L-"+c.cfg.tickSize+" 0"),i.n.t.setAttribute("transform","translate("+(-c.cfg.tickSize-r.sizeAlt-1)+",0)")),u=[r.coord,r.coord+r.size],s=(u=[(l=u[0])-2,u[1]+2])[0],h=u[1],u=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<h}).length,i.n.t.style.opacity=u?0:1,n.picked.push(r),!u};return function(t){var e,n,i,r,a,o,l,s,h;for(null==t&&(t=1),e=[{checked:{},picked:[],node:c._n.wrap},[]],n=e[0],i=e[1],n.fontSize=getComputedStyle(n.node).fontSize,d.map(function(t){return t.n.t.style.opacity=0}),d.length&&(i.push([0,d.length-1,0]),[0,d.length-1].map(function(t){return u(t,0,n)}));i.length;)r=(e=i.splice(0,1)[0])[0],a=e[1],t<=(o=e[2])||(l=Math.floor((r+a)/2),u(l,o,n),r+1<l&&i.push([r,l,o+1]),l+1<a&&i.push([l,a,o+1]));return s=Math.max.apply(Math,[0].concat(n.picked.map(function(t){return t.sizeAlt}))),c.dir<2?(c._n.label.setAttribute("y",s+c.cfg.tickSize),c._n.layout.style.height=s+c.cfg.tickSize+c._n.label.getBoundingClientRect().height+"px"):(c._n.label.setAttribute("x",0),c._n.label.setAttribute("y",0),c._n.layout.style.width=s+c.cfg.tickSize+c._n.label.getBoundingClientRect().width+"px",h=c._n.layout.getBoundingClientRect(),c._n.label.setAttribute("transform","translate("+-(s+c.cfg.tickSize)+","+h.height/2+") rotate(90)"),c._n.root.setAttribute("transform","translate("+h.width+",0)"))}(5)}}),"undefined"!=typeof chart&&null!==chart&&((chart.utils||(chart.utils={})).axis=t)}.call(this);
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:{},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),null==this.cfg.caption.show||this.cfg.caption.show?this._n.label.textContent=this.cfg.caption.text||this._caption||"":this._n.label.textContent=""},update:function(){},ticks:function(n){var t,e,i,a=this,r={},l=this._n.layout.getBoundingClientRect()[this.dir<2?"width":"height"],l=Math.round(l/25),o=1<(t=Math.round(n.length/(1<l?l:1)))?t:1;for(e in this._ticks=n.filter(function(t,e){return!(e%o)||e===n.length-1}).map(function(t){var e,n;return r[(t="object"!=typeof t?{v:t}:t).v]=c((e=a._map)[n=t.v]||(e[n]={}),t)}),t=this._map)i=t[e],r[e]||i.n.g.parentNode.removeChild(i.n.g);return this._map=r,this._ticks.filter(function(t){return!t.n}).map(function(t){if(t.n={g: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,r=this,n=this._n,l=this.dir<2,o=n.wrap;return o.style.fontSize=this.cfg.label.font.size?this.cfg.label.font.size+"px"||"":void 0,o.setAttribute("class",(this.cfg.label.font||{}).className||""),i=this._ticks,null==this.cfg.enabled||this.cfg.enabled?(l?((t=n.layout.style).height="",t.paddingTop="",t.paddingBottom=""):((t=n.layout.style).width="",t.paddingLeft="",t.paddingRight=""),n.domain.style.display="",i.map(function(t){return t.n.g.style.display=""}),a=getComputedStyle(o).fontSize,e=n.layout.getBoundingClientRect(),(t=n.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:r._scale(t.v)+(r._scale.bandwidth?r._scale.bandwidth()/2:0),t._t=null!=t.t?t.t:r._format(t.v),(e=t.n.p.style).strokeWidth=1,e.stroke="currentColor",e.fill="none",o.textContent=t._t,o.style.textAlign=l?["left","center","right"][n]:["right","left"][r.dir-2],t.n.tt=wrapSvgText({node:o}),t.n.t.style.fontSize=a,t.n.t.style.fill=r.cfg.label.color,t.n.t.textContent="",t.n.t.appendChild(t.n.tt),t.n.t.setAttribute("class",(r.cfg.label.font||{}).className||"")}),i.sort(function(t,e){return t._c-e._c}),n.domain.style.stroke=this.cfg.baseline.show?this.cfg.baseline.color:"none",l?(n.domain.setAttribute("d","M0 0L"+e.width+" 0Z"),n.label.setAttribute("x",e.width/2)):(n.domain.setAttribute("d","M0 0L0 "+e.height+"Z"),n.label.setAttribute("transform","translate(0,"+e.height/2+") rotate(90)")),i.map(function(t){return t.box=t.n.t.getBBox()}),this.adjust()):(l?((t=n.layout.style).height="0px",t.paddingTop="0",t.paddingBottom="0"):((t=n.layout.style).width="0px",t.paddingLeft="0",t.paddingRight="0"),n.domain.style.display="none",void i.map(function(t){return t.n.g.style.display="none"}))},adjust:function(){var d=this,u=this._ticks,f=this.dir<2,h=function(t,e,n){var i,a,r,l,o,s,c,h;if(!n.checked[t])return n.checked[t]=!0,i=u[t],l=t?t===u.length-1?2:1:0,h=[i._c,i._t][0],r={x:-(a=i.box).x,y:-a.y},l=!d._scale.bandwidth&&(null!=d.cfg.tick.boundaryOffset?!!d.cfg.tick.boundaryOffset:d.dir<2)?l/2:.5,f?r.x-=a.width*l:r.y-=a.height*l,i.n.tt.setAttribute("transform","translate("+r.x+","+r.y+")"),(a={size:a[f?"width":"height"],sizeAlt:a[f?"height":"width"],lv:e,tick:i,idx:t}).coord=h-a.size*l,f?(i.n.g.setAttribute("transform","translate("+h+",0)"),i.n.p.setAttribute("d","M0 0L0 "+d.cfg.tick.inner),i.n.t.setAttribute("transform","translate(0,"+(d.cfg.tick.inner+d.cfg.label.padding)+")")):(i.n.g.setAttribute("transform","translate(0,"+h+")"),i.n.p.setAttribute("d","M0 0L-"+d.cfg.tick.inner+" 0"),i.n.t.setAttribute("transform","translate("+(-d.cfg.tick.inner-a.sizeAlt-1-d.cfg.label.padding)+",0)")),h=[a.coord,a.coord+a.size],s=(h=[(o=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]<o&&o<e[1]||s<t&&t<c}).length,i.n.t.style.opacity=h?0:1,i.n.p.style.stroke=d.cfg.tick.color||"",n.picked.push(a),!h};return function(t){var e,n,i,a,r,l,o,s,c;for(null==t&&(t=1),e=[{checked:{},picked:[],node:d._n.wrap},[]],n=e[0],i=e[1],n.fontSize=getComputedStyle(n.node).fontSize,u.map(function(t){return t.n.t.style.opacity=0}),u.length&&(i.push([0,u.length-1,0]),[0,u.length-1].map(function(t){return h(t,0,n)}));i.length;)a=(e=i.splice(0,1)[0])[0],r=e[1],t<=(l=e[2])||(o=Math.floor((a+r)/2),h(o,l,n),a+1<o&&i.push([a,o,l+1]),o+1<r&&i.push([o,r,l+1]));return d._n.label.style.fill=d.cfg.caption.color,d._n.label.style.fontSize=d.cfg.caption.size,d._n.label.setAttribute("class",(d.cfg.caption.font||{}).className||""),d.caption(),c=Math.max.apply(Math,[0].concat(n.picked.map(function(t){return t.sizeAlt}))),s=d.cfg.tick.inner+d.cfg.label.padding+c,d.dir<2?(d._n.label.setAttribute("y",s),d._n.layout.style.height=s+d._n.label.getBoundingClientRect().height+"px"):(d._n.label.setAttribute("x",0),d._n.label.setAttribute("y",0),d._n.layout.style.width=s+d._n.label.getBoundingClientRect().width+"px",c=d._n.layout.getBoundingClientRect(),d._n.label.setAttribute("transform","translate("+-s+","+c.height/2+") rotate(90)"),d._n.root.setAttribute("transform","translate("+(c.width-1)+",0)"))}(5)}}),"undefined"!=typeof chart&&null!==chart&&((chart.utils||(chart.utils={})).axis=t)}.call(this);
package/utils/config.js CHANGED
@@ -1,34 +1,137 @@
1
1
  (function(){
2
- var config;
2
+ var font, config;
3
+ font = {
4
+ family: {
5
+ type: 'font'
6
+ },
7
+ size: {
8
+ type: 'quantity',
9
+ 'default': '1em',
10
+ units: [
11
+ {
12
+ name: 'em',
13
+ max: 10,
14
+ step: 0.01,
15
+ 'default': 1
16
+ }, {
17
+ name: 'px',
18
+ max: 256,
19
+ step: 1,
20
+ 'default': 16
21
+ }
22
+ ]
23
+ }
24
+ };
3
25
  config = {
4
26
  preset: {
5
27
  'default': {
6
28
  margin: {
7
29
  type: 'number'
8
30
  },
9
- font: {
10
- size: {
11
- type: 'number',
12
- min: 1,
13
- max: 256,
14
- step: 1,
15
- 'default': 16
16
- }
17
- },
31
+ font: font,
18
32
  color: {
19
- type: 'color'
33
+ type: 'color',
34
+ 'default': 'currentColor'
20
35
  },
21
36
  palette: {
22
37
  type: 'palette'
23
38
  },
24
39
  background: {
25
- type: 'color'
40
+ type: 'color',
41
+ 'default': 'transparent'
26
42
  }
27
43
  },
28
44
  legend: {
29
45
  selectable: {
30
46
  type: 'boolean',
31
47
  'default': true
48
+ },
49
+ enabled: {
50
+ type: 'boolean',
51
+ 'default': true
52
+ },
53
+ position: {
54
+ type: 'choice',
55
+ values: ['bottom', 'right'],
56
+ 'default': 'right'
57
+ }
58
+ },
59
+ axis: {
60
+ enabled: {
61
+ type: 'boolean',
62
+ 'default': true
63
+ },
64
+ tick: {
65
+ inner: {
66
+ type: 'number',
67
+ name: "Inner Tick Size",
68
+ 'default': 8,
69
+ min: 0,
70
+ max: 40,
71
+ step: 0.1
72
+ },
73
+ color: {
74
+ type: 'color',
75
+ 'default': 'currentColor'
76
+ },
77
+ count: {
78
+ type: 'number',
79
+ 'default': 4,
80
+ min: 1,
81
+ max: 40
82
+ },
83
+ boundaryOffset: {
84
+ type: 'boolean',
85
+ 'default': true
86
+ }
87
+ },
88
+ baseline: {
89
+ show: {
90
+ type: 'boolean',
91
+ 'default': true
92
+ },
93
+ color: {
94
+ type: 'color',
95
+ 'default': 'currentColor'
96
+ }
97
+ },
98
+ label: {
99
+ color: {
100
+ type: 'color',
101
+ 'default': 'currentColor'
102
+ },
103
+ format: {
104
+ type: 'text',
105
+ 'default': '.3s'
106
+ },
107
+ direction: {
108
+ type: 'choice',
109
+ 'default': 'horizontal',
110
+ values: ['horizontal', 'vertical']
111
+ },
112
+ padding: {
113
+ type: 'number',
114
+ 'default': 1,
115
+ min: 0,
116
+ max: 10,
117
+ step: 0.1
118
+ },
119
+ font: font
120
+ },
121
+ caption: {
122
+ color: {
123
+ type: 'color',
124
+ 'default': 'currentColor'
125
+ },
126
+ text: {
127
+ type: 'text',
128
+ 'default': ''
129
+ },
130
+ show: {
131
+ type: 'boolean',
132
+ 'default': true
133
+ },
134
+ font: font
32
135
  }
33
136
  }
34
137
  }
@@ -1 +1 @@
1
- !function(){var e={preset:{default:{margin:{type:"number"},font:{size:{type:"number",min:1,max:256,step:1,default:16}},color:{type:"color"},palette:{type:"palette"},background:{type:"color"}},legend:{selectable:{type:"boolean",default:!0}}}};"undefined"!=typeof chart&&null!==chart&&((chart.utils||(chart.utils={})).config=e)}.call(this);
1
+ !function(){var 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}]}},e={preset:{default:{margin:{type:"number"},font:e,color:{type:"color",default:"currentColor"},palette:{type:"palette"},background:{type:"color",default:"transparent"}},legend:{selectable:{type:"boolean",default:!0},enabled:{type:"boolean",default:!0},position:{type:"choice",values:["bottom","right"],default:"right"}},axis:{enabled:{type:"boolean",default:!0},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:"text",default:".3s"},direction:{type:"choice",default:"horizontal",values:["horizontal","vertical"]},padding:{type:"number",default:1,min:0,max:10,step:.1},font:e},caption:{color:{type:"color",default:"currentColor"},text:{type:"text",default:""},show:{type:"boolean",default:!0},font:e}}}};"undefined"!=typeof chart&&null!==chart&&((chart.utils||(chart.utils={})).config=e)}.call(this);
package/utils/format.js CHANGED
@@ -1,68 +1,80 @@
1
1
  (function(){
2
2
  var format;
3
- format = {};
4
- format.auto = function(list){
5
- var s, intRate, diffs, i, diffAvg, type, size;
6
- list == null && (list = []);
7
- return d3.format(".3s");
8
- list = list.map(function(it){
9
- return +it;
10
- }).filter(function(it){
11
- return !isNaN(it);
12
- });
13
- if (!list.length) {
14
- return d3.format("d");
15
- }
16
- list.sort(function(a, b){
17
- return a - b;
18
- });
19
- s = Math.max.apply(Math, list.map(function(it){
20
- var s, ref$;
21
- s = 1;
22
- while (it) {
23
- if (it % 10) {
24
- break;
25
- }
26
- it = Math.floor(it / 10);
27
- s++;
3
+ format = {
4
+ from: function(s){
5
+ var e;
6
+ try {
7
+ return d3.format(s);
8
+ } catch (e$) {
9
+ e = e$;
10
+ return function(it){
11
+ return it;
12
+ };
28
13
  }
29
- return (ref$ = Math.ceil(Math.log(it || 1) / Math.log(10) - s)) > 0 ? ref$ : 0;
30
- }));
31
- intRate = list.filter(function(it){
32
- return Math.floor(it) === it;
33
- }).length / list.length;
34
- diffs = (function(){
35
- var i$, to$, results$ = [];
36
- for (i$ = 1, to$ = list.length; i$ < to$; ++i$) {
37
- i = i$;
38
- results$.push(Math.abs(list[i] - list[i - 1]));
14
+ },
15
+ auto: function(list){
16
+ var s, intRate, diffs, i, diffAvg, type, size;
17
+ list == null && (list = []);
18
+ return d3.format(".3s");
19
+ list = list.map(function(it){
20
+ return +it;
21
+ }).filter(function(it){
22
+ return !isNaN(it);
23
+ });
24
+ if (!list.length) {
25
+ return d3.format("d");
39
26
  }
40
- return results$;
41
- }()).map(function(it){
42
- return Math.log(it ? it : 1) / Math.log(10);
43
- });
44
- diffAvg = diffs.reduce(function(a, b){
45
- return a + b;
46
- }, 0) / list.length;
47
- type = intRate > 0.9 ? "s" : "f";
48
- size = diffAvg >= 0
49
- ? s > 0 ? s : 0
50
- : Math.ceil(Math.abs(diffAvg));
51
- return d3.format("." + size + type);
52
- };
53
- format.simple = function(v){
54
- if (isNaN(v = +v)) {
55
- return v;
27
+ list.sort(function(a, b){
28
+ return a - b;
29
+ });
30
+ s = Math.max.apply(Math, list.map(function(it){
31
+ var s, ref$;
32
+ s = 1;
33
+ while (it) {
34
+ if (it % 10) {
35
+ break;
36
+ }
37
+ it = Math.floor(it / 10);
38
+ s++;
39
+ }
40
+ return (ref$ = Math.ceil(Math.log(it || 1) / Math.log(10) - s)) > 0 ? ref$ : 0;
41
+ }));
42
+ intRate = list.filter(function(it){
43
+ return Math.floor(it) === it;
44
+ }).length / list.length;
45
+ diffs = (function(){
46
+ var i$, to$, results$ = [];
47
+ for (i$ = 1, to$ = list.length; i$ < to$; ++i$) {
48
+ i = i$;
49
+ results$.push(Math.abs(list[i] - list[i - 1]));
50
+ }
51
+ return results$;
52
+ }()).map(function(it){
53
+ return Math.log(it ? it : 1) / Math.log(10);
54
+ });
55
+ diffAvg = diffs.reduce(function(a, b){
56
+ return a + b;
57
+ }, 0) / list.length;
58
+ type = intRate > 0.9 ? "s" : "f";
59
+ size = diffAvg >= 0
60
+ ? s > 0 ? s : 0
61
+ : Math.ceil(Math.abs(diffAvg));
62
+ return d3.format("." + size + type);
63
+ },
64
+ simple: function(v){
65
+ if (isNaN(v = +v)) {
66
+ return v;
67
+ }
68
+ return v >= 1000000000
69
+ ? (v / 1000000000).toFixed(0) + "G"
70
+ : v >= 1000000
71
+ ? (v / 1000000).toFixed(0) + "M"
72
+ : v >= 1000
73
+ ? (v / 1000).toFixed(0) + "K"
74
+ : Math.floor(v) === v
75
+ ? v.toFixed(0)
76
+ : v.toFixed(2);
56
77
  }
57
- return v >= 1000000000
58
- ? (v / 1000000000).toFixed(0) + "G"
59
- : v >= 1000000
60
- ? (v / 1000000).toFixed(0) + "M"
61
- : v >= 1000
62
- ? (v / 1000).toFixed(0) + "K"
63
- : Math.floor(v) === v
64
- ? v.toFixed(0)
65
- : v.toFixed(2);
66
78
  };
67
79
  if (typeof chart != 'undefined' && chart !== null) {
68
80
  (chart.utils || (chart.utils = {})).format = format;
@@ -1 +1 @@
1
- !function(){var t={auto:function(t){return null==t&&(t=[]),d3.format(".3s")},simple:function(t){return isNaN(t=+t)?t:1e9<=t?(t/1e9).toFixed(0)+"G":1e6<=t?(t/1e6).toFixed(0)+"M":1e3<=t?(t/1e3).toFixed(0)+"K":Math.floor(t)===t?t.toFixed(0):t.toFixed(2)}};"undefined"!=typeof chart&&null!==chart&&((chart.utils||(chart.utils={})).format=t)}.call(this);
1
+ !function(){var t={from:function(t){try{return d3.format(t)}catch(t){return function(t){return t}}},auto:function(t){return null==t&&(t=[]),d3.format(".3s")},simple:function(t){return isNaN(t=+t)?t:1e9<=t?(t/1e9).toFixed(0)+"G":1e6<=t?(t/1e6).toFixed(0)+"M":1e3<=t?(t/1e3).toFixed(0)+"K":Math.floor(t)===t?t.toFixed(0):t.toFixed(2)}};"undefined"!=typeof chart&&null!==chart&&((chart.utils||(chart.utils={})).format=t)}.call(this);
package/utils/legend.js CHANGED
@@ -236,6 +236,9 @@
236
236
  this._data = data.filter(function(d, i){
237
237
  return hash[d.key] === i;
238
238
  });
239
+ this._range = this._data.filter(function(it){
240
+ return it.ext;
241
+ });
239
242
  this._updatePicked();
240
243
  this.update();
241
244
  this.layout.update(false);
@@ -264,7 +267,13 @@
264
267
  return results$;
265
268
  },
266
269
  isSelected: function(key){
267
- return !!this._picked[key];
270
+ var this$ = this;
271
+ if (!(this._range && this._range.length)) {
272
+ return !!this._picked[key];
273
+ }
274
+ return !!this._range.filter(function(it){
275
+ return key >= it.ext[0] && key < it.ext[1] && this$._picked[it.key];
276
+ }).length;
268
277
  }
269
278
  });
270
279
  if (typeof chart != 'undefined' && chart !== null) {
@@ -1 +1 @@
1
- !function(){var d,e;d="http://www.w3.org/2000/svg",(e=function(a){var e,t,n,i,l=this;return null==a&&(a={}),this._data=a.data||[],this.name=a.name||"legend",this.cfg=a.cfg||{},this.root="string"==typeof a.root?document.querySelector(a.root):a.root,this.dir=a.direction||"vertical",this.evtHandler={},this._picked=Object.fromEntries(this._data.map(function(e){return[e.key,!0]})),this.layout=a.layout||new layout({root:this.root}),(n=this.layout).on("update",function(){return l.update()}),n.on("render",function(){return l.render()}),this.id=Math.random().toString(36).substring(2),i=this.layout.getNode(this.name),e=this.layout.getGroup(this.name),i.querySelector("[ld-each=legend]")||(i.innerHTML='<div class="pdlg '+this.dir+'">\n <div ld-each="legend">\n <div class="pdl-cell" ld="shape" data-only></div>\n <div class="pdl-cell" ld="text" data-only></div>\n </div>\n</div>'),e.querySelector("[ld-each=legend]")||(t=document.createElementNS(d,"g"),n=document.createElementNS(d,"g"),i=document.createElementNS(d,"g"),t.classList.add("pdlg-g"),t.setAttribute("ld-each","legend"),n.setAttribute("ld","shape"),i.setAttribute("ld","text"),t.appendChild(n),t.appendChild(i),e.appendChild(t)),this._func=[{key:"all",type:"func",text:"全選"},{key:"none",type:"func",text:"全不選"}],this.view={layout:new ldview({root:this.layout.getNode(this.name),initRender:!1,handler:{legend:{list:function(){return l._data.concat(l.cfg.selectable?l._func:[])},key:function(e){return e.key},view:{handler:{shape:function(e){var t=e.node,e=e.ctx;return t.setAttribute("data-name",l._name(e,"shape"))},text:function(e){var t=e.node,e=e.ctx;return t.setAttribute("data-name",l._name(e,"text")),t.innerText=e.text}}}}}}),render:new ldview({root:this.layout.getGroup(this.name),initRender:!1,handler:{legend:{list:function(){return l._data.concat(l.cfg.selectable?l._func:[])},key:function(e){return e.key},view:{action:{click:{"@":function(e){e.node;var t,n=e.ctx;if(l.cfg.selectable){if("func"===n.type)for(t in l._picked)l._picked[t]="all"===n.key;else l._picked[n.key]=!l._picked[n.key];return l.view.render.render("legend"),l.fire("select",l._picked)}}}},handler:{"@":function(e){var t=e.node,e=e.ctx;return t.style.opacity=!l.cfg.selectable||"func"===e.type||l._picked[e.key]?1:.3},shape:function(e){var t,n,i=e.node,r=e.ctx;if("func"!==r.type)return i.querySelector("circle")||i.appendChild(document.createElementNS(d,"circle")),t=i.querySelector("circle"),n=l.layout.getBox(l._name(r,"shape")),e=l.layout.getBox(l.name),t.setAttribute("cx",".5em"),t.setAttribute("cy",".5em"),t.setAttribute("r",".5em"),t.setAttribute("transform","translate("+(n.x-e.x)+", "+(n.y-e.y)+")"),"function"==typeof a.shape?a.shape.call(t,r):void 0;i.style.display="none"},text:function(e){var t=e.node,n=e.ctx,i=l.layout.getNode(l._name(n,"text")),e=l.layout.getBox(l._name(n,"text")),n=l.layout.getBox(l.name);return t.setAttribute("transform","translate("+(e.x-n.x)+", "+(e.y-n.y)+")"),t.textContent="",i=wrapSvgText({node:i,useRange:!0}),t.appendChild(i)}}}}}})},this.update(),this}).prototype=function(e,t){var n,i={}.hasOwnProperty;for(n in t)i.call(t,n)&&(e[n]=t[n]);return e}(Object.create(Object.prototype),{_name:function(e,t){return"pdlg-"+(t=null==t?"s":t)+"-"+this.id+"-"+(e.type||"")+"-"+e.key},enabled:function(){return this._data&&this._data.length&&(!(null!=this.cfg.enabled)||this.cfg.enabled)},update:function(){var e=this.enabled()?"":"0px",t=this.layout.getNode("legend").style;return t.width=e,t.height=e,t.padding=e,t.margin=e,this.view.layout.render()},render:function(){var e=this.enabled();if(this.layout.getGroup(this.name).style.display=e?"":"none",e)return this.view.render.render()},config:function(e){var t,n=this;return null==e?this.cfg:(this.cfg.selectable!==e.selectable&&(this._picked=null,this._updatePicked()),this.cfg=e,this.dir="bottom"===this.cfg.position?"horizontal":"vertical",t=this.layout.getNode(this.name).querySelector(".pdlg"),["horizontal","vertical"].map(function(e){return t.classList.toggle(e,n.dir===e)}))},_updatePicked:function(){var t=this;return null==this._picked&&(this._picked=Object.fromEntries(this._data.map(function(e){return[e.key,!0]}))),this._data.map(function(e){if(null==t._picked[e.key])return t._picked[e.key]=!0})},data:function(e){var n={};return(e=null==e?[]:e).map(function(e,t){return n[e.key]=t}),this._data=e.filter(function(e,t){return n[e.key]===t}),this._updatePicked(),this.update(),this.layout.update(!1),this.view.render.render()},on:function(e,n){var i=this;return(Array.isArray(e)?e:[e]).map(function(e){var t;return((t=i.evtHandler)[e]||(t[e]=[])).push(n)})},fire:function(e){for(var t,n,i,r,a=[],l=[],d=1,c=arguments.length;d<c;++d)l.push(arguments[d]);for(t=l,d=0,i=(n=this.evtHandler[e]||[]).length;d<i;++d)r=n[d],a.push(r.apply(this,t));return a},isSelected:function(e){return!!this._picked[e]}}),"undefined"!=typeof chart&&null!==chart&&((chart.utils||(chart.utils={})).legend=e)}.call(this);
1
+ !function(){var d,t;d="http://www.w3.org/2000/svg",(t=function(a){var t,e,n,i,l=this;return null==a&&(a={}),this._data=a.data||[],this.name=a.name||"legend",this.cfg=a.cfg||{},this.root="string"==typeof a.root?document.querySelector(a.root):a.root,this.dir=a.direction||"vertical",this.evtHandler={},this._picked=Object.fromEntries(this._data.map(function(t){return[t.key,!0]})),this.layout=a.layout||new layout({root:this.root}),(n=this.layout).on("update",function(){return l.update()}),n.on("render",function(){return l.render()}),this.id=Math.random().toString(36).substring(2),i=this.layout.getNode(this.name),t=this.layout.getGroup(this.name),i.querySelector("[ld-each=legend]")||(i.innerHTML='<div class="pdlg '+this.dir+'">\n <div ld-each="legend">\n <div class="pdl-cell" ld="shape" data-only></div>\n <div class="pdl-cell" ld="text" data-only></div>\n </div>\n</div>'),t.querySelector("[ld-each=legend]")||(e=document.createElementNS(d,"g"),n=document.createElementNS(d,"g"),i=document.createElementNS(d,"g"),e.classList.add("pdlg-g"),e.setAttribute("ld-each","legend"),n.setAttribute("ld","shape"),i.setAttribute("ld","text"),e.appendChild(n),e.appendChild(i),t.appendChild(e)),this._func=[{key:"all",type:"func",text:"全選"},{key:"none",type:"func",text:"全不選"}],this.view={layout:new ldview({root:this.layout.getNode(this.name),initRender:!1,handler:{legend:{list:function(){return l._data.concat(l.cfg.selectable?l._func:[])},key:function(t){return t.key},view:{handler:{shape:function(t){var e=t.node,t=t.ctx;return e.setAttribute("data-name",l._name(t,"shape"))},text:function(t){var e=t.node,t=t.ctx;return e.setAttribute("data-name",l._name(t,"text")),e.innerText=t.text}}}}}}),render:new ldview({root:this.layout.getGroup(this.name),initRender:!1,handler:{legend:{list:function(){return l._data.concat(l.cfg.selectable?l._func:[])},key:function(t){return t.key},view:{action:{click:{"@":function(t){t.node;var e,n=t.ctx;if(l.cfg.selectable){if("func"===n.type)for(e in l._picked)l._picked[e]="all"===n.key;else l._picked[n.key]=!l._picked[n.key];return l.view.render.render("legend"),l.fire("select",l._picked)}}}},handler:{"@":function(t){var e=t.node,t=t.ctx;return e.style.opacity=!l.cfg.selectable||"func"===t.type||l._picked[t.key]?1:.3},shape:function(t){var e,n,i=t.node,r=t.ctx;if("func"!==r.type)return i.querySelector("circle")||i.appendChild(document.createElementNS(d,"circle")),e=i.querySelector("circle"),n=l.layout.getBox(l._name(r,"shape")),t=l.layout.getBox(l.name),e.setAttribute("cx",".5em"),e.setAttribute("cy",".5em"),e.setAttribute("r",".5em"),e.setAttribute("transform","translate("+(n.x-t.x)+", "+(n.y-t.y)+")"),"function"==typeof a.shape?a.shape.call(e,r):void 0;i.style.display="none"},text:function(t){var e=t.node,n=t.ctx,i=l.layout.getNode(l._name(n,"text")),t=l.layout.getBox(l._name(n,"text")),n=l.layout.getBox(l.name);return e.setAttribute("transform","translate("+(t.x-n.x)+", "+(t.y-n.y)+")"),e.textContent="",i=wrapSvgText({node:i,useRange:!0}),e.appendChild(i)}}}}}})},this.update(),this}).prototype=function(t,e){var n,i={}.hasOwnProperty;for(n in e)i.call(e,n)&&(t[n]=e[n]);return t}(Object.create(Object.prototype),{_name:function(t,e){return"pdlg-"+(e=null==e?"s":e)+"-"+this.id+"-"+(t.type||"")+"-"+t.key},enabled:function(){return this._data&&this._data.length&&(!(null!=this.cfg.enabled)||this.cfg.enabled)},update:function(){var t=this.enabled()?"":"0px",e=this.layout.getNode("legend").style;return e.width=t,e.height=t,e.padding=t,e.margin=t,this.view.layout.render()},render:function(){var t=this.enabled();if(this.layout.getGroup(this.name).style.display=t?"":"none",t)return this.view.render.render()},config:function(t){var e,n=this;return null==t?this.cfg:(this.cfg.selectable!==t.selectable&&(this._picked=null,this._updatePicked()),this.cfg=t,this.dir="bottom"===this.cfg.position?"horizontal":"vertical",e=this.layout.getNode(this.name).querySelector(".pdlg"),["horizontal","vertical"].map(function(t){return e.classList.toggle(t,n.dir===t)}))},_updatePicked:function(){var e=this;return null==this._picked&&(this._picked=Object.fromEntries(this._data.map(function(t){return[t.key,!0]}))),this._data.map(function(t){if(null==e._picked[t.key])return e._picked[t.key]=!0})},data:function(t){var n={};return(t=null==t?[]:t).map(function(t,e){return n[t.key]=e}),this._data=t.filter(function(t,e){return n[t.key]===e}),this._range=this._data.filter(function(t){return t.ext}),this._updatePicked(),this.update(),this.layout.update(!1),this.view.render.render()},on:function(t,n){var i=this;return(Array.isArray(t)?t:[t]).map(function(t){var e;return((e=i.evtHandler)[t]||(e[t]=[])).push(n)})},fire:function(t){for(var e,n,i,r,a=[],l=[],d=1,c=arguments.length;d<c;++d)l.push(arguments[d]);for(e=l,d=0,i=(n=this.evtHandler[t]||[]).length;d<i;++d)r=n[d],a.push(r.apply(this,e));return a},isSelected:function(e){var n=this;return this._range&&this._range.length?!!this._range.filter(function(t){return e>=t.ext[0]&&e<t.ext[1]&&n._picked[t.key]}).length:!!this._picked[e]}}),"undefined"!=typeof chart&&null!==chart&&((chart.utils||(chart.utils={})).legend=t)}.call(this);
package/utils/tick.js CHANGED
@@ -1,7 +1,7 @@
1
1
  (function(){
2
2
  var tick;
3
3
  tick = function(o){
4
- var ext, len, ticks, extent, g, s, i$, ref$, len$, i, step, base, lg, fmt, unit, labels, to$, t1, t2;
4
+ var ext, len, delta, ticks, steps, pow, i$, i, g, s, j$, ref$, len$, j, step, ref1$, v, extent, base, lg, fmt, unit, labels, to$, t1, t2;
5
5
  o == null && (o = {});
6
6
  ext = o.extent || [0, 1];
7
7
  len = o.len || 3;
@@ -15,7 +15,62 @@
15
15
  if (ext[0] > ext[1]) {
16
16
  ext = [ext[1], ext[0]];
17
17
  }
18
- if (o.pretty != null && !o.pretty) {
18
+ if (o.exp != null) {
19
+ delta = ext[1] - ext[0];
20
+ ticks = [];
21
+ steps = [];
22
+ pow = Math.pow(10, o.exp);
23
+ if (o.pretty != null && !o.pretty) {
24
+ ticks = (function(){
25
+ var i$, to$, results$ = [];
26
+ for (i$ = 0, to$ = len; i$ <= to$; ++i$) {
27
+ results$.push(i$);
28
+ }
29
+ return results$;
30
+ }()).map(function(i){
31
+ return delta * Math.pow(i / len, pow) + ext[0];
32
+ });
33
+ } else {
34
+ for (i$ = 1; i$ <= len; ++i$) {
35
+ i = i$;
36
+ g = delta * (Math.pow(i / len, pow) - Math.pow((i - 1) / len, pow));
37
+ s = Math.floor(Math.log(g) / Math.LN10);
38
+ for (j$ = 0, len$ = (ref$ = [10, 20, 25, 50, 100]).length; j$ < len$; ++j$) {
39
+ j = ref$[j$];
40
+ if ((step = j * Math.pow(10, s - 1)) > g) {
41
+ break;
42
+ }
43
+ }
44
+ steps.push(step);
45
+ }
46
+ delta = steps.reduce(function(a, b){
47
+ return a + b;
48
+ }, 0);
49
+ ext = [ext[0], (ref$ = ext[0] + delta) > (ref1$ = ext[1]) ? ref$ : ref1$];
50
+ ext = [[ext[0], 'floor'], [ext[1], 'ceil']].map(function(arg$){
51
+ var t, n, ret;
52
+ t = arg$[0], n = arg$[1];
53
+ ret = [10, 20, 25, 50, 100].map(function(d){
54
+ return [d, Math.abs(t - Math[n](t / d) * d)];
55
+ });
56
+ ret.sort(function(a, b){
57
+ return a[1] - b[1];
58
+ });
59
+ return ret[0][0] * Math[n](t / ret[0][0]);
60
+ });
61
+ v = ext[0];
62
+ for (i$ = 0; i$ < len; ++i$) {
63
+ i = i$;
64
+ ticks.push(v);
65
+ v = v + steps[i];
66
+ }
67
+ ticks.push(v);
68
+ }
69
+ ticks.sort(function(a, b){
70
+ return a - b;
71
+ });
72
+ extent = [ticks[0], ticks[len - 1]];
73
+ } else if (o.pretty != null && !o.pretty) {
19
74
  ticks = (function(){
20
75
  var i$, to$, results$ = [];
21
76
  for (i$ = 0, to$ = len; i$ < to$; ++i$) {
@@ -59,6 +114,7 @@
59
114
  i = i$;
60
115
  ref$ = [ticks[i], ticks[i + 1]], t1 = ref$[0], t2 = ref$[1];
61
116
  labels.push({
117
+ ext: [t1, t2],
62
118
  key: (t1 + t2) / 2,
63
119
  text: lg.text
64
120
  ? lg.text(t1, t2)
package/utils/tick.min.js CHANGED
@@ -1 +1 @@
1
- !function(){var t=function(t){var n,e,r,u,o,a,f,i,l,c,h,s,p,y,k,x,g,m=(t=null==t?{}:t).extent||[0,1],M=t.len||3;if((m=m.map(function(t){return isNaN(t)?0:t}))[0]>m[1]&&(m=[m[1],m[0]]),null==t.pretty||t.pretty){for(r=(m[1]-m[0])/(M+1),u=Math.floor(Math.log((m[1]-m[0]||1)/(M+1))/Math.LN10),o=0,f=(a=[10,20,25,50,100]).length;o<f&&(i=a[o],!((l=i*Math.pow(10,u-1))>r));++o);c=l*Math.floor(m[0]/l),e=[(n=function(){for(var t=[],n=0,e=M;n<=e;++n)t.push(n);return t}().map(function(t){return c+l*t}))[0],n[M]]}else e=[(n=function(){for(var t=[],n=0,e=M;n<e;++n)t.push(n);return t}().map(function(t){return m[0]+(m[1]-m[0])*t/(1<(t=M-1)?t:1)}))[0],n[M-1]];if(h=t.legend){if(s=h.format||function(t){return t},p=h.unit||"",h.range)for(y=[],o=0,k=n.length-1;o<k;++o)x=(a=[n[i=o],n[i+1]])[0],g=a[1],y.push({key:(x+g)/2,text:h.text?h.text(x,g):s(x)+" - "+s(g)+p});else y=n.map(function(t){return{key:t,text:h.text?h.text(t):s(t)+""+p}});y.sort(function(t,n){return t.key<n.key?1:t.key>n.key?-1:0})}return{ticks:n,extent:e,labels:y}};"undefined"!=typeof chart&&null!==chart&&((chart.utils||(chart.utils={})).tick=t)}.call(this);
1
+ !function(){var t=function(t){var n,r,e,u,o,a,f,l,h,i,p,c,s,M,x,y,k,m,g,v,w,d,N,b=(t=null==t?{}:t).extent||[0,1],L=t.len||3;if((b=b.map(function(t){return isNaN(t)?0:t}))[0]>b[1]&&(b=[b[1],b[0]]),null!=t.exp){if(n=b[1]-b[0],r=[],e=[],u=Math.pow(10,t.exp),null==t.pretty||t.pretty){for(o=1;o<=L;++o){for(a=o,f=n*(Math.pow(a/L,u)-Math.pow((a-1)/L,u)),l=Math.floor(Math.log(f)/Math.LN10),h=0,p=(i=[10,20,25,50,100]).length;h<p&&(c=i[h],!((s=c*Math.pow(10,l-1))>f));++h);e.push(s)}for(n=e.reduce(function(t,n){return t+n},0),M=(b=[[(b=[b[0],(i=b[0]+n)>(x=b[1])?i:x])[0],"floor"],[b[1],"ceil"]].map(function(t){var n=t[0],r=t[1],t=[10,20,25,50,100].map(function(t){return[t,Math.abs(n-Math[r](n/t)*t)]});return t.sort(function(t,n){return t[1]-n[1]}),t[0][0]*Math[r](n/t[0][0])}))[0],o=0;o<L;++o)a=o,r.push(M),M+=e[a];r.push(M)}else r=function(){for(var t=[],n=0,r=L;n<=r;++n)t.push(n);return t}().map(function(t){return n*Math.pow(t/L,u)+b[0]});r.sort(function(t,n){return t-n}),x=[r[0],r[L-1]]}else if(null==t.pretty||t.pretty){for(f=(b[1]-b[0])/(L+1),l=Math.floor(Math.log((b[1]-b[0]||1)/(L+1))/Math.LN10),o=0,p=(i=[10,20,25,50,100]).length;o<p&&(a=i[o],!((s=a*Math.pow(10,l-1))>f));++o);y=s*Math.floor(b[0]/s),x=[(r=function(){for(var t=[],n=0,r=L;n<=r;++n)t.push(n);return t}().map(function(t){return y+s*t}))[0],r[L]]}else x=[(r=function(){for(var t=[],n=0,r=L;n<r;++n)t.push(n);return t}().map(function(t){return b[0]+(b[1]-b[0])*t/(1<(t=L-1)?t:1)}))[0],r[L-1]];if(k=t.legend){if(m=k.format||function(t){return t},g=k.unit||"",k.range)for(v=[],o=0,w=r.length-1;o<w;++o)d=(i=[r[a=o],r[a+1]])[0],N=i[1],v.push({ext:[d,N],key:(d+N)/2,text:k.text?k.text(d,N):m(d)+" - "+m(N)+g});else v=r.map(function(t){return{key:t,text:k.text?k.text(t):m(t)+""+g}});v.sort(function(t,n){return t.key<n.key?1:t.key>n.key?-1:0})}return{ticks:r,extent:x,labels:v}};"undefined"!=typeof chart&&null!==chart&&((chart.utils||(chart.utils={})).tick=t)}.call(this);
package/utils/tint.js CHANGED
@@ -75,16 +75,16 @@
75
75
  if (arguments.length === 0) {
76
76
  return this._ext;
77
77
  }
78
- this._ext = e = [v[0], v[1]].map(function(it){
78
+ this._ext = e = v.map(function(it){
79
79
  if (it != null) {
80
80
  return it;
81
81
  } else {
82
82
  return 0;
83
83
  }
84
84
  });
85
- if (e[0] > e[1]) {
86
- return this._ext = [e[1], e[0]];
87
- }
85
+ return this._ext.sort(function(a, b){
86
+ return a - b;
87
+ });
88
88
  },
89
89
  get: function(d, v, i){
90
90
  v == null && (v = 0);
@@ -93,6 +93,8 @@
93
93
  return this._vd(d, v);
94
94
  case 2:
95
95
  return this._vc(d, v);
96
+ case 3:
97
+ return this._vs(d, v);
96
98
  default:
97
99
  return this._d(d, v, i);
98
100
  }
@@ -156,6 +158,23 @@
156
158
  }
157
159
  return this._v(ret, variant);
158
160
  },
161
+ _vs: function(data, variant){
162
+ var ext, idx, i$, to$, i, ref$, ref1$;
163
+ ext = this._ext || [0, 1];
164
+ idx = -1;
165
+ for (i$ = 0, to$ = ext.length - 1; i$ < to$; ++i$) {
166
+ i = i$;
167
+ if (data >= ext[i + 1]) {
168
+ continue;
169
+ }
170
+ idx = i;
171
+ break;
172
+ }
173
+ if (idx === -1) {
174
+ idx = ext.length;
175
+ }
176
+ return this._v(this.colors[(ref$ = idx > 0 ? idx : 0) < (ref1$ = this.colors.length - 1) ? ref$ : ref1$], variant);
177
+ },
159
178
  _vd: function(data, variant){
160
179
  var ext, v, ref$, ref1$;
161
180
  ext = this._ext || [0, 1];
@@ -191,7 +210,8 @@
191
210
  tint.mode = {
192
211
  ordinal: 0,
193
212
  discrete: 1,
194
- continuous: 2
213
+ continuous: 2,
214
+ ranges: 3
195
215
  };
196
216
  if (typeof chart != 'undefined' && chart !== null) {
197
217
  (chart.utils || (chart.utils = {})).tint = tint;
package/utils/tint.min.js CHANGED
@@ -1 +1 @@
1
- !function(){var s;(s=function(t){return this.isUnique=null==(t=null==t?{}:t).unique||t.unique,this.map={},this.nmap=[],this.wm=new WeakMap,this.count=0,this._ext=t.extent||[0,1],this.set(t.palette)||t.colors,this.mode(t.mode),this}).default=["#e15c64","#f7b26a","#f3ed9d","#a4bd81","#a0d7d2","#8db1da","#daaedb"],s.prototype=function(t,n){var i,s={}.hasOwnProperty;for(i in n)s.call(n,i)&&(t[i]=n[i]);return t}(Object.create(Object.prototype),{set:function(t,n){var i=this;return null==t&&(t=[]),null==n&&(n=!1),this.colors=Array.isArray(t)&&t.length?t:t.colors&&Array.isArray(t.colors)?t.colors:s.default,this.nmap=t.maps||[],this.colors=this.colors.map(function(t){return t.value||t}),1===this.colors.length&&this.colors.push(ldcolor.complement(this.colors[0])),this.colors=this.colors.map(function(t){return ldcolor.hsl(t)}),this.len=2<(t=this.colors.length)?t:2,n?this.reset():this.nmap.map(function(t,n){return(Array.isArray(t)?t:[t]).map(function(t){return i.get(t,0,n)})})},unique:function(t){return null!=t?this.isUnique=!!t:this.isUnique},reset:function(){var i=this;return this.map={},this.wm=new WeakMap,this.count=0,(this.nmap||[]).map(function(t,n){return(Array.isArray(t)?t:[t]).map(function(t){return i.get(t,0,n)})})},mode:function(t){return 0===arguments.length?this._m:this._m=t},extent:function(t){var n;return 0===arguments.length?this._ext:(this._ext=n=[t[0],t[1]].map(function(t){return null!=t?t:0}),n[0]>n[1]?this._ext=[n[1],n[0]]:void 0)},get:function(t,n,i){switch(null==n&&(n=0),this._m){case 1:return this._vd(t,n);case 2:return this._vc(t,n);default:return this._d(t,n,i)}},_v:function(t,n){return 0<n?t=ldcolor.lighter(t,n):n<0&&(t=ldcolor.darker(t,-n)),ldcolor.web(t)},_d:function(t,n,i){var s,r,e,o,l,h,u,c;if(null==n&&(n=0),null!=i?(this.count<i&&(this.count=i+1),s=i%this.len,"object"==typeof t?this.wm.set(t,s):this.map[t]=s):("object"==typeof t?null==(s=this.wm.get(t))&&this.wm.set(t,s=this.count++):null==(s=this.map[t])&&(this.map[t]=s=this.count++),this.isUnique||(s%=this.len)),s>=this.len){for(c=s%(this.len-1),r=Math.floor(s/(this.len-1)),o=(e=[0,1])[0],l=e[1];0<r;)o=(e=[2*o,2*l])[0],l=e[1],r%2&&(o+=1),r>>=1;r=o/l,e=[this.colors[c],this.colors[1+c]],h=e[0],u=e[1],c={h:(e=["h","s","l"].map(function(t){return r*(u[t]-h[t])+h[t]}))[0],s:e[1],l:e[2]}}else c=this.colors[s];return this._v(c,n)},_vd:function(t,n){var i,s=this._ext||[0,1],s=(t=0<(i=(t-s[0])/(s[1]-s[0]||1))?i:0)<1?t:1;return this._v(this.colors[Math.floor((t=s*(this.len||1))<(i=this.len-1)?t:i)],n)},_vc:function(t,n){var i,s,r,e=this._ext||[0,1],t=((o=0<(l=(t-e[0])/(e[1]-e[0]||1))?l:0)<1?o:1)*(this.len||1),o=[(o=Math.floor(void 0))<(l=this.len-1)?o:l,(o=Math.floor(void 0)+1)<(l=this.len-1)?o:l],e=o[0],l=o[1];return o=[this.colors[e],this.colors[l]],i=o[0],s=o[1],r=t-e,t=(o=["h","s","l"].map(function(t){return r*(s[t]-i[t])+i[t]}))[0],e=o[1],o=o[2],this._v({h:t,s:e,l:o},n)},text:function(t,n){return null==n&&(n={}),t=ldcolor.hcl(this.get(t)),ldcolor.web(50<t.l?n.textDark||"#000":n.textLight||"#fff")}}),s.mode={ordinal:0,discrete:1,continuous:2},"undefined"!=typeof chart&&null!==chart&&((chart.utils||(chart.utils={})).tint=s)}.call(this);
1
+ !function(){var i;(i=function(t){return this.isUnique=null==(t=null==t?{}:t).unique||t.unique,this.map={},this.nmap=[],this.wm=new WeakMap,this.count=0,this._ext=t.extent||[0,1],this.set(t.palette)||t.colors,this.mode(t.mode),this}).default=["#e15c64","#f7b26a","#f3ed9d","#a4bd81","#a0d7d2","#8db1da","#daaedb"],i.prototype=function(t,n){var s,i={}.hasOwnProperty;for(s in n)i.call(n,s)&&(t[s]=n[s]);return t}(Object.create(Object.prototype),{set:function(t,n){var s=this;return null==t&&(t=[]),null==n&&(n=!1),this.colors=Array.isArray(t)&&t.length?t:t.colors&&Array.isArray(t.colors)?t.colors:i.default,this.nmap=t.maps||[],this.colors=this.colors.map(function(t){return t.value||t}),1===this.colors.length&&this.colors.push(ldcolor.complement(this.colors[0])),this.colors=this.colors.map(function(t){return ldcolor.hsl(t)}),this.len=2<(t=this.colors.length)?t:2,n?this.reset():this.nmap.map(function(t,n){return(Array.isArray(t)?t:[t]).map(function(t){return s.get(t,0,n)})})},unique:function(t){return null!=t?this.isUnique=!!t:this.isUnique},reset:function(){var s=this;return this.map={},this.wm=new WeakMap,this.count=0,(this.nmap||[]).map(function(t,n){return(Array.isArray(t)?t:[t]).map(function(t){return s.get(t,0,n)})})},mode:function(t){return 0===arguments.length?this._m:this._m=t},extent:function(t){return 0===arguments.length?this._ext:(this._ext=t.map(function(t){return null!=t?t:0}),this._ext.sort(function(t,n){return t-n}))},get:function(t,n,s){switch(null==n&&(n=0),this._m){case 1:return this._vd(t,n);case 2:return this._vc(t,n);case 3:return this._vs(t,n);default:return this._d(t,n,s)}},_v:function(t,n){return 0<n?t=ldcolor.lighter(t,n):n<0&&(t=ldcolor.darker(t,-n)),ldcolor.web(t)},_d:function(t,n,s){var i,r,e,o,l,h,u,c;if(null==n&&(n=0),null!=s?(this.count<s&&(this.count=s+1),i=s%this.len,"object"==typeof t?this.wm.set(t,i):this.map[t]=i):("object"==typeof t?null==(i=this.wm.get(t))&&this.wm.set(t,i=this.count++):null==(i=this.map[t])&&(this.map[t]=i=this.count++),this.isUnique||(i%=this.len)),i>=this.len){for(c=i%(this.len-1),r=Math.floor(i/(this.len-1)),o=(e=[0,1])[0],l=e[1];0<r;)o=(e=[2*o,2*l])[0],l=e[1],r%2&&(o+=1),r>>=1;r=o/l,e=[this.colors[c],this.colors[1+c]],h=e[0],u=e[1],c={h:(e=["h","s","l"].map(function(t){return r*(u[t]-h[t])+h[t]}))[0],s:e[1],l:e[2]}}else c=this.colors[i];return this._v(c,n)},_vs:function(t,n){for(var s,i,r,e=this._ext||[0,1],o=-1,l=0,h=e.length-1;l<h;++l)if(!(t>=e[(s=l)+1])){o=s;break}return-1===o&&(o=e.length),this._v(this.colors[(i=0<o?o:0)<(r=this.colors.length-1)?i:r],n)},_vd:function(t,n){var s,i=this._ext||[0,1],i=(t=0<(s=(t-i[0])/(i[1]-i[0]||1))?s:0)<1?t:1;return this._v(this.colors[Math.floor((t=i*(this.len||1))<(s=this.len-1)?t:s)],n)},_vc:function(t,n){var s,i,r,e=this._ext||[0,1],t=((o=0<(l=(t-e[0])/(e[1]-e[0]||1))?l:0)<1?o:1)*(this.len||1),o=[(o=Math.floor(void 0))<(l=this.len-1)?o:l,(o=Math.floor(void 0)+1)<(l=this.len-1)?o:l],e=o[0],l=o[1];return o=[this.colors[e],this.colors[l]],s=o[0],i=o[1],r=t-e,t=(o=["h","s","l"].map(function(t){return r*(i[t]-s[t])+s[t]}))[0],e=o[1],o=o[2],this._v({h:t,s:e,l:o},n)},text:function(t,n){return null==n&&(n={}),t=ldcolor.hcl(this.get(t)),ldcolor.web(50<t.l?n.textDark||"#000":n.textLight||"#fff")}}),i.mode={ordinal:0,discrete:1,continuous:2,ranges:3},"undefined"!=typeof chart&&null!==chart&&((chart.utils||(chart.utils={})).tint=i)}.call(this);