@plotdb/chart 2.1.38 → 3.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +11 -0
- package/package.json +1 -1
- package/utils/axis.js +6 -2
- package/utils/axis.min.js +1 -1
- package/utils/tip.js +10 -1
- package/utils/tip.min.js +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,16 @@
|
|
|
1
1
|
# Change Logs
|
|
2
2
|
|
|
3
|
+
## v3.0.0
|
|
4
|
+
|
|
5
|
+
- upgrade d3 dependencies from v4 to v7
|
|
6
|
+
- support alternative value in tooltip
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
## v2.1.39
|
|
10
|
+
|
|
11
|
+
- fix bug: no default value in axis sideNoteStart / sideNoteEnd, causing NaN in generated SVG
|
|
12
|
+
|
|
13
|
+
|
|
3
14
|
## v2.1.38
|
|
4
15
|
|
|
5
16
|
- axis, config utilities: support side note
|
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":"
|
|
1
|
+
{"author":"zbryikt","name":"@plotdb/chart","license":"MIT","description":"plotdb charts","style":"index.min.css","browser":"index.min.js","main":"index.min.js","version":"3.0.0","homepage":"https://github.com/plotdb/chart","repository":{"type":"git","url":"https://github.com/plotdb/chart"},"engines":{"node":">=10.14.1","npm":">=6.4.1"},"scripts":{"start":"npx server -r web -o true -p 3457"},"devDependencies":{"@loadingio/bootstrap.ext":"^0.0.12","@loadingio/ldquery":"^3.0.6","@loadingio/loading.css":"^3.2.1","@loadingio/vscroll":"^0.0.11","@plotdb/layout":"^0.0.12","@plotdb/pdmap-world":"^0.0.5","@plotdb/semver":"^0.0.3","@plotdb/sheet":"^0.7.0","@xlfont/choose":"^0.0.32","@xlfont/load":"^2.1.5","@zbryikt/template":"^2.4.1","bootstrap":"^4.6.1","bootstrap.native":"^3.0.15","fedep":"^1.6.0","jsdom":"^22.1.0","ldbutton":"^2.0.5","ldfile":"^2.0.1","ldiconfont":"^0.2.8","ldloader":"^3.0.3","ldview":"^1.5.1","livescript":"^1.6.0","pdmaptw":"2.2.1","uglify-js":"^3.13.1","uglifycss":"^0.0.29","zmgr":"^2.2.3"},"frontendDependencies":{"root":"web/static/assets/lib","modules":["bootstrap","bootstrap.native","@loadingio/bootstrap.ext","@loadingio/ldquery","@loadingio/loading.css","@loadingio/ldcolorpicker","@loadingio/debounce.js","@loadingio/vscroll","@plotdb/pdmap-world","@plotdb/block","@plotdb/csscope","@plotdb/rescope","@plotdb/layout","@plotdb/sheet","@plotdb/konfig","@plotdb/semver","@xlfont/choose","@xlfont/load","@zbryikt/voronoijs","d3","d3-array","d3-axis","d3-brush","d3-color","d3-dispatch","d3-drag","d3-ease","d3-force","d3-force-boundary","d3-format","d3-hierarchy","d3-interpolate","d3-path","d3-quadtree","d3-random","d3-scale-chromatic","d3-selection","d3-shape","d3-timer","d3-transition","choosefont.js","pdmaptw","proxise","ldiconfont","ldloader","ldbutton","ldcover","ldcolor","ldfile","ldslider","wrap-svg-text","ldpalettepicker","zmgr","ldview"]},"dependencies":{"@loadingio/debounce.js":"^1.0.1","@loadingio/ldcolorpicker":"^3.0.5","@plotdb/block":"^5.2.2","@plotdb/csscope":"^5.0.3","@plotdb/konfig":"^4.8.12","@plotdb/rescope":"^5.0.9","@zbryikt/voronoijs":"^1.0.0","choosefont.js":"^0.0.1","d3":"^7.9.0","d3-force-boundary":"^0.0.2","ldcolor":"^1.1.3","ldcover":"^3.5.1","ldpalettepicker":"^4.0.4","ldslider":"^3.1.1","proxise":"^1.0.1","wrap-svg-text":"^0.0.7"}}
|
package/utils/axis.js
CHANGED
|
@@ -89,8 +89,12 @@
|
|
|
89
89
|
padding: 1
|
|
90
90
|
},
|
|
91
91
|
enabled: c.enabled,
|
|
92
|
-
sideNoteStart: {
|
|
93
|
-
|
|
92
|
+
sideNoteStart: {
|
|
93
|
+
padding: 1
|
|
94
|
+
},
|
|
95
|
+
sideNoteEnd: {
|
|
96
|
+
padding: 1
|
|
97
|
+
}
|
|
94
98
|
};
|
|
95
99
|
['tick', 'baseline', 'label', 'caption', 'sideNoteStart', 'sideNoteEnd'].map(function(n){
|
|
96
100
|
return import$(this$.cfg[n], c[n] || {});
|
package/utils/axis.min.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
!function(){var l,t;function c(t,e){var n,i={}.hasOwnProperty;for(n in e)i.call(e,n)&&(t[n]=e[n]);return t}l=function(t){return document.createElementNS("http://www.w3.org/2000/svg",t)},(t=function(t){var i,e=this;return this.dir={bottom:0,left:2}[(t=null==t?{}:t).direction||"bottom"],this.name=t.name||"axis",this.layout=t.layout||new layout({root:this.root}),this._ticks=[],this._scale=t.scale||function(t){return t},this._format=chart.utils.format.simple,this._config(t.cfg),this._map={},this._n=i={root:l("g"),layout:this.layout.getNode(this.name),render:this.layout.getGroup(this.name),wrap:null,domain:l("path")},i.render.appendChild(i.root),i.root.appendChild(i.domain),i.label=l("text"),i.label.textContent="",(t=i.label).setAttribute("dominant-baseline","hanging"),t.setAttribute("text-anchor","middle"),i.root.appendChild(i.label),i.sideNote=[0,1].map(function(t){var e,n=l("text");return n.textContent="",(e=n).setAttribute("dominant-baseline","hanging"),e.setAttribute("text-anchor",["start","end"][t]),i.root.appendChild(n)}),this.wrapper(),(t=this.layout).on("update",function(){return e.update()}),t.on("render",function(){return e.render()}),this}).prototype=c(Object.create(Object.prototype),{wrapper:function(){var t,e=this._n;return e.wrap&&e.wrap.parentNode&&e.wrap.parentNode.removeChild(e.wrap),e.wrap=document.createElement("div"),c(((t=e.wrap.style).visibility="hidden",t.position="absolute",t.top=0,t.left=0,t.pointerEvents="none",t.userSelect="none",t.zIndex=0,t.wordBreak="break-all",t.lineHeight=".95em",t),this.dir<2&&null!=this.cfg.textWidth?{whiteSpace:"wrap",width:(1<(t=this.cfg.textWidth)?t:1)+"em"}:{whiteSpace:"pre",width:"4em"}),e.layout.appendChild(e.wrap)},_config:function(e){var t,n=this;return null==e&&(e={}),this.cfg={tick:{inner:8},baseline:{},label:{padding:1},caption:{padding:1},enabled:e.enabled,sideNoteStart:{},sideNoteEnd:{}},["tick","baseline","label","caption","sideNoteStart","sideNoteEnd"].map(function(t){return c(n.cfg[t],e[t]||{})}),(t=this.cfg.label).font||(t.font={}),(t=this.cfg.caption).font||(t.font={}),(t=this.cfg.sideNoteStart).font||(t.font={}),(t=this.cfg.sideNoteEnd).font||(t.font={}),this.format(this.cfg.label.format)},config:function(t){return null==t?this.cfg:(this._config(t),this.wrapper())},format:function(t){return null==t?this._format:this._format="string"==typeof t?chart.utils.format.from(t):t||chart.utils.format.simple},scale:function(t){return null!=t?this._scale=t:this._scale},caption:function(t){return arguments.length&&(this._caption=t),!this.cfg.enabled||null!=this.cfg.caption.show&&!this.cfg.caption.show?this._n.label.textContent="":this._n.label.textContent=this.cfg.caption.text||this._caption||""},update:function(){},ticks:function(n){var t,e,i,
|
|
1
|
+
!function(){var l,t;function c(t,e){var n,i={}.hasOwnProperty;for(n in e)i.call(e,n)&&(t[n]=e[n]);return t}l=function(t){return document.createElementNS("http://www.w3.org/2000/svg",t)},(t=function(t){var i,e=this;return this.dir={bottom:0,left:2}[(t=null==t?{}:t).direction||"bottom"],this.name=t.name||"axis",this.layout=t.layout||new layout({root:this.root}),this._ticks=[],this._scale=t.scale||function(t){return t},this._format=chart.utils.format.simple,this._config(t.cfg),this._map={},this._n=i={root:l("g"),layout:this.layout.getNode(this.name),render:this.layout.getGroup(this.name),wrap:null,domain:l("path")},i.render.appendChild(i.root),i.root.appendChild(i.domain),i.label=l("text"),i.label.textContent="",(t=i.label).setAttribute("dominant-baseline","hanging"),t.setAttribute("text-anchor","middle"),i.root.appendChild(i.label),i.sideNote=[0,1].map(function(t){var e,n=l("text");return n.textContent="",(e=n).setAttribute("dominant-baseline","hanging"),e.setAttribute("text-anchor",["start","end"][t]),i.root.appendChild(n)}),this.wrapper(),(t=this.layout).on("update",function(){return e.update()}),t.on("render",function(){return e.render()}),this}).prototype=c(Object.create(Object.prototype),{wrapper:function(){var t,e=this._n;return e.wrap&&e.wrap.parentNode&&e.wrap.parentNode.removeChild(e.wrap),e.wrap=document.createElement("div"),c(((t=e.wrap.style).visibility="hidden",t.position="absolute",t.top=0,t.left=0,t.pointerEvents="none",t.userSelect="none",t.zIndex=0,t.wordBreak="break-all",t.lineHeight=".95em",t),this.dir<2&&null!=this.cfg.textWidth?{whiteSpace:"wrap",width:(1<(t=this.cfg.textWidth)?t:1)+"em"}:{whiteSpace:"pre",width:"4em"}),e.layout.appendChild(e.wrap)},_config:function(e){var t,n=this;return null==e&&(e={}),this.cfg={tick:{inner:8},baseline:{},label:{padding:1},caption:{padding:1},enabled:e.enabled,sideNoteStart:{padding:1},sideNoteEnd:{padding:1}},["tick","baseline","label","caption","sideNoteStart","sideNoteEnd"].map(function(t){return c(n.cfg[t],e[t]||{})}),(t=this.cfg.label).font||(t.font={}),(t=this.cfg.caption).font||(t.font={}),(t=this.cfg.sideNoteStart).font||(t.font={}),(t=this.cfg.sideNoteEnd).font||(t.font={}),this.format(this.cfg.label.format)},config:function(t){return null==t?this.cfg:(this._config(t),this.wrapper())},format:function(t){return null==t?this._format:this._format="string"==typeof t?chart.utils.format.from(t):t||chart.utils.format.simple},scale:function(t){return null!=t?this._scale=t:this._scale},caption:function(t){return arguments.length&&(this._caption=t),!this.cfg.enabled||null!=this.cfg.caption.show&&!this.cfg.caption.show?this._n.label.textContent="":this._n.label.textContent=this.cfg.caption.text||this._caption||""},update:function(){},ticks:function(n){var t,e,i,a=this,o={},r=this._n.layout.getBoundingClientRect()[this.dir<2?"width":"height"],r=Math.round(r/25),s=1<(t=Math.round(n.length/(1<r?r:1)))?t:1;for(e in this._ticks=n.filter(function(t,e){return!(e%s)||e===n.length-1}).map(function(t){var e,n;return o[(t="object"!=typeof t?{v:t}:t).v]=c((e=a._map)[n=t.v]||(e[n]={}),t)}),t=this._map)i=t[e],o[e]||i.n.g.parentNode.removeChild(i.n.g);return this._map=o,this._ticks.filter(function(t){return!t.n}).map(function(t){if(t.n={g:l("g"),p:l("path"),t:l("g")},t.n.g.appendChild(t.n.p),t.n.g.appendChild(t.n.t),a._n.root.appendChild(t.n.g),isNaN(+t.v))return t.t=t.v})},render:function(){var i,t,a,e,n,o,r,s=this,l=this._n,c=this.dir<2,d=l.wrap;return d.style.fontSize=this.cfg.label.font.size?this.cfg.label.font.size+""||"":void 0,d.setAttribute("class",(this.cfg.label.font.family||{}).className||""),i=this._ticks,null==this.cfg.enabled||this.cfg.enabled?(c?((t=l.layout.style).height="",t.paddingTop="",t.paddingBottom=""):((t=l.layout.style).width="",t.paddingLeft="",t.paddingRight=""),l.domain.style.display="",i.map(function(t){return t.n.g.style.display=""}),a=getComputedStyle(d).fontSize,e=l.layout.getBoundingClientRect(),(t=l.domain.style).strokeWidth=1,t.stroke="currentColor",t.fill="none",i.map(function(t,e){var n=e?e===i.length-1?2:1:0;return t._c=null!=t.c?t.c:s._scale(t.v)+(s._scale.bandwidth?s._scale.bandwidth()/2:0),t._t=null!=t.t?t.t:s._format(t.v),(e=t.n.p.style).strokeWidth=1,e.stroke="currentColor",e.fill="none",d.textContent=t._t,d.style.textAlign=c?["left","center","right"][n]:["right","left"][s.dir-2],t.n.tt=wrapSvgText({node:d}),t.n.t.style.fontSize=a,t.n.t.style.fill=s.cfg.label.color,t.n.t.textContent="",t.n.t.appendChild(t.n.tt),t.n.t.setAttribute("class",(s.cfg.label.font||{}).className||"")}),i.sort(function(t,e){return t._c-e._c}),l.domain.style.stroke=this.cfg.baseline.show?this.cfg.baseline.color:"none",r=(this.cfg.caption.position||0)%3,n=Math.floor((this.cfg.caption.position||0)/3),(o=l.label).setAttribute("text-anchor",["start","middle","end"][r]),o.setAttribute("dominant-baseline",["baseline","hanging"][n]),l.sideNote.map(function(t,e){e=(s.cfg[["sideNoteStart","sideNoteEnd"][e]]||{}).position||0;return t.setAttribute("dominant-baseline",["baseline","hanging"][e])}),c?(l.domain.setAttribute("d","M0 0L"+e.width+" 0Z"),l.label.setAttribute("x",e.width/2),l.label.setAttribute("x",[2,e.width/2,e.width-2][r])):(l.domain.setAttribute("d","M0 0L0 "+e.height+"Z"),r=[2,e.height/2,e.height-2][r],l.label.setAttribute("transform","translate(0,"+r+") rotate(90)")),i.map(function(t){return t.box=t.n.t.getBBox()}),this.adjust()):(c?((t=l.layout.style).height="0px",t.paddingTop="0",t.paddingBottom="0"):((t=l.layout.style).width="0px",t.paddingLeft="0",t.paddingRight="0"),l.domain.style.display="none",void i.map(function(t){return t.n.g.style.display="none"}))},adjust:function(){var f=this,p=this._ticks,h=this.dir<2,g=function(t,e,n){var i,a,o,r,s,l,c,d;if(!n.checked[t])return n.checked[t]=!0,i=p[t],r=t?t===p.length-1?2:1:0,d=[i._c,i._t][0],o={x:-(a=i.box).x,y:-a.y},r=!f._scale.bandwidth&&(null!=f.cfg.tick.boundaryOffset?!!f.cfg.tick.boundaryOffset:f.dir<2)?r/2:.5,h?o.x-=a.width*r:o.y-=a.height*r,i.n.tt.setAttribute("transform","translate("+o.x+","+o.y+")"),(a={size:a[h?"width":"height"],sizeAlt:a[h?"height":"width"],lv:e,tick:i,idx:t}).coord=d-a.size*r,h?(i.n.g.setAttribute("transform","translate("+d+",0)"),i.n.p.setAttribute("d","M0 0L0 "+f.cfg.tick.inner),i.n.t.setAttribute("transform","translate(0,"+(f.cfg.tick.inner+f.cfg.label.padding)+")")):(i.n.g.setAttribute("transform","translate(0,"+d+")"),i.n.p.setAttribute("d","M0 0L-"+f.cfg.tick.inner+" 0"),i.n.t.setAttribute("transform","translate("+(-f.cfg.tick.inner-a.sizeAlt-1-f.cfg.label.padding)+",0)")),d=[a.coord,a.coord+a.size],l=(d=[(s=d[0])-2,d[1]+2])[0],c=d[1],d=n.picked.filter(function(t){var e=[t.coord,t.coord+t.size],t=e[0];return(e=[t-2,e[1]+2])[0]<s&&s<e[1]||l<t&&t<c}).length,i.n.t.style.opacity=d?0:1,i.n.p.style.stroke=f.cfg.tick.color||"",n.picked.push(a),!d};return function(t){var e,n,i,a,o,r,s,l,c,d,h,u;for(null==t&&(t=1),e=[{checked:{},picked:[],node:f._n.wrap},[]],n=e[0],i=e[1],n.fontSize=getComputedStyle(n.node).fontSize,p.map(function(t){return t.n.t.style.opacity=0}),p.length&&(i.push([0,p.length-1,0]),[0,p.length-1].map(function(t){return g(t,0,n)}));i.length;)a=(e=i.splice(0,1)[0])[0],o=e[1],t<=(r=e[2])||(s=Math.floor((a+o)/2),g(s,r,n),a+1<s&&i.push([a,s,r+1]),s+1<o&&i.push([s,o,r+1]));return f._n.label.style.fill=f.cfg.caption.color,f._n.label.style.fontSize=f.cfg.caption.font.size?f.cfg.caption.font.size+""||"":void 0,f._n.label.setAttribute("class",(f.cfg.caption.font.family||{}).className||""),f.caption(),f._n.sideNote.map(function(t,e){var n=f.cfg[["sideNoteStart","sideNoteEnd"][e]]||{},e=n.font||{};return t.textContent=n.show&&n.text||"",t.style.fill=n.color,t.style.fontSize=e.size?e.size+""||"":void 0,t.setAttribute("class",(e.family||{}).className||"")}),u=(f.cfg.caption.position||0)%3,l=Math.floor((f.cfg.caption.position||0)/3),c=Math.max.apply(Math,[0].concat(n.picked.map(function(t){return t.sizeAlt}))),d=f.cfg.tick.inner+f.cfg.label.padding+f.cfg.caption.padding+c,f.dir<2?(f._n.label.setAttribute("y",[-2,d][l]),f._n.layout.style.height=d+f._n.label.getBoundingClientRect().height+"px",h=f._n.layout.getBoundingClientRect(),f._n.sideNote.map(function(t,e){var n=f.cfg[["sideNoteStart","sideNoteEnd"][e]]||{},i=n.position||0;return t.setAttribute("x",[2,h.width-2][e]),t.setAttribute("y",[-2-n.padding,d+n.padding][i])})):(f._n.label.setAttribute("x",0),f._n.label.setAttribute("y",0),f._n.layout.style.width=d+f._n.label.getBoundingClientRect().width+"px",u=[2,(h=f._n.layout.getBoundingClientRect()).height/2,h.height-2][u],f._n.label.setAttribute("transform","translate("+[2,-d-2][l]+","+u+") rotate(90)"),f._n.root.setAttribute("transform","translate("+(h.width-1)+",0)"),f._n.sideNote.map(function(t,e){var n=f.cfg[["sideNoteStart","sideNoteEnd"][e]]||{},i=n.position||0,i=[2+n.padding,-d-2-n.padding][i],e=[2,h.height-2][e];return t.setAttribute("transform","translate("+i+","+e+") rotate(90)")}))}(5)}}),"undefined"!=typeof chart&&null!==chart&&((chart.utils||(chart.utils={})).axis=t)}.call(this);
|
package/utils/tip.js
CHANGED
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
this.enabled = true;
|
|
19
19
|
if (!this.tip) {
|
|
20
20
|
this.tip = document.createElement('div');
|
|
21
|
-
this.tip.innerHTML = "<div ld=\"group\" style=\"font-size:.75em\"></div>\n<div ld=\"name\" style=\"font-size:.85em\"></div>\n<div ld=\"value\" style=\"font-weight:bold;font-size:1.1em;line-height:1.2em\"></div>";
|
|
21
|
+
this.tip.innerHTML = "<div ld=\"group\" style=\"font-size:.75em\"></div>\n<div ld=\"name\" style=\"font-size:.85em\"></div>\n<div ld=\"value\" style=\"font-weight:bold;font-size:1.1em;line-height:1.2em\"></div>\n<div ld=\"value-alt\" style=\"font-size:0.9em;line-height:1em\"></div>";
|
|
22
22
|
this.root.appendChild(this.tip);
|
|
23
23
|
ref$ = this.tip.style;
|
|
24
24
|
ref$.padding = '.4em .5em';
|
|
@@ -69,6 +69,15 @@
|
|
|
69
69
|
} else {
|
|
70
70
|
return '';
|
|
71
71
|
}
|
|
72
|
+
},
|
|
73
|
+
"value-alt": function(arg$){
|
|
74
|
+
var ctx;
|
|
75
|
+
ctx = arg$.ctx;
|
|
76
|
+
if (ctx) {
|
|
77
|
+
return ctx.valueAlt;
|
|
78
|
+
} else {
|
|
79
|
+
return '';
|
|
80
|
+
}
|
|
72
81
|
}
|
|
73
82
|
}
|
|
74
83
|
});
|
package/utils/tip.min.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
!function(){var t,e=function(t){var e,i=this;return this.root="string"==typeof(t=null==t?{}:t).root?document.querySelector(t.root):t.root,this.tip="string"==typeof t.node?this.root.querySelector(t.node):t.node,this.margin=null!=t.margin?t.margin:10,this.type="over"===t.type?"over":"move",this.accessor=t.accessor,this.range=t.range,this.zmgr=t.zmgr,this._z=0,this.enabled=!0,this.tip||(this.tip=document.createElement("div"),this.tip.innerHTML='<div ld="group" style="font-size:.75em"></div>\n<div ld="name" style="font-size:.85em"></div>\n<div ld="value" style="font-weight:bold;font-size:1.1em;line-height:1.2em"></div>',this.root.appendChild(this.tip),(e=this.tip.style).padding=".4em .5em",e.background="#13171a",e.color="#fff",e.borderRadius="3px",e.boxShadow="0 2px 4px rgba(0,0,0,.3)",e.lineHeight="1.2em",e.fontSize=".9em",e.maxWidth="10em",e.wordBreak="break-all"),(e=this.tip.style).position="absolute",e.zIndex=1,e.top=0,e.left=0,e.pointerEvents="none",e.userSelect="none",e.opacity=0,e.transition="opacity .15s ease-in-out"+("over"===this.type?", transform .15s ease-in-out":""),this.view=new ldview({root:this.tip,text:t.view||{group:function(t){t=t.ctx;return t?t.group:""},name:function(t){t=t.ctx;return t?t.name:""},value:function(t){t=t.ctx;return t?t.value:""}}}),this.hide=debounce(3e3,function(){if(this.tip.style.opacity=0,this.zmgr)return this.zmgr.remove(this._z)}),this._evthdr={},this.accessor&&(this.root.addEventListener("over"===this.type?"mouseover":"mousemove",this._evthdr.over=function(t){var e;if(t.target&&(e=i.accessor({evt:t})))return i.render({data:e,node:t.target,evt:t})}),this.root.addEventListener("mouseout",this._evthdr.out=function(){return i.hide().now()})),this};e.prototype=((t=Object.create(Object.prototype)).destroy=function(){if(this._evthdr.over&&this.root.removeEventListener("over"===this.type?"mouseover":"mousemove",this._evthdr.over),this._evthdr.out)return this.root.removeEventListener("mouseout",this._evthdr.out)},t.toggle=function(t){return null==t?this.enabled:this.enabled=t},t.render=function(t){var e,i,n,o,r,h,s,d,a;if(null==t&&(t={}),this.enabled)return this.view.ctx(t.data),this.view.render(),e=this.root.getBoundingClientRect(),h=null!=t.node?((s=t.node.getBoundingClientRect()).x=s.x-e.x,s.y=s.y-e.y,s):null!=t.box?t.box:{x:t.x,y:t.y,width:t.width,height:t.height},i=this.tip.getBoundingClientRect(),o=(n=[t.evt.clientX-e.x,t.evt.clientY-e.y])[0],a=n[1],d=this.margin,r=(n=[h.x+(null!=h.width?h.width/2:0),h.y+(null!=h.height?h.height/2:0)])[0],s=n[1],t=(n=[o-i.width/2,a-i.height/2])[0],h=n[1],t=(n=[t+(r<o?1:-1)*(d+i.width/2),h+(s<a?1:-1)*(d+i.height/2)])[0],h=n[1],t=(n=[((n=(t>(a=(s=this.range?this.range():e).x-e.x)?t:a)+i.width)<(d=s.width+s.x-e.x)?n:d)-i.width,((n=(h>(a=s.y-e.y)?h:a)+i.height)<(d=s.height+s.y-e.y)?n:d)-i.height])[0],h=n[1],(n=this.tip.style).transform="translate("+t+"px,"+h+"px)",n.opacity=1,n.zIndex=this._z=this.zmgr?this.zmgr.add(10):10,this.hide()},t),"undefined"!=typeof chart&&null!==chart&&((chart.utils||(chart.utils={})).tip=e)}.call(this);
|
|
1
|
+
!function(){var t,e=function(t){var e,i=this;return this.root="string"==typeof(t=null==t?{}:t).root?document.querySelector(t.root):t.root,this.tip="string"==typeof t.node?this.root.querySelector(t.node):t.node,this.margin=null!=t.margin?t.margin:10,this.type="over"===t.type?"over":"move",this.accessor=t.accessor,this.range=t.range,this.zmgr=t.zmgr,this._z=0,this.enabled=!0,this.tip||(this.tip=document.createElement("div"),this.tip.innerHTML='<div ld="group" style="font-size:.75em"></div>\n<div ld="name" style="font-size:.85em"></div>\n<div ld="value" style="font-weight:bold;font-size:1.1em;line-height:1.2em"></div>\n<div ld="value-alt" style="font-size:0.9em;line-height:1em"></div>',this.root.appendChild(this.tip),(e=this.tip.style).padding=".4em .5em",e.background="#13171a",e.color="#fff",e.borderRadius="3px",e.boxShadow="0 2px 4px rgba(0,0,0,.3)",e.lineHeight="1.2em",e.fontSize=".9em",e.maxWidth="10em",e.wordBreak="break-all"),(e=this.tip.style).position="absolute",e.zIndex=1,e.top=0,e.left=0,e.pointerEvents="none",e.userSelect="none",e.opacity=0,e.transition="opacity .15s ease-in-out"+("over"===this.type?", transform .15s ease-in-out":""),this.view=new ldview({root:this.tip,text:t.view||{group:function(t){t=t.ctx;return t?t.group:""},name:function(t){t=t.ctx;return t?t.name:""},value:function(t){t=t.ctx;return t?t.value:""},"value-alt":function(t){t=t.ctx;return t?t.valueAlt:""}}}),this.hide=debounce(3e3,function(){if(this.tip.style.opacity=0,this.zmgr)return this.zmgr.remove(this._z)}),this._evthdr={},this.accessor&&(this.root.addEventListener("over"===this.type?"mouseover":"mousemove",this._evthdr.over=function(t){var e;if(t.target&&(e=i.accessor({evt:t})))return i.render({data:e,node:t.target,evt:t})}),this.root.addEventListener("mouseout",this._evthdr.out=function(){return i.hide().now()})),this};e.prototype=((t=Object.create(Object.prototype)).destroy=function(){if(this._evthdr.over&&this.root.removeEventListener("over"===this.type?"mouseover":"mousemove",this._evthdr.over),this._evthdr.out)return this.root.removeEventListener("mouseout",this._evthdr.out)},t.toggle=function(t){return null==t?this.enabled:this.enabled=t},t.render=function(t){var e,i,n,o,r,h,s,d,a;if(null==t&&(t={}),this.enabled)return this.view.ctx(t.data),this.view.render(),e=this.root.getBoundingClientRect(),h=null!=t.node?((s=t.node.getBoundingClientRect()).x=s.x-e.x,s.y=s.y-e.y,s):null!=t.box?t.box:{x:t.x,y:t.y,width:t.width,height:t.height},i=this.tip.getBoundingClientRect(),o=(n=[t.evt.clientX-e.x,t.evt.clientY-e.y])[0],a=n[1],d=this.margin,r=(n=[h.x+(null!=h.width?h.width/2:0),h.y+(null!=h.height?h.height/2:0)])[0],s=n[1],t=(n=[o-i.width/2,a-i.height/2])[0],h=n[1],t=(n=[t+(r<o?1:-1)*(d+i.width/2),h+(s<a?1:-1)*(d+i.height/2)])[0],h=n[1],t=(n=[((n=(t>(a=(s=this.range?this.range():e).x-e.x)?t:a)+i.width)<(d=s.width+s.x-e.x)?n:d)-i.width,((n=(h>(a=s.y-e.y)?h:a)+i.height)<(d=s.height+s.y-e.y)?n:d)-i.height])[0],h=n[1],(n=this.tip.style).transform="translate("+t+"px,"+h+"px)",n.opacity=1,n.zIndex=this._z=this.zmgr?this.zmgr.add(10):10,this.hide()},t),"undefined"!=typeof chart&&null!==chart&&((chart.utils||(chart.utils={})).tip=e)}.call(this);
|