@plotdb/chart 0.0.2
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 +11 -0
- package/README.md +50 -0
- package/build +39 -0
- package/dist/chart.css +8 -0
- package/dist/chart.js +603 -0
- package/dist/chart.min.css +1 -0
- package/dist/chart.min.js +1 -0
- package/dist/data/index.js +73 -0
- package/dist/utils/axis.js +357 -0
- package/dist/utils/axis.min.js +1 -0
- package/dist/utils/config.js +33 -0
- package/dist/utils/config.min.js +1 -0
- package/dist/utils/data.js +238 -0
- package/dist/utils/data.min.js +1 -0
- package/dist/utils/format.js +70 -0
- package/dist/utils/format.min.js +1 -0
- package/dist/utils/legend.css +40 -0
- package/dist/utils/legend.js +263 -0
- package/dist/utils/legend.min.css +1 -0
- package/dist/utils/legend.min.js +1 -0
- package/dist/utils/tint.js +138 -0
- package/dist/utils/tint.min.js +1 -0
- package/dist/utils/tip.js +148 -0
- package/dist/utils/tip.min.js +1 -0
- package/doc/charts.md +58 -0
- package/doc/config.md +44 -0
- package/doc/draft/chart.md +146 -0
- package/doc/draft/data.md +8 -0
- package/doc/draft/definition.md +0 -0
- package/doc/draft/events.md +0 -0
- package/doc/draft/filter.md +0 -0
- package/doc/draft/lifecycle.md +89 -0
- package/doc/spec.md +89 -0
- package/doc/todo.md +27 -0
- package/doc/utils/tip.md +84 -0
- package/package.json +83 -0
- package/src/chart.ls +320 -0
- package/src/chart.styl +6 -0
- package/src/data/en-US/category +20 -0
- package/src/data/en-US/fruit +39 -0
- package/src/data/en-US/movie +125 -0
- package/src/data/en-US/name +58 -0
- package/src/data/index.ls +34 -0
- package/src/data/zh-TW/category +20 -0
- package/src/data/zh-TW/fruits +38 -0
- package/src/data/zh-TW/movie +125 -0
- package/src/data/zh-TW/names +105 -0
- package/src/utils/axis.ls +229 -0
- package/src/utils/config.ls +11 -0
- package/src/utils/data.ls +104 -0
- package/src/utils/format.ls +30 -0
- package/src/utils/legend.ls +134 -0
- package/src/utils/legend.styl +37 -0
- package/src/utils/tint.ls +66 -0
- package/src/utils/tip.ls +97 -0
- package/web/src/pug/base.pug +19 -0
- package/web/src/pug/block/axis/0.0.1/index.ls +38 -0
- package/web/src/pug/block/axis/0.0.1/index.pug +1 -0
- package/web/src/pug/block/axis-bubble/0.0.1/index.ls +141 -0
- package/web/src/pug/block/axis-bubble/0.0.1/index.pug +1 -0
- package/web/src/pug/block/bar/0.0.1/index.ls +274 -0
- package/web/src/pug/block/bar/0.0.1/index.pug +35 -0
- package/web/src/pug/block/bar-list/0.0.1/index.ls +85 -0
- package/web/src/pug/block/bar-list/0.0.1/index.pug +30 -0
- package/web/src/pug/block/bar-race/0.0.1/index.ls +83 -0
- package/web/src/pug/block/bar-race/0.0.1/index.pug +21 -0
- package/web/src/pug/block/base/0.0.1/index.ls +67 -0
- package/web/src/pug/block/base/0.0.1/index.pug +5 -0
- package/web/src/pug/block/blank/0.0.1/index.ls +25 -0
- package/web/src/pug/block/blank/0.0.1/index.pug +1 -0
- package/web/src/pug/block/bubble/0.0.1/index.ls +220 -0
- package/web/src/pug/block/bubble/0.0.1/index.pug +28 -0
- package/web/src/pug/block/curve-bar/0.0.1/index.ls +89 -0
- package/web/src/pug/block/curve-bar/0.0.1/index.pug +16 -0
- package/web/src/pug/block/curve-bar/0.0.1/sample.js +338 -0
- package/web/src/pug/block/dumbbell/0.0.1/index.ls +90 -0
- package/web/src/pug/block/dumbbell/0.0.1/index.pug +1 -0
- package/web/src/pug/block/empty/0.0.1/index.ls +27 -0
- package/web/src/pug/block/empty/0.0.1/index.pug +2 -0
- package/web/src/pug/block/gauge/0.0.1/index.ls +100 -0
- package/web/src/pug/block/gauge/0.0.1/index.pug +31 -0
- package/web/src/pug/block/gauge/0.0.1/sample.js +338 -0
- package/web/src/pug/block/line/0.0.1/index.ls +265 -0
- package/web/src/pug/block/line/0.0.1/index.pug +33 -0
- package/web/src/pug/block/number/0.0.1/index.ls +69 -0
- package/web/src/pug/block/number/0.0.1/index.pug +20 -0
- package/web/src/pug/block/percent-list/0.0.1/index.ls +167 -0
- package/web/src/pug/block/percent-list/0.0.1/index.pug +34 -0
- package/web/src/pug/block/pie/0.0.1/index.ls +125 -0
- package/web/src/pug/block/pie/0.0.1/index.pug +19 -0
- package/web/src/pug/block/pie/0.0.1/sample.js +338 -0
- package/web/src/pug/block/pie-bubble/0.0.1/index.ls +185 -0
- package/web/src/pug/block/pie-bubble/0.0.1/index.pug +40 -0
- package/web/src/pug/block/radar/0.0.1/index.ls +113 -0
- package/web/src/pug/block/radar/0.0.1/index.pug +1 -0
- package/web/src/pug/block/radar/0.0.1/xx +285 -0
- package/web/src/pug/block/scatter/0.0.1/index.ls +128 -0
- package/web/src/pug/block/scatter/0.0.1/index.pug +30 -0
- package/web/src/pug/block/sheet/0.0.1/index.ls +38 -0
- package/web/src/pug/block/sheet/0.0.1/index.pug +5 -0
- package/web/src/pug/block/table/0.0.1/index.ls +40 -0
- package/web/src/pug/block/table/0.0.1/index.pug +3 -0
- package/web/src/pug/block/taiwantown/0.0.1/index.ls +48 -0
- package/web/src/pug/block/taiwantown/0.0.1/index.pug +52 -0
- package/web/src/pug/block/taiwanvillage/0.0.1/index.ls +53 -0
- package/web/src/pug/block/taiwanvillage/0.0.1/index.pug +52 -0
- package/web/src/pug/block/treemap/0.0.1/index.ls +172 -0
- package/web/src/pug/block/treemap/0.0.1/index.pug +42 -0
- package/web/src/pug/block/voronoi-treemap/0.0.1/index.ls +174 -0
- package/web/src/pug/block/voronoi-treemap/0.0.1/index.pug +17 -0
- package/web/src/pug/block/voronoi-treemap/0.0.1/sample.js +241 -0
- package/web/src/pug/block/wordcloud/0.0.1/index.ls +61 -0
- package/web/src/pug/block/wordcloud/0.0.1/index.pug +1 -0
- package/web/src/pug/block/worldmap/0.0.1/index.ls +83 -0
- package/web/src/pug/block/worldmap/0.0.1/index.pug +12 -0
- package/web/src/pug/index.ls +72 -0
- package/web/src/pug/index.pug +52 -0
- package/web/src/styl/index.styl +0 -0
- package/web/static/assets/block/cache.js +4 -0
- package/web/static/assets/custom-lib/d3/d3-array.v2.min.js +2 -0
- package/web/static/assets/custom-lib/d3/d3-axis.v2.min.js +2 -0
- package/web/static/assets/custom-lib/d3/d3-brush.v2.min.js +2 -0
- package/web/static/assets/custom-lib/d3/d3-color.v2.min.js +2 -0
- package/web/static/assets/custom-lib/d3/d3-dispatch.v2.min.js +2 -0
- package/web/static/assets/custom-lib/d3/d3-drag.v2.min.js +2 -0
- package/web/static/assets/custom-lib/d3/d3-ease.v2.min.js +2 -0
- package/web/static/assets/custom-lib/d3/d3-force-boundary.v0.0.1.min.js +2 -0
- package/web/static/assets/custom-lib/d3/d3-force.v2.min.js +2 -0
- package/web/static/assets/custom-lib/d3/d3-format.v2.min.js +2 -0
- package/web/static/assets/custom-lib/d3/d3-hierarchy.v2.min.js +2 -0
- package/web/static/assets/custom-lib/d3/d3-interpolate.v2.min.js +2 -0
- package/web/static/assets/custom-lib/d3/d3-path.v2.min.js +2 -0
- package/web/static/assets/custom-lib/d3/d3-quadtree.v2.min.js +2 -0
- package/web/static/assets/custom-lib/d3/d3-random.v2.min.js +2 -0
- package/web/static/assets/custom-lib/d3/d3-scale-chromatic.v1.min.js +2 -0
- package/web/static/assets/custom-lib/d3/d3-selection.v2.min.js +2 -0
- package/web/static/assets/custom-lib/d3/d3-shape.v2.min.js +2 -0
- package/web/static/assets/custom-lib/d3/d3-timer.v2.min.js +2 -0
- package/web/static/assets/custom-lib/d3/d3-transition.v2.min.js +2 -0
- package/web/static/assets/custom-lib/d3/d3.v4.js +17178 -0
- package/web/static/assets/custom-lib/d3/d3.v4.min.js +2 -0
- package/web/static/assets/data/countrycode.json +1 -0
- package/web/static/assets/data/world-110m.json +1 -0
- package/web/static/assets/data/zh-to-alpha2.json +1 -0
- package/web/static/assets/img/fluid.svg +16 -0
- package/web/static/block/axis/0.0.1/index.html +79 -0
- package/web/static/block/axis-bubble/0.0.1/index.html +222 -0
- package/web/static/block/bar/0.0.1/index.html +581 -0
- package/web/static/block/bar-list/0.0.1/index.html +231 -0
- package/web/static/block/bar-race/0.0.1/index.html +184 -0
- package/web/static/block/base/0.0.1/index.html +197 -0
- package/web/static/block/blank/0.0.1/index.html +42 -0
- package/web/static/block/bubble/0.0.1/index.html +402 -0
- package/web/static/block/bubble/0.0.1/test.html +0 -0
- package/web/static/block/curve-bar/0.0.1/index.html +148 -0
- package/web/static/block/dumbbell/0.0.1/index.html +178 -0
- package/web/static/block/empty/0.0.1/index.html +76 -0
- package/web/static/block/gauge/0.0.1/index.html +150 -0
- package/web/static/block/line/0.0.1/index.html +540 -0
- package/web/static/block/number/0.0.1/index.html +152 -0
- package/web/static/block/percent-list/0.0.1/index.html +316 -0
- package/web/static/block/pie/0.0.1/index.html +281 -0
- package/web/static/block/pie-bubble/0.0.1/index.html +358 -0
- package/web/static/block/radar/0.0.1/index.html +149 -0
- package/web/static/block/scatter/0.0.1/index.html +251 -0
- package/web/static/block/sheet/0.0.1/index.html +103 -0
- package/web/static/block/table/0.0.1/index.html +73 -0
- package/web/static/block/taiwantown/0.0.1/index.html +210 -0
- package/web/static/block/taiwanvillage/0.0.1/index.html +220 -0
- package/web/static/block/treemap/0.0.1/index.html +360 -0
- package/web/static/block/voronoi-treemap/0.0.1/index.html +350 -0
- package/web/static/block/wordcloud/0.0.1/index.html +92 -0
- package/web/static/block/worldmap/0.0.1/index.html +207 -0
- package/web/static/css/index.css +0 -0
- package/web/static/css/index.min.css +0 -0
- package/web/static/favicon.ico +0 -0
- package/web/static/index.html +153 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
div[plug=layout]{width:100%;height:100%}div[plug=layout] .pdl-layout{width:100%;height:100%}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
(function(){var svgns,parent,aniloop,visibilityObserver,resizeObserver,withDefault,defaultConfig,chart;svgns="http://www.w3.org/2000/svg";parent=function(n,s,e){var m;m=n;while(n&&n!==e){n=n.parentNode}if(n!==e){return null}if(!s){return n}n=m;while(n&&n!==e&&(!n.matches||n.matches&&!n.matches(s))){n=n.parentNode}if(n===e&&(!e.matches||!e.matches(s))){return null}return n};aniloop=function(){this.running=false;this.time={now:0,last:0};this.fps(60);this.evtHandler={};return this};aniloop.prototype=import$(Object.create(Object.prototype),{on:function(n,cb){var this$=this;return(Array.isArray(n)?n:[n]).map(function(n){var ref$;return((ref$=this$.evtHandler)[n]||(ref$[n]=[])).push(cb)})},fire:function(n){var v,res$,i$,to$,ref$,len$,cb,results$=[];res$=[];for(i$=1,to$=arguments.length;i$<to$;++i$){res$.push(arguments[i$])}v=res$;for(i$=0,len$=(ref$=this.evtHandler[n]||[]).length;i$<len$;++i$){cb=ref$[i$];results$.push(cb.apply(this,v))}return results$},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(it){if(it!=null){this.running=!it}if(this.running){return this.pause()}else{return this.run()}},pause:function(){return this.running=false},render:function(){return this.fire("tick",this.time.now)},run:function(fps){var this$=this;if(fps!=null){this.fps(fps)}if(this.running){return}this.running=true;return requestAnimationFrame(function(t){return this$.handler(this$.time.last=t,true)})},throttle:function(v){v==null&&(v=true);return this.isThrottled=v},fps:function(it){if(!(it!=null)){return this._fps_val}this._fps_val=it>.01?it:.01;return this._fps_delay=1e3/this._fps_val},handler:function(t,force){var delay,ref$,this$=this;force==null&&(force=false);if(!this.running){return}this.time.now=t;delay=this.isThrottled?(ref$=this._fps_delay)>1e3?ref$:1e3:this._fps_delay;if(force||this.time.now-this.time.last>=delay){this.time.last=t;this.render()}return requestAnimationFrame(function(t){return this$.handler(t,false)})}});visibilityObserver={list:[],init:function(){var ref$,h,vc,this$=this;this.inited=true;ref$=document.hidden!=null?["hidden","visibilitychange"]:document.msHidden!=null?["hidden","visibilitychange"]:document.webkiHidden!=null?["webkitHidden","webkitvisibilitychange"]:["hidden","visibilitychange"],h=ref$[0],vc=ref$[1];return document.addEventListener(vc,debounce(150,function(){var th;th=!!document[h];return this$.list.map(function(it){return it.throttle(th)})},false))},add:function(aniloop){if(!this.inited){this.init()}return this.list.push(aniloop)}};resizeObserver={wm:new WeakMap,ro:new ResizeObserver(function(list){return list.map(function(n){var ret;ret=resizeObserver.wm.get(n.target);return ret._resize()})}),add:function(node,obj){this.wm.set(node,obj);return this.ro.observe(node)},delete:function(it){this.ro.unobserve(it);return this.wm["delete"](it)}};withDefault=function(cfg,defcfg){var _;cfg==null&&(cfg={});defcfg==null&&(defcfg={});defcfg=JSON.parse(JSON.stringify(defcfg));_=function(cfg,defcfg){var k,v;for(k in defcfg){v=defcfg[k];if(!(cfg[k]!=null)){cfg[k]=v}else if(typeof cfg[k]==="object"&&typeof v==="object"){withDefault(cfg[k],defcfg[k])}}return cfg};return _(cfg,defcfg)};defaultConfig=function(cfg){var _;_=function(meta,ret){var ctrls,that,id,v;ret==null&&(ret={});ctrls=(that=meta.child)?that:meta;for(id in meta){v=meta[id];if(!v.type){_(v,ret[id]||(ret[id]={}))}else if(v["default"]){ret[id]=v["default"]}}return ret};return _(cfg)};chart=function(opt){var this$=this;opt==null&&(opt={});this.root=typeof opt.root==="string"?document.querySelector(opt.root):opt.root;this.useSample=opt.useSample!=null?opt.useSample:true;this.autoSelect=opt.autoSelect!=null?opt.autoSelect:true;this.forceInit=opt.forceInit?opt.forceInit:false;this.prepareSvg=opt.prepareSvg!=null?opt.prepareSvg:true;this.layoutOpt=opt.layout!=null?opt.layout:true;this.delayRender=opt.delayRender||false;this.dataAccessor=opt.dataAccessor!=null?opt.dataAccessor:function(it){if(it){return it.data._raw}else{return null}};this.raw=opt.raw||null;this.mod=opt.mod||{};this.cfg=opt.config||{};this.seed=opt.seed||Math.random();this.binding=opt.binding||{};this.evtHandler={};this.init=proxise.once(function(){return this$._init()});this._resize=null;if(this.autoSelect){this.root.addEventListener("click",this._select=function(e){var p;if(!(p=parent(e.target,".data",this$.root))){return}return this$.fire("select",[{data:this$.dataAccessor(p),node:p}])});this.root.addEventListener("mouseover",this._hover=function(e){var p;if(!(p=ld$.parent(e.target,".data",this$.root))){return}return this$.fire("hover",[{data:this$.dataAccessor(p),node:p}])})}return this};chart.prototype=import$(Object.create(Object.prototype),{_init:function(){var layoutRoot,ref$,r,p,this$=this;if(window.getComputedStyle(this.root).position==="static"){this.root.style.position="relative"}layoutRoot=this.layoutOpt?typeof this.layoutOpt!=="object"?this.root.querySelector(".pdl-layout"):typeof this.layoutOpt.root==="string"?this.root.querySelector(this.layoutOpt.root):this.layoutOpt.root?this.layoutOpt.root:null:null;if(this.prepareSvg&&!(this.svg=this.root.querySelector("svg"))){this.svg=document.createElementNS(svgns,"svg");ref$=this.svg.style;ref$.width="100%";ref$.height="100%";if(this.layoutOpt){if(!layoutRoot){console.error("[@plotdb/chart] layout enabled yet layout root isn't configured properly. ")}r=layoutRoot.querySelector("[data-type=render]");if(!r){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.")}}(r||this.root).appendChild(this.svg)}this._aniloop=new aniloop;visibilityObserver.add(this._aniloop);this._aniloop.on("tick",function(){return this$.tick()});return p=Promise.resolve().then(function(){var ref$;if(this$.raw&&Array.isArray(this$.raw)){return}if(this$.useSample){this$.raw=(ref$=this$.mod.sample?this$.mod.sample()||{}:{}).raw;this$.binding=ref$.binding}if(!this$.raw){return this$.raw=[]}}).then(function(){var defcfg,ref$,_resizeLock;defcfg=defaultConfig(this$.mod.config||{});withDefault(this$.cfg,defcfg);if(this$.layoutOpt){if(!(typeof layout!="undefined"&&layout!==null)){console.warn("[@plotdb/chart] layout-opt is set yet @plotdb/layout is not found.")}else{if(!layoutRoot){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")}this$.layout=new layout(typeof this$.layoutOpt==="object"?(ref$=import$({},this$.layoutOpt),ref$.watchResize=false,ref$):{root:layoutRoot,watchResize:false})}}_resizeLock=proxise(function(){resizeObserver.add(this$.root,this$);return null});if(this$.forceInit&&!this$.root.offsetParent||window.getComputedStyle(this$.root).display==="none"){return}this$._resize=function(){return _resizeLock.resolve()};return _resizeLock()}).then(function(){return this$._resize=function(){}}).then(function(){var init,layoutLock;init=function(){if(this$.mod.init){return this$.mod.init.apply(this$)}};if(!this$.layout){return init()}layoutLock=proxise(function(){Promise.resolve(this$.layout.init(init));return null});this$._layout=function(){return layoutLock.resolve()};this$.layout.on("render",function(){return this$._layout()});return layoutLock()}).then(function(){this$._layout=function(){};Promise.resolve().then(function(){if(!this$.delayRender){return}this$.renderLock=proxise(function(){});return this$.renderLock()}).then(function(){this$._resize=function(){this$.resize();return this$.render()};this$._layout=function(){this$.parse();this$.bind();this$.resize();return this$.render()};this$.parse();this$.bind();this$.resize();return this$.render()})})},parse:function(){var this$=this;this.data=this.raw.map(function(r,i){var ret,k,v;ret={};(function(){var ref$,results$=[];for(k in ref$=this.binding){v=ref$[k];results$.push({k:k,v:v})}return results$}).call(this$).map(function(arg$){var k,v,ref$,ref1$,t;k=arg$.k,v=arg$.v;if(!v){return}ret[k]=((ref$=(ref1$=this$.mod).dimension||(ref1$.dimension={}))[k]||(ref$[k]={})).multiple?v.map(function(it){return r[it.key]}):r[v.key];t=((ref$=(ref1$=this$.mod).dimension||(ref1$.dimension={}))[k]||(ref$[k]={})).type;if(/[RIT]/.exec(t)&&!/[CN]/.exec(t)){return ret[k]=Array.isArray(ret[k])?ret[k].map(function(it){return parseFloat(it)}):parseFloat(ret[k])}});ret._raw=r;ret._idx=i;return ret});if(this.mod.parse){return this.mod.parse.apply(this)}},bind:function(){if(this.mod.bind){return this.mod.bind.apply(this)}},start:function(){this._aniloop.run();if(this.mod.start){return this.mod.start.apply(this)}},stop:function(){this._aniloop.pause();if(this.mod.stop){return this.mod.stop.apply(this)}},resize:function(){if(this.layout){this.layout.update(false)}this.box=this.root.getBoundingClientRect();if(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 this$=this;return Promise.resolve().then(function(){if(this$._select){this$.root.removeEventListener("click",this$._select)}if(this$._hover){this$.root.removeEventListener("mouseover",this$._hover)}resizeObserver["delete"](this$.root);if(this$.layout){this$.layout.destroy()}this$.stop();if(this$.mod.destroy){return this$.mod.destroy.apply(this$)}})},config:function(opt){if(!(opt!=null&&opt)){return this.cfg}return import$(this.cfg,opt)},setBind:function(n,b){this.binding[n]=b;this.parse();this.bind();this.resize();return this.render()},setRaw:function(raw,binding,reinit){var ref$;reinit==null&&(reinit=false);if(!Array.isArray(raw)){ref$=raw,raw=ref$.raw,binding=ref$.binding,reinit=ref$.reinit}if(raw!=null){this.raw=raw}if(binding!=null){this.binding=binding}if(this.renderLock){this.renderLock.resolve();return this.renderLock=null}else{if(reinit&&this.mod.init){this.mod.init.apply(this)}this.parse();this.bind();this.resize();return this.render()}},on:function(n,cb){var this$=this;return(Array.isArray(n)?n:[n]).map(function(n){var ref$;return((ref$=this$.evtHandler)[n]||(ref$[n]=[])).push(cb)})},fire:function(n){var v,res$,i$,to$,ref$,len$,cb,results$=[];res$=[];for(i$=1,to$=arguments.length;i$<to$;++i$){res$.push(arguments[i$])}v=res$;for(i$=0,len$=(ref$=this.evtHandler[n]||[]).length;i$<len$;++i$){cb=ref$[i$];results$.push(cb.apply(this,v))}return results$},filter:function(filters,internal){var bs,k,ref$,v,u;filters==null&&(filters={});internal==null&&(internal=false);bs=[];for(k in ref$=this.binding){v=ref$[k];u=Array.isArray(v)?v:[v];u=u.map(fn$);bs=bs.concat(u)}for(k in filters){v=filters[k];bs.filter(fn1$).map(fn2$)}if(internal){this.fire("filter",filters)}if(this.mod.filter){this.mod.filter.apply(this,[filters,internal])}this.parse();this.bind();this.resize();return this.render();function fn$(v){return{k:k,v:v}}function fn1$(it){return it.k===k}function fn2$(it){return it.v.filter=v}}});if(typeof module!="undefined"&&module!==null){module.exports=chart}else if(typeof window!="undefined"&&window!==null){window.chart=chart}function import$(obj,src){var own={}.hasOwnProperty;for(var key in src)if(own.call(src,key))obj[key]=src[key];return obj}}).call(this);
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
(function(){
|
|
2
|
+
var randFname, generate;
|
|
3
|
+
randFname = function(){
|
|
4
|
+
return "...";
|
|
5
|
+
};
|
|
6
|
+
generate = function(count, binding){
|
|
7
|
+
var gen, fields, idx, k, v, u, keys, i$, i, ret, hint, name, value, range;
|
|
8
|
+
gen = {
|
|
9
|
+
raw: [],
|
|
10
|
+
binding: {}
|
|
11
|
+
};
|
|
12
|
+
fields = {};
|
|
13
|
+
idx = 0;
|
|
14
|
+
for (k in binding) {
|
|
15
|
+
v = binding[k];
|
|
16
|
+
u = Array.isArray(v)
|
|
17
|
+
? v
|
|
18
|
+
: [v];
|
|
19
|
+
keys = u.map(fn$);
|
|
20
|
+
if (Array.isArray(v)) {
|
|
21
|
+
gen.binding[k] = keys.map(fn1$);
|
|
22
|
+
} else {
|
|
23
|
+
gen.binding[k] = {
|
|
24
|
+
key: fields[keys[0]].key
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
for (i$ = 0; i$ < count; ++i$) {
|
|
29
|
+
i = i$;
|
|
30
|
+
for (k in fields) {
|
|
31
|
+
v = fields[k];
|
|
32
|
+
ret = {};
|
|
33
|
+
hint = v.hint;
|
|
34
|
+
name = v.key;
|
|
35
|
+
value = "...";
|
|
36
|
+
switch (hint.type) {
|
|
37
|
+
case 'R':
|
|
38
|
+
range = hint.range || [0, 1];
|
|
39
|
+
value = Math.round(Math.random() * (range[1] - range[0]) + range[0]);
|
|
40
|
+
break;
|
|
41
|
+
case 'N':
|
|
42
|
+
value = ['A', 'B', 'C', 'D', 'E'][Math.floor(Math.random() * 5)];
|
|
43
|
+
}
|
|
44
|
+
ret[v.key] = value;
|
|
45
|
+
}
|
|
46
|
+
gen.raw.push(ret);
|
|
47
|
+
}
|
|
48
|
+
return gen;
|
|
49
|
+
function fn$(it){
|
|
50
|
+
fields[idx] = {
|
|
51
|
+
key: randFname(),
|
|
52
|
+
hint: it
|
|
53
|
+
};
|
|
54
|
+
return idx++;
|
|
55
|
+
}
|
|
56
|
+
function fn1$(it){
|
|
57
|
+
return {
|
|
58
|
+
key: fields[it].key
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
};
|
|
62
|
+
generate(10, {
|
|
63
|
+
height: [0, 1, 2, 3].map(function(){
|
|
64
|
+
return {
|
|
65
|
+
type: 'R',
|
|
66
|
+
range: [0, 10]
|
|
67
|
+
};
|
|
68
|
+
}),
|
|
69
|
+
name: {
|
|
70
|
+
type: 'N'
|
|
71
|
+
}
|
|
72
|
+
});
|
|
73
|
+
}).call(this);
|
|
@@ -0,0 +1,357 @@
|
|
|
1
|
+
(function(){
|
|
2
|
+
var ceNS, axis;
|
|
3
|
+
ceNS = function(it){
|
|
4
|
+
return document.createElementNS("http://www.w3.org/2000/svg", it);
|
|
5
|
+
};
|
|
6
|
+
axis = function(opt){
|
|
7
|
+
var n, x$, y$, this$ = this;
|
|
8
|
+
opt == null && (opt = {});
|
|
9
|
+
this.dir = {
|
|
10
|
+
"bottom": 0,
|
|
11
|
+
"left": 2
|
|
12
|
+
}[opt.direction || 'bottom'];
|
|
13
|
+
this.name = opt.name || 'axis';
|
|
14
|
+
this.layout = opt.layout || new layout({
|
|
15
|
+
root: this.root
|
|
16
|
+
});
|
|
17
|
+
this._ticks = [];
|
|
18
|
+
this._scale = opt.scale || function(it){
|
|
19
|
+
return it;
|
|
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);
|
|
29
|
+
this._map = {};
|
|
30
|
+
this._n = n = {
|
|
31
|
+
root: ceNS('g'),
|
|
32
|
+
layout: this.layout.getNode(this.name),
|
|
33
|
+
render: this.layout.getGroup(this.name),
|
|
34
|
+
wrap: null,
|
|
35
|
+
domain: ceNS('path')
|
|
36
|
+
};
|
|
37
|
+
n.render.appendChild(n.root);
|
|
38
|
+
n.root.appendChild(n.domain);
|
|
39
|
+
n.label = ceNS('text');
|
|
40
|
+
n.label.textContent = '';
|
|
41
|
+
x$ = n.label;
|
|
42
|
+
x$.setAttribute('dominant-baseline', 'hanging');
|
|
43
|
+
x$.setAttribute('text-anchor', 'middle');
|
|
44
|
+
n.root.appendChild(n.label);
|
|
45
|
+
this.wrapper();
|
|
46
|
+
y$ = this.layout;
|
|
47
|
+
y$.on('update', function(){
|
|
48
|
+
return this$.update();
|
|
49
|
+
});
|
|
50
|
+
y$.on('render', function(){
|
|
51
|
+
return this$.render();
|
|
52
|
+
});
|
|
53
|
+
return this;
|
|
54
|
+
};
|
|
55
|
+
axis.prototype = import$(Object.create(Object.prototype), {
|
|
56
|
+
wrapper: function(){
|
|
57
|
+
var n, ref$;
|
|
58
|
+
n = this._n;
|
|
59
|
+
if (n.wrap && n.wrap.parentNode) {
|
|
60
|
+
n.wrap.parentNode.removeChild(n.wrap);
|
|
61
|
+
}
|
|
62
|
+
n.wrap = document.createElement('div');
|
|
63
|
+
import$((ref$ = n.wrap.style, ref$.visibility = 'hidden', ref$.position = 'absolute', ref$.top = 0, ref$.left = 0, ref$.pointerEvents = 'none', ref$.userSelect = 'none', ref$.zIndex = 0, ref$.wordBreak = "break-all", ref$.lineHeight = '.95em', ref$), this.dir < 2 && this.cfg.textWidth != null
|
|
64
|
+
? {
|
|
65
|
+
whiteSpace: 'wrap',
|
|
66
|
+
width: ((ref$ = this.cfg.textWidth) > 1 ? ref$ : 1) + "em"
|
|
67
|
+
}
|
|
68
|
+
: {
|
|
69
|
+
whiteSpace: 'pre',
|
|
70
|
+
width: '4em'
|
|
71
|
+
});
|
|
72
|
+
return n.layout.appendChild(n.wrap);
|
|
73
|
+
},
|
|
74
|
+
config: function(it){
|
|
75
|
+
if (!(it != null)) {
|
|
76
|
+
return this.cfg;
|
|
77
|
+
}
|
|
78
|
+
import$(this.cfg, it);
|
|
79
|
+
if (this.cfg.format) {
|
|
80
|
+
this.format(this.cfg.format);
|
|
81
|
+
}
|
|
82
|
+
return this.wrapper();
|
|
83
|
+
},
|
|
84
|
+
format: function(it){
|
|
85
|
+
if (it != null) {
|
|
86
|
+
return this._format = it;
|
|
87
|
+
} else {
|
|
88
|
+
return this._format;
|
|
89
|
+
}
|
|
90
|
+
},
|
|
91
|
+
scale: function(it){
|
|
92
|
+
if (it != null) {
|
|
93
|
+
return this._scale = it;
|
|
94
|
+
} else {
|
|
95
|
+
return this._scale;
|
|
96
|
+
}
|
|
97
|
+
},
|
|
98
|
+
caption: function(it){
|
|
99
|
+
if (this.cfg.showCaption != null && !this.cfg.showCaption) {
|
|
100
|
+
return this._n.label.textContent = '';
|
|
101
|
+
} else {
|
|
102
|
+
return this._n.label.textContent = it;
|
|
103
|
+
}
|
|
104
|
+
},
|
|
105
|
+
update: function(){},
|
|
106
|
+
ticks: function(ticks){
|
|
107
|
+
/* (v)alue -> (c)oordinate -> (t)ext -> (n)odes: { g(group), p(path), t(text) } */
|
|
108
|
+
var map, size, count, itr, ref$, k, v, this$ = this;
|
|
109
|
+
map = {};
|
|
110
|
+
size = this._n.layout.getBoundingClientRect()[this.dir < 2 ? 'width' : 'height'];
|
|
111
|
+
count = Math.round(size / 25);
|
|
112
|
+
itr = (ref$ = Math.round(ticks.length / (count > 1 ? count : 1))) > 1 ? ref$ : 1;
|
|
113
|
+
this._ticks = ticks.filter(function(d, i){
|
|
114
|
+
return !(i % itr) || i === ticks.length - 1;
|
|
115
|
+
}).map(function(o){
|
|
116
|
+
var ref$, key$;
|
|
117
|
+
if (typeof o !== 'object') {
|
|
118
|
+
o = {
|
|
119
|
+
v: o
|
|
120
|
+
};
|
|
121
|
+
}
|
|
122
|
+
return map[o.v] = import$((ref$ = this$._map)[key$ = o.v] || (ref$[key$] = {}), o);
|
|
123
|
+
});
|
|
124
|
+
for (k in ref$ = this._map) {
|
|
125
|
+
v = ref$[k];
|
|
126
|
+
if (!map[k]) {
|
|
127
|
+
v.n.g.parentNode.removeChild(v.n.g);
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
this._map = map;
|
|
131
|
+
return this._ticks.filter(function(o){
|
|
132
|
+
return !o.n;
|
|
133
|
+
}).map(function(o){
|
|
134
|
+
o.n = {
|
|
135
|
+
g: ceNS('g'),
|
|
136
|
+
p: ceNS('path'),
|
|
137
|
+
t: ceNS('g')
|
|
138
|
+
};
|
|
139
|
+
o.n.g.appendChild(o.n.p);
|
|
140
|
+
o.n.g.appendChild(o.n.t);
|
|
141
|
+
this$._n.root.appendChild(o.n.g);
|
|
142
|
+
if (isNaN(+o.v)) {
|
|
143
|
+
return o.t = o.v;
|
|
144
|
+
}
|
|
145
|
+
});
|
|
146
|
+
},
|
|
147
|
+
render: function(){
|
|
148
|
+
var n, isHorizon, wrap, ticks, ref$, fontSize, box, this$ = this;
|
|
149
|
+
n = this._n;
|
|
150
|
+
isHorizon = this.dir < 2;
|
|
151
|
+
wrap = n.wrap;
|
|
152
|
+
ticks = this._ticks;
|
|
153
|
+
if (this.cfg.enabled != null && !this.cfg.enabled) {
|
|
154
|
+
if (isHorizon) {
|
|
155
|
+
ref$ = n.layout.style;
|
|
156
|
+
ref$.height = "0px";
|
|
157
|
+
ref$.paddingTop = "0";
|
|
158
|
+
ref$.paddingBottom = "0";
|
|
159
|
+
} else {
|
|
160
|
+
ref$ = n.layout.style;
|
|
161
|
+
ref$.width = "0px";
|
|
162
|
+
ref$.paddingLeft = "0";
|
|
163
|
+
ref$.paddingRight = "0";
|
|
164
|
+
}
|
|
165
|
+
n.domain.style.display = 'none';
|
|
166
|
+
return;
|
|
167
|
+
} else {
|
|
168
|
+
if (isHorizon) {
|
|
169
|
+
ref$ = n.layout.style;
|
|
170
|
+
ref$.height = "";
|
|
171
|
+
ref$.paddingTop = "";
|
|
172
|
+
ref$.paddingBottom = "";
|
|
173
|
+
} else {
|
|
174
|
+
ref$ = n.layout.style;
|
|
175
|
+
ref$.width = "";
|
|
176
|
+
ref$.paddingLeft = "";
|
|
177
|
+
ref$.paddingRight = "";
|
|
178
|
+
}
|
|
179
|
+
n.domain.style.display = '';
|
|
180
|
+
}
|
|
181
|
+
fontSize = getComputedStyle(wrap).fontSize;
|
|
182
|
+
box = n.layout.getBoundingClientRect();
|
|
183
|
+
ref$ = n.domain.style;
|
|
184
|
+
ref$.strokeWidth = 1;
|
|
185
|
+
ref$.stroke = 'currentColor';
|
|
186
|
+
ref$.fill = 'none';
|
|
187
|
+
ticks.map(function(o, idx){
|
|
188
|
+
var pos, ref$;
|
|
189
|
+
pos = !idx
|
|
190
|
+
? 0
|
|
191
|
+
: idx === ticks.length - 1 ? 2 : 1;
|
|
192
|
+
o._c = o.c != null
|
|
193
|
+
? o.c
|
|
194
|
+
: this$._scale(o.v) + (this$._scale.bandwidth ? this$._scale.bandwidth() / 2 : 0);
|
|
195
|
+
o._t = o.t != null
|
|
196
|
+
? o.t
|
|
197
|
+
: this$._format(o.v);
|
|
198
|
+
ref$ = o.n.p.style;
|
|
199
|
+
ref$.strokeWidth = 1;
|
|
200
|
+
ref$.stroke = 'currentColor';
|
|
201
|
+
ref$.fill = 'none';
|
|
202
|
+
wrap.textContent = o._t;
|
|
203
|
+
wrap.style.textAlign = isHorizon
|
|
204
|
+
? ['left', 'center', 'right'][pos]
|
|
205
|
+
: ['right', 'left'][this$.dir - 2];
|
|
206
|
+
o.n.tt = wrapSvgText({
|
|
207
|
+
node: wrap
|
|
208
|
+
});
|
|
209
|
+
o.n.t.style.fontSize = fontSize;
|
|
210
|
+
o.n.t.textContent = '';
|
|
211
|
+
return o.n.t.appendChild(o.n.tt);
|
|
212
|
+
});
|
|
213
|
+
ticks.sort(function(a, b){
|
|
214
|
+
return a._c - b._c;
|
|
215
|
+
});
|
|
216
|
+
if (isHorizon) {
|
|
217
|
+
n.domain.setAttribute('d', "M0 0L" + box.width + " 0Z");
|
|
218
|
+
n.label.setAttribute('x', box.width / 2);
|
|
219
|
+
} else {
|
|
220
|
+
n.domain.setAttribute('d', "M0 0L0 " + box.height + "Z");
|
|
221
|
+
n.label.setAttribute("transform", "translate(0," + box.height / 2 + ") rotate(90)");
|
|
222
|
+
}
|
|
223
|
+
ticks.map(function(o){
|
|
224
|
+
return o.box = o.n.t.getBBox();
|
|
225
|
+
});
|
|
226
|
+
return this.adjust();
|
|
227
|
+
},
|
|
228
|
+
adjust: function(){
|
|
229
|
+
var ticks, isHorizon, insert, bfs, this$ = this;
|
|
230
|
+
ticks = this._ticks;
|
|
231
|
+
isHorizon = this.dir < 2;
|
|
232
|
+
insert = function(idx, lv, lc){
|
|
233
|
+
var tick, pos, ref$, coord, text, box, offset, doOffset, r, m, ip1, ip2, op1, op2, overlap;
|
|
234
|
+
if (lc.checked[idx]) {
|
|
235
|
+
return;
|
|
236
|
+
} else {
|
|
237
|
+
lc.checked[idx] = true;
|
|
238
|
+
}
|
|
239
|
+
tick = ticks[idx];
|
|
240
|
+
pos = !idx
|
|
241
|
+
? 0
|
|
242
|
+
: idx === ticks.length - 1 ? 2 : 1;
|
|
243
|
+
ref$ = [tick._c, tick._t], coord = ref$[0], text = ref$[1];
|
|
244
|
+
box = tick.box;
|
|
245
|
+
offset = {
|
|
246
|
+
x: -box.x,
|
|
247
|
+
y: -box.y
|
|
248
|
+
};
|
|
249
|
+
doOffset = this$._scale.bandwidth
|
|
250
|
+
? false
|
|
251
|
+
: this$.cfg.boundaryTickOffset != null
|
|
252
|
+
? !!this$.cfg.boundaryTickOffset
|
|
253
|
+
: this$.dir < 2 ? true : false;
|
|
254
|
+
r = doOffset
|
|
255
|
+
? pos / 2
|
|
256
|
+
: 1 / 2;
|
|
257
|
+
if (isHorizon) {
|
|
258
|
+
offset.x -= box.width * r;
|
|
259
|
+
} else {
|
|
260
|
+
offset.y -= box.height * r;
|
|
261
|
+
}
|
|
262
|
+
tick.n.tt.setAttribute('transform', "translate(" + offset.x + "," + offset.y + ")");
|
|
263
|
+
box = {
|
|
264
|
+
size: box[isHorizon ? 'width' : 'height'],
|
|
265
|
+
sizeAlt: box[isHorizon ? 'height' : 'width'],
|
|
266
|
+
lv: lv,
|
|
267
|
+
tick: tick,
|
|
268
|
+
idx: idx
|
|
269
|
+
};
|
|
270
|
+
box.coord = coord - box.size * r;
|
|
271
|
+
if (isHorizon) {
|
|
272
|
+
tick.n.g.setAttribute('transform', "translate(" + coord + ",0)");
|
|
273
|
+
tick.n.p.setAttribute('d', "M0 0L0 " + this$.cfg.tickSize);
|
|
274
|
+
tick.n.t.setAttribute('transform', "translate(0," + this$.cfg.tickSize + ")");
|
|
275
|
+
} else {
|
|
276
|
+
tick.n.g.setAttribute('transform', "translate(0," + coord + ")");
|
|
277
|
+
tick.n.p.setAttribute('d', "M0 0L-" + this$.cfg.tickSize + " 0");
|
|
278
|
+
tick.n.t.setAttribute('transform', "translate(" + (-this$.cfg.tickSize - box.sizeAlt - 1) + ",0)");
|
|
279
|
+
}
|
|
280
|
+
m = 2;
|
|
281
|
+
ref$ = [box.coord, box.coord + box.size], ip1 = ref$[0], ip2 = ref$[1];
|
|
282
|
+
ref$ = [ip1 - m, ip2 + m], op1 = ref$[0], op2 = ref$[1];
|
|
283
|
+
overlap = lc.picked.filter(function(b){
|
|
284
|
+
var ref$, iq1, iq2, oq1, oq2;
|
|
285
|
+
ref$ = [b.coord, b.coord + b.size], iq1 = ref$[0], iq2 = ref$[1];
|
|
286
|
+
ref$ = [iq1 - m, iq2 + m], oq1 = ref$[0], oq2 = ref$[1];
|
|
287
|
+
return (ip1 > oq1 && ip1 < oq2) || (iq1 > op1 && iq1 < op2);
|
|
288
|
+
}).length;
|
|
289
|
+
tick.n.t.style.opacity = overlap ? 0 : 1;
|
|
290
|
+
lc.picked.push(box);
|
|
291
|
+
return !overlap;
|
|
292
|
+
};
|
|
293
|
+
bfs = function(maxlv){
|
|
294
|
+
var ref$, lc, fifo, L, R, D, M, size, box;
|
|
295
|
+
maxlv == null && (maxlv = 1);
|
|
296
|
+
ref$ = [
|
|
297
|
+
{
|
|
298
|
+
checked: {},
|
|
299
|
+
picked: [],
|
|
300
|
+
node: this$._n.wrap
|
|
301
|
+
}, []
|
|
302
|
+
], lc = ref$[0], fifo = ref$[1];
|
|
303
|
+
lc.fontSize = getComputedStyle(lc.node).fontSize;
|
|
304
|
+
ticks.map(function(it){
|
|
305
|
+
return it.n.t.style.opacity = 0;
|
|
306
|
+
});
|
|
307
|
+
if (ticks.length) {
|
|
308
|
+
fifo.push([0, ticks.length - 1, 0]);
|
|
309
|
+
[0, ticks.length - 1].map(function(it){
|
|
310
|
+
return insert(it, 0, lc);
|
|
311
|
+
});
|
|
312
|
+
}
|
|
313
|
+
while (fifo.length) {
|
|
314
|
+
ref$ = fifo.splice(0, 1)[0], L = ref$[0], R = ref$[1], D = ref$[2];
|
|
315
|
+
if (D >= maxlv) {
|
|
316
|
+
continue;
|
|
317
|
+
}
|
|
318
|
+
M = Math.floor((L + R) / 2);
|
|
319
|
+
insert(M, D, lc);
|
|
320
|
+
if (M > L + 1) {
|
|
321
|
+
fifo.push([L, M, D + 1]);
|
|
322
|
+
}
|
|
323
|
+
if (R > M + 1) {
|
|
324
|
+
fifo.push([M, R, D + 1]);
|
|
325
|
+
}
|
|
326
|
+
}
|
|
327
|
+
/* align lv
|
|
328
|
+
lc.picked.map -> if it.lv >= maxlv => it.tick.n.t.style.opacity = 0
|
|
329
|
+
lc.picked = lc.picked.filter -> it.lv < maxlv
|
|
330
|
+
*/
|
|
331
|
+
size = Math.max.apply(Math, [0].concat(lc.picked.map(function(it){
|
|
332
|
+
return it.sizeAlt;
|
|
333
|
+
})));
|
|
334
|
+
if (this$.dir < 2) {
|
|
335
|
+
this$._n.label.setAttribute('y', size + this$.cfg.tickSize);
|
|
336
|
+
return this$._n.layout.style.height = (size + this$.cfg.tickSize + this$._n.label.getBoundingClientRect().height) + "px";
|
|
337
|
+
} else {
|
|
338
|
+
this$._n.label.setAttribute('x', 0);
|
|
339
|
+
this$._n.label.setAttribute('y', 0);
|
|
340
|
+
this$._n.layout.style.width = (size + this$.cfg.tickSize + this$._n.label.getBoundingClientRect().width) + "px";
|
|
341
|
+
box = this$._n.layout.getBoundingClientRect();
|
|
342
|
+
this$._n.label.setAttribute('transform', "translate(" + (-(size + this$.cfg.tickSize)) + "," + box.height / 2 + ") rotate(90)");
|
|
343
|
+
return this$._n.root.setAttribute('transform', "translate(" + box.width + ",0)");
|
|
344
|
+
}
|
|
345
|
+
};
|
|
346
|
+
return bfs(5);
|
|
347
|
+
}
|
|
348
|
+
});
|
|
349
|
+
if (typeof chart != 'undefined' && chart !== null) {
|
|
350
|
+
(chart.utils || (chart.utils = {})).axis = axis;
|
|
351
|
+
}
|
|
352
|
+
function import$(obj, src){
|
|
353
|
+
var own = {}.hasOwnProperty;
|
|
354
|
+
for (var key in src) if (own.call(src, key)) obj[key] = src[key];
|
|
355
|
+
return obj;
|
|
356
|
+
}
|
|
357
|
+
}).call(this);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
(function(){var ceNS,axis;ceNS=function(it){return document.createElementNS("http://www.w3.org/2000/svg",it)};axis=function(opt){var n,x$,y$,this$=this;opt==null&&(opt={});this.dir={bottom:0,left:2}[opt.direction||"bottom"];this.name=opt.name||"axis";this.layout=opt.layout||new layout({root:this.root});this._ticks=[];this._scale=opt.scale||function(it){return it};this._format=opt.format||(typeof chart!="undefined"&&chart!==null?chart.utils.format.simple:function(it){return it});this.cfg=import$({tickSize:8},opt.cfg);this._map={};this._n=n={root:ceNS("g"),layout:this.layout.getNode(this.name),render:this.layout.getGroup(this.name),wrap:null,domain:ceNS("path")};n.render.appendChild(n.root);n.root.appendChild(n.domain);n.label=ceNS("text");n.label.textContent="";x$=n.label;x$.setAttribute("dominant-baseline","hanging");x$.setAttribute("text-anchor","middle");n.root.appendChild(n.label);this.wrapper();y$=this.layout;y$.on("update",function(){return this$.update()});y$.on("render",function(){return this$.render()});return this};axis.prototype=import$(Object.create(Object.prototype),{wrapper:function(){var n,ref$;n=this._n;if(n.wrap&&n.wrap.parentNode){n.wrap.parentNode.removeChild(n.wrap)}n.wrap=document.createElement("div");import$((ref$=n.wrap.style,ref$.visibility="hidden",ref$.position="absolute",ref$.top=0,ref$.left=0,ref$.pointerEvents="none",ref$.userSelect="none",ref$.zIndex=0,ref$.wordBreak="break-all",ref$.lineHeight=".95em",ref$),this.dir<2&&this.cfg.textWidth!=null?{whiteSpace:"wrap",width:((ref$=this.cfg.textWidth)>1?ref$:1)+"em"}:{whiteSpace:"pre",width:"4em"});return n.layout.appendChild(n.wrap)},config:function(it){if(!(it!=null)){return this.cfg}import$(this.cfg,it);if(this.cfg.format){this.format(this.cfg.format)}return this.wrapper()},format:function(it){if(it!=null){return this._format=it}else{return this._format}},scale:function(it){if(it!=null){return this._scale=it}else{return this._scale}},caption:function(it){if(this.cfg.showCaption!=null&&!this.cfg.showCaption){return this._n.label.textContent=""}else{return this._n.label.textContent=it}},update:function(){},ticks:function(ticks){var map,size,count,itr,ref$,k,v,this$=this;map={};size=this._n.layout.getBoundingClientRect()[this.dir<2?"width":"height"];count=Math.round(size/25);itr=(ref$=Math.round(ticks.length/(count>1?count:1)))>1?ref$:1;this._ticks=ticks.filter(function(d,i){return!(i%itr)||i===ticks.length-1}).map(function(o){var ref$,key$;if(typeof o!=="object"){o={v:o}}return map[o.v]=import$((ref$=this$._map)[key$=o.v]||(ref$[key$]={}),o)});for(k in ref$=this._map){v=ref$[k];if(!map[k]){v.n.g.parentNode.removeChild(v.n.g)}}this._map=map;return this._ticks.filter(function(o){return!o.n}).map(function(o){o.n={g:ceNS("g"),p:ceNS("path"),t:ceNS("g")};o.n.g.appendChild(o.n.p);o.n.g.appendChild(o.n.t);this$._n.root.appendChild(o.n.g);if(isNaN(+o.v)){return o.t=o.v}})},render:function(){var n,isHorizon,wrap,ticks,ref$,fontSize,box,this$=this;n=this._n;isHorizon=this.dir<2;wrap=n.wrap;ticks=this._ticks;if(this.cfg.enabled!=null&&!this.cfg.enabled){if(isHorizon){ref$=n.layout.style;ref$.height="0px";ref$.paddingTop="0";ref$.paddingBottom="0"}else{ref$=n.layout.style;ref$.width="0px";ref$.paddingLeft="0";ref$.paddingRight="0"}n.domain.style.display="none";return}else{if(isHorizon){ref$=n.layout.style;ref$.height="";ref$.paddingTop="";ref$.paddingBottom=""}else{ref$=n.layout.style;ref$.width="";ref$.paddingLeft="";ref$.paddingRight=""}n.domain.style.display=""}fontSize=getComputedStyle(wrap).fontSize;box=n.layout.getBoundingClientRect();ref$=n.domain.style;ref$.strokeWidth=1;ref$.stroke="currentColor";ref$.fill="none";ticks.map(function(o,idx){var pos,ref$;pos=!idx?0:idx===ticks.length-1?2:1;o._c=o.c!=null?o.c:this$._scale(o.v)+(this$._scale.bandwidth?this$._scale.bandwidth()/2:0);o._t=o.t!=null?o.t:this$._format(o.v);ref$=o.n.p.style;ref$.strokeWidth=1;ref$.stroke="currentColor";ref$.fill="none";wrap.textContent=o._t;wrap.style.textAlign=isHorizon?["left","center","right"][pos]:["right","left"][this$.dir-2];o.n.tt=wrapSvgText({node:wrap});o.n.t.style.fontSize=fontSize;o.n.t.textContent="";return o.n.t.appendChild(o.n.tt)});ticks.sort(function(a,b){return a._c-b._c});if(isHorizon){n.domain.setAttribute("d","M0 0L"+box.width+" 0Z");n.label.setAttribute("x",box.width/2)}else{n.domain.setAttribute("d","M0 0L0 "+box.height+"Z");n.label.setAttribute("transform","translate(0,"+box.height/2+") rotate(90)")}ticks.map(function(o){return o.box=o.n.t.getBBox()});return this.adjust()},adjust:function(){var ticks,isHorizon,insert,bfs,this$=this;ticks=this._ticks;isHorizon=this.dir<2;insert=function(idx,lv,lc){var tick,pos,ref$,coord,text,box,offset,doOffset,r,m,ip1,ip2,op1,op2,overlap;if(lc.checked[idx]){return}else{lc.checked[idx]=true}tick=ticks[idx];pos=!idx?0:idx===ticks.length-1?2:1;ref$=[tick._c,tick._t],coord=ref$[0],text=ref$[1];box=tick.box;offset={x:-box.x,y:-box.y};doOffset=this$._scale.bandwidth?false:this$.cfg.boundaryTickOffset!=null?!!this$.cfg.boundaryTickOffset:this$.dir<2?true:false;r=doOffset?pos/2:1/2;if(isHorizon){offset.x-=box.width*r}else{offset.y-=box.height*r}tick.n.tt.setAttribute("transform","translate("+offset.x+","+offset.y+")");box={size:box[isHorizon?"width":"height"],sizeAlt:box[isHorizon?"height":"width"],lv:lv,tick:tick,idx:idx};box.coord=coord-box.size*r;if(isHorizon){tick.n.g.setAttribute("transform","translate("+coord+",0)");tick.n.p.setAttribute("d","M0 0L0 "+this$.cfg.tickSize);tick.n.t.setAttribute("transform","translate(0,"+this$.cfg.tickSize+")")}else{tick.n.g.setAttribute("transform","translate(0,"+coord+")");tick.n.p.setAttribute("d","M0 0L-"+this$.cfg.tickSize+" 0");tick.n.t.setAttribute("transform","translate("+(-this$.cfg.tickSize-box.sizeAlt-1)+",0)")}m=2;ref$=[box.coord,box.coord+box.size],ip1=ref$[0],ip2=ref$[1];ref$=[ip1-m,ip2+m],op1=ref$[0],op2=ref$[1];overlap=lc.picked.filter(function(b){var ref$,iq1,iq2,oq1,oq2;ref$=[b.coord,b.coord+b.size],iq1=ref$[0],iq2=ref$[1];ref$=[iq1-m,iq2+m],oq1=ref$[0],oq2=ref$[1];return ip1>oq1&&ip1<oq2||iq1>op1&&iq1<op2}).length;tick.n.t.style.opacity=overlap?0:1;lc.picked.push(box);return!overlap};bfs=function(maxlv){var ref$,lc,fifo,L,R,D,M,size,box;maxlv==null&&(maxlv=1);ref$=[{checked:{},picked:[],node:this$._n.wrap},[]],lc=ref$[0],fifo=ref$[1];lc.fontSize=getComputedStyle(lc.node).fontSize;ticks.map(function(it){return it.n.t.style.opacity=0});if(ticks.length){fifo.push([0,ticks.length-1,0]);[0,ticks.length-1].map(function(it){return insert(it,0,lc)})}while(fifo.length){ref$=fifo.splice(0,1)[0],L=ref$[0],R=ref$[1],D=ref$[2];if(D>=maxlv){continue}M=Math.floor((L+R)/2);insert(M,D,lc);if(M>L+1){fifo.push([L,M,D+1])}if(R>M+1){fifo.push([M,R,D+1])}}size=Math.max.apply(Math,[0].concat(lc.picked.map(function(it){return it.sizeAlt})));if(this$.dir<2){this$._n.label.setAttribute("y",size+this$.cfg.tickSize);return this$._n.layout.style.height=size+this$.cfg.tickSize+this$._n.label.getBoundingClientRect().height+"px"}else{this$._n.label.setAttribute("x",0);this$._n.label.setAttribute("y",0);this$._n.layout.style.width=size+this$.cfg.tickSize+this$._n.label.getBoundingClientRect().width+"px";box=this$._n.layout.getBoundingClientRect();this$._n.label.setAttribute("transform","translate("+-(size+this$.cfg.tickSize)+","+box.height/2+") rotate(90)");return this$._n.root.setAttribute("transform","translate("+box.width+",0)")}};return bfs(5)}});if(typeof chart!="undefined"&&chart!==null){(chart.utils||(chart.utils={})).axis=axis}function import$(obj,src){var own={}.hasOwnProperty;for(var key in src)if(own.call(src,key))obj[key]=src[key];return obj}}).call(this);
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
(function(){
|
|
2
|
+
var config;
|
|
3
|
+
config = {
|
|
4
|
+
preset: {
|
|
5
|
+
'default': {
|
|
6
|
+
margin: {
|
|
7
|
+
type: 'number'
|
|
8
|
+
},
|
|
9
|
+
font: {
|
|
10
|
+
size: {
|
|
11
|
+
type: 'number',
|
|
12
|
+
min: 1,
|
|
13
|
+
max: 256,
|
|
14
|
+
step: 1,
|
|
15
|
+
'default': 16
|
|
16
|
+
}
|
|
17
|
+
},
|
|
18
|
+
color: {
|
|
19
|
+
type: 'color'
|
|
20
|
+
},
|
|
21
|
+
palette: {
|
|
22
|
+
type: 'palette'
|
|
23
|
+
},
|
|
24
|
+
background: {
|
|
25
|
+
type: 'color'
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
};
|
|
30
|
+
if (typeof chart != 'undefined' && chart !== null) {
|
|
31
|
+
(chart.utils || (chart.utils = {})).config = config;
|
|
32
|
+
}
|
|
33
|
+
}).call(this);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
(function(){var config;config={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"}}}};if(typeof chart!="undefined"&&chart!==null){(chart.utils||(chart.utils={})).config=config}}).call(this);
|