UNPKG

highcharts

Version:
10 lines 6.87 kB
!/** * Highcharts JS v13.0.1 (2026-08-17) * @module highcharts/modules/geoheatmap * @requires highcharts * * (c) 2009-2026 * * A commercial license may be required depending on use, * see www.highcharts.com/license */function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e(t._Highcharts,t._Highcharts.SeriesRegistry):"function"==typeof define&&define.amd?define("highcharts/modules/geoheatmap",["highcharts/highcharts"],function(t){return e(t,t.SeriesRegistry)}):"object"==typeof exports?exports["highcharts/modules/geoheatmap"]=e(t._Highcharts,t._Highcharts.SeriesRegistry):t.Highcharts=e(t.Highcharts,t.Highcharts.SeriesRegistry)}("u"<typeof window?this:window,(t,e)=>(()=>{"use strict";var i={512(t){t.exports=e},944(e){e.exports=t}};let o={};function a(t){let e=o[t];if(void 0!==e)return e.exports;let r=o[t]={exports:{}};return i[t](r,r.exports,a),r.exports}a.n=t=>{let e=t&&t.__esModule?()=>t.default:()=>t;return a.d(e,{a:e}),e},a.d=(t,e)=>{if(Array.isArray(e))for(var i=0;i<e.length;){var o=e[i++],r=e[i++];a.o(t,o)?0===r&&i++:0===r?Object.defineProperty(t,o,{enumerable:!0,value:e[i++]}):Object.defineProperty(t,o,{enumerable:!0,get:r})}else for(var o in e)a.o(e,o)&&!a.o(t,o)&&Object.defineProperty(t,o,{enumerable:!0,get:e[o]})},a.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e);let r={};a.d(r,{default:()=>x});var s=a(944),n=a.n(s),l=a(512),h=a.n(l);let{map:{prototype:{pointClass:p}}}=h().seriesTypes,d=class extends p{applyOptions(t,e){let i=super.applyOptions.call(this,t,e),{lat:o,lon:a}=i.options;if((0,s.isNumber)(a)&&(0,s.isNumber)(o)){let{colsize:t=1,rowsize:e=1}=this.series.options,r=a-t/2,s=o-e/2;i.geometry=i.options.geometry={type:"Polygon",coordinates:[[[r,s],[r+t,s],[r+t,s+e],[r,s+e],[r,s]]]}}return i}},{doc:c}=n(),{noop:g}=n(),{colorFromPoint:u,getContext:y}={colorFromPoint:function(t,e){let i=e.series.colorAxis;if(i){let o=i.toColor(t||0,e).split(")")[0].split("(")[1].split(",").map(t=>(0,s.pick)(parseFloat(t),parseInt(t,10)));return o[3]=255*(0,s.pick)(o[3],1),(0,s.defined)(t)&&e.visible||(o[3]=0),o}return[0,0,0,0]},getContext:function(t){let{canvas:e,context:i}=t;return e&&i?.clearRect?(i.clearRect(0,0,e.width,e.height),i):(t.canvas=c.createElement("canvas"),t.context=t.canvas.getContext("2d",{willReadFrequently:!0})||void 0,t.context)}},{seriesTypes:{map:m}}=h();function f(t){return t-360*Math.floor((t+180)/360)}class b extends m{constructor(){super(...arguments),this.isDirtyCanvas=!0}update(){this.options=(0,s.merge)(this.options,arguments[0]),this.getInterpolation().enabled&&(this.isDirtyCanvas=!0,this.points.forEach(t=>{t.graphic&&(t.graphic.destroy(),delete t.graphic)})),super.update.apply(this,arguments)}translate(){(!this.getInterpolation().enabled||!this.image||this.isDirty||this.isDirtyData)&&super.translate.apply(this,arguments)}getInterpolation(){return(0,s.isObject)(this.options.interpolation)?this.options.interpolation:{blur:1,enabled:this.options.interpolation}}drawPoints(){let t=this.chart.mapView,e=this.options;if(this.getInterpolation().enabled&&t&&this.bounds){let o=this.context||y(this),{canvas:a,colorAxis:r,image:n,chart:l,points:h}=this,[p,d]=[(0,s.pick)(e.colsize,1),(0,s.pick)(e.rowsize,1)],c=t.projectedUnitsToPixels({x:this.bounds.x1,y:this.bounds.y2}),g=t.projectedUnitsToPixels({x:this.bounds.x2,y:this.bounds.y1});if(a&&o&&r&&c&&g){let{x:e,y:r}=c,y=g.x-e,m=g.y-r,f={x:e,y:r,width:y,height:m};if(this.isDirtyCanvas||this.isDirtyData||"Orthographic"===t.projection.options.name){let n=a.width=~~(360/p)+1,l=a.height=~~(180/d)+1,c=new Uint8ClampedArray(n*l*4),{lat:g=0,lon:f=0}=h[0].options,b=f%d!=0,x=g%p!=0,w=b?t=>Math.round(t/d)*d:t=>t,v=x?t=>Math.round(t/p)*p:t=>t,D=h.length;(b||x)&&(0,s.error)("Highcharts Warning: For best performance, lon/lat datapoints should spaced by a single colsize/rowsize",!1,this.chart,{colsize:String(p),rowsize:String(d)}),this.directTouch=!1,this.isDirtyCanvas=!0;for(let t=0;t<D;t++){var i;let e=h[t],{lon:o,lat:a}=e.options;(0,s.isNumber)(o)&&(0,s.isNumber)(a)&&c.set(u(e.value,e),4*(i=w(o),Math.ceil(n*(l-1-(v(a)+90)/d)+(i+180)/p)))}let C=this.getInterpolation().blur,j=0===C?1:11*C,P=~~(n*j),I=~~(l*j),O=~~y,T=~~m,R=new ImageData(c,n,l);a.width=P,a.height=I,o.putImageData(R,0,0),o.globalCompositeOperation="copy",o.drawImage(a,0,0,R.width,R.height,0,0,P,I);let A=this.getProjectedImageData(t,O,T,o.getImageData(0,0,P,I),a,e,r);a.width=O,a.height=T,o.putImageData(new ImageData(A,O,T),0,0)}if(n)if(l.renderer.globalAnimation&&l.hasRendered){let t=Number(n.attr("x")),i=Number(n.attr("y")),o=Number(n.attr("width")),h=Number(n.attr("height")),p=(a,s)=>{let l=s.pos;n.attr({x:t+(e-t)*l,y:i+(r-i)*l,width:o+(y-o)*l,height:h+(m-h)*l})},d=(0,s.merge)((0,s.animObject)(l.renderer.globalAnimation)),c=d.step;d.step=function(){c&&c.apply(this,arguments),p.apply(this,arguments)},n.attr((0,s.merge)({animator:0},this.isDirtyCanvas?{href:a.toDataURL("image/png",1)}:void 0)).animate({animator:1},d)}else(0,s.stop)(n),n.attr((0,s.merge)(f,this.isDirtyCanvas?{href:a.toDataURL("image/png",1)}:void 0));else this.image=l.renderer.image(a.toDataURL("image/png",1)).attr(f).add(this.group);this.isDirtyCanvas=!1}}else super.drawPoints.apply(this,arguments)}getProjectedImageData(t,e,i,o,a,r,n){let l=new Uint8ClampedArray(e*i*4),h=(0,s.pick)(t.projection.options.rotation?.[0],0),p=a.width/360,d=-1*a.height/180,c=-1;for(let i=0;i<l.length;i+=4){let s=i/4%e;0===s&&c++;let g=t.pixelsToLonLat({x:r+s,y:n+c});if(g){g.lon>-180-h&&g.lon<180-h&&(g.lon=f(g.lon));let t=[g.lon,g.lat],e=t[0]*p+a.width/2,r=t[1]*d+a.height/2;if(e>=0&&e<=a.width&&r>=0&&r<=a.height){let t=Math.floor(r)*a.width*4+4*Math.round(e);l[i]=o.data[t],l[i+1]=o.data[t+1],l[i+2]=o.data[t+2],l[i+3]=o.data[t+3]}}}return l}searchPoint(t,e){let i=this.chart,o=i.mapView;if(o&&this.bounds&&this.image&&i.tooltip&&i.tooltip.options.enabled)if(!i.pointer.hasDragged&&(.01>=+this.image.attr("animator")||+this.image.attr("animator")>=.99)){let a=o.projectedUnitsToPixels({x:this.bounds.x1,y:this.bounds.y2}),r=o.projectedUnitsToPixels({x:this.bounds.x2,y:this.bounds.y1});if(i.pointer.normalize(t),t.lon&&t.lat&&a&&r&&t.chartX-i.plotLeft>a.x&&t.chartX-i.plotLeft<r.x&&t.chartY-i.plotTop>a.y&&t.chartY-i.plotTop<r.y)return this.searchKDTree({clientX:t.chartX,lon:f(t.lon),lat:t.lat},e,t)}else i.tooltip.destroy()}}b.defaultOptions=(0,s.merge)(m.defaultOptions,{nullColor:"transparent",tooltip:{pointFormat:"Lat: {point.lat}, Lon: {point.lon}, Value: {point.value}<br/>"},borderWidth:0,colsize:1,rowsize:1,stickyTracking:!0,interpolation:{enabled:!1,blur:1}}),(0,s.addEvent)(b,"afterDataClassLegendClick",function(){this.isDirtyCanvas=!0,this.drawPoints()}),(0,s.extend)(b.prototype,{type:"geoheatmap",applyJitter:g,pointClass:d,pointArrayMap:["lon","lat","value"],kdAxisArray:["lon","lat"]}),h().registerSeriesType("geoheatmap",b);let x=n();return r.default})());