/* * heatmap.js v2.0.5 | JavaScript Heatmap Library * * Copyright 2008-2016 Patrick Wied - All rights reserved. * Dual licensed under MIT and Beerware license * * :: 2018-04-19 12:47 */ (function(t,a,e){if(typeof module!=="undefined"&&module.exports){module.exports=e()}else if(typeof define==="function"&&define.amd){define(e)}else{a[t]=e()}})("h337",this,function(){var n={defaultRadius:40,defaultRenderer:"canvas2d",defaultGradient:{.25:"rgb(0,0,255)",.55:"rgb(0,255,0)",.85:"yellow",1:"rgb(255,0,0)"},defaultMaxOpacity:1,defaultMinOpacity:0,defaultBlur:.85,defaultXField:"x",defaultYField:"y",defaultValueField:"value",plugins:{}};var s=function t(){var a=function t(a){this._coordinator={};this._data=[];this._radi=[];this._min=10;this._max=1;this._xField=a["xField"]||a.defaultXField;this._yField=a["yField"]||a.defaultYField;this._valueField=a["valueField"]||a.defaultValueField;if(a["radius"]){this._cfgRadius=a["radius"]}};var u=n.defaultRadius;a.prototype={_organiseData:function(t,a){var e=t[this._xField];var i=t[this._yField];var r=this._radi;var n=this._data;var s=this._max;var h=this._min;var o=t[this._valueField]||1;var d=t.radius||this._cfgRadius||u;if(!n[e]){n[e]=[];r[e]=[]}if(!n[e][i]){n[e][i]=o;r[e][i]=d}else{n[e][i]+=o}var l=n[e][i];if(l>s){if(!a){this._max=l}else{this.setDataMax(l)}return false}else if(l0){var t=arguments[0];var a=t.length;while(a--){this.addData.call(this,t[a])}}else{var e=this._organiseData(arguments[0],true);if(e){if(this._data.length===0){this._min=this._max=e.value}this._coordinator.emit("renderpartial",{min:this._min,max:this._max,data:[e]})}}return this},setData:function(t){var a=t.data;var e=a.length;this._data=[];this._radi=[];for(var i=0;i0){this.clip();this._drawAlpha(t);this._colorize()}},renderAll:function(t){this._clear();if(t.data.length>0){this.clip();this._drawAlpha(a(t));this._colorize()}},_updateGradient:function(t){this._palette=h(t)},updateConfig:function(t){if(t["gradient"]){this._updateGradient(t)}this._setStyles(t)},setDimensions:function(t,a){this._width=t;this._height=a;this.canvas.width=this.shadowCanvas.width=t;this.canvas.height=this.shadowCanvas.height=a},_clear:function(){this.shadowCtx.clearRect(0,0,this._width,this._height);this.ctx.clearRect(0,0,this._width,this._height)},_setStyles:function(t){this._blur=t.blur==0?0:t.blur||t.defaultBlur;if(t.backgroundColor){this.canvas.style.backgroundColor=t.backgroundColor}this._width=this.canvas.width=this.shadowCanvas.width=t.width||this._width;this._height=this.canvas.height=this.shadowCanvas.height=t.height||this._height;this._opacity=(t.opacity||0)*255;this._maxOpacity=(t.maxOpacity||t.defaultMaxOpacity)*255;this._minOpacity=(t.minOpacity||t.defaultMinOpacity)*255;this._useGradientOpacity=!!t.useGradientOpacity},_drawAlpha:function(t){var a=this._min=t.min;var e=this._max=t.max;var t=t.data||[];var i=t.length;var r=1-this._blur;while(i--){var n=t[i];var s=n.x;var h=n.y;var o=n.radius;var d=Math.min(n.value,e);var l=s-o;var u=h-o;var c=this.shadowCtx;var _;if(!this._templates[o]){this._templates[o]=_=v(o,r)}else{_=this._templates[o]}var f=(d-a)/(e-a);c.globalAlpha=f<.01?.01:f;c.drawImage(_,l,u);if(lthis._renderBoundaries[2]){this._renderBoundaries[2]=l+2*o}if(u+2*o>this._renderBoundaries[3]){this._renderBoundaries[3]=u+2*o}}},_colorize:function(){var t=this._renderBoundaries[0];var a=this._renderBoundaries[1];var e=this._renderBoundaries[2]-t;var i=this._renderBoundaries[3]-a;var r=this._width;var n=this._height;var s=this._opacity;var h=this._maxOpacity;var o=this._minOpacity;var d=this._useGradientOpacity;if(t<0){t=0}if(a<0){a=0}if(t+e>r){e=r-t}if(a+i>n){i=n-a}var l=this.shadowCtx.getImageData(t,a,e,i);var u=l.data;var c=u.length;var _=this._palette;for(var f=3;f0){m=s}else{if(v>0;return a},getDataURL:function(){return this.canvas.toDataURL()}};return e}();var h=function t(){var a=false;if(n["defaultRenderer"]==="canvas2d"){a=e}return a}();var o={merge:function(){var t={};var a=arguments.length;for(var e=0;e