/* chartist-plugin-tooltip 0.1.2
* Copyright © 2019 Markus Padourek
* Free to use under the WTFPL license.
* http://www.wtfpl.net/
*/
!function(e,o){void 0===e&&void 0!==window&&(e=window),"function"==typeof define&&define.amd?define(["chartist"],function(t){return e["Chartist.plugins.tooltip"]=o(t)}):"object"==typeof module&&module.exports?module.exports=o(require("chartist")):e["Chartist.plugins.tooltip"]=o(e.Chartist)}(this,function(t){return function(v,x,b){"use strict";var t={currency:void 0,currencyFormatCallback:void 0,tooltipOffset:{x:0,y:-20},anchorToPoint:!1,appendToBody:!0,class:void 0,pointClass:"ct-point"};function T(t,e){return-1<(" "+t.getAttribute("class")+" ").indexOf(" "+e+" ")}function C(t){var e;return C in t?e=(e=t.offsetParent)||x.body.parentElement:(e=t.parentNode)?"static"!==v.getComputedStyle(e).position?e:"BODY"===e.tagName?e.parentElement:C(e):x.body.parentElement}b.plugins=b.plugins||{},b.plugins.tooltip=function(h){return h=b.extend({},t,h),function(c){var t=h.pointClass;c instanceof b.Bar?t="ct-bar":c instanceof b.Pie&&(t=c.options.donut?c.options.donutSolid?"ct-slice-donut-solid":"ct-slice-donut":"ct-slice-pie");var p,f=c.container,u=!1,d=C(f);(p=h.appendToBody?x.querySelector(".chartist-tooltip"):f.querySelector(".chartist-tooltip"))||((p=x.createElement("div")).className=h.class?"chartist-tooltip "+h.class:"chartist-tooltip",h.appendToBody?x.body.appendChild(p):f.appendChild(p));var g=p.offsetHeight,y=p.offsetWidth;function e(t,e,o){f.addEventListener(t,function(t){e&&!T(t.target,e)||o(t)})}function m(t){g=g||p.offsetHeight;var e=-(y=y||p.offsetWidth)/2+h.tooltipOffset.x,o=-g+h.tooltipOffset.y,n=!0===h.anchorToPoint&&t.target.x2&&t.target.y2;if(!0===h.appendToBody)if(n){var i=f.getBoundingClientRect(),a=t.target.x2.baseVal.value+i.left+v.pageXOffset,s=t.target.y2.baseVal.value+i.top+v.pageYOffset;p.style.left=a+e+"px",p.style.top=s+o+"px"}else p.style.left=t.pageX+e+"px",p.style.top=t.pageY+o+"px";else{var l=d.getBoundingClientRect(),r=-l.left-v.scrollX+e,c=-l.top-v.scrollY+o;if(n){i=f.getBoundingClientRect(),a=t.target.x2.baseVal.value+i.left+v.pageXOffset,s=t.target.y2.baseVal.value+i.top+v.pageYOffset;p.style.left=a+r+"px",p.style.top=s+c+"px"}else p.style.left=t.pageX+r+"px",p.style.top=t.pageY+c+"px"}}function o(t){u=!1;var e=new RegExp("tooltip-show\\s*","gi");t.className=t.className.replace(e,"").trim()}o(p),e("mouseover",t,function(t){var e=t.target,o="",n=(c instanceof b.Pie?e:e.parentNode)?e.parentNode.getAttribute("ct:meta")||e.parentNode.getAttribute("ct:series-name"):"",i=e.getAttribute("ct:meta")||n||"",a=!!i,s=e.getAttribute("ct:value");if(h.transformTooltipTextFnc&&"function"==typeof h.transformTooltipTextFnc&&(s=h.transformTooltipTextFnc(s)),h.tooltipFnc&&"function"==typeof h.tooltipFnc)o=h.tooltipFnc(i,s);else{if(h.metaIsHTML){var l=x.createElement("textarea");l.innerHTML=i,i=l.value}if(i=''+i+"",a)o+=i+"
";else if(c instanceof b.Pie){var r=function(t,e){for(;t=t.nextSibling,t&&!T(t,e););return t}(e,"ct-label");r&&(o+=function(t){return t.innerText||t.textContent}(r)+"
")}s&&(h.currency&&(s=null!=h.currencyFormatCallback?h.currencyFormatCallback(s,h):h.currency+s.replace(/(\d)(?=(\d{3})+(?:\.\d+)?$)/g,"$1,")),o+=s=''+s+"")}o&&(p.innerHTML=o,g=p.offsetHeight,y=p.offsetWidth,!0!==h.appendToBody&&(d=C(f)),"absolute"!==p.style.display&&(p.style.display="absolute"),m(t),function(t){u=!0,T(t,"tooltip-show")||(t.className=t.className+" tooltip-show")}(p),g=p.offsetHeight,y=p.offsetWidth)}),e("mouseout",t,function(){o(p)}),e("mousemove",null,function(t){!1===h.anchorToPoint&&u&&m(t)})}}}(window,document,t),t.plugins.tooltip});
//# sourceMappingURL=chartist-plugin-tooltip.min.js.map