highcharts
Version:
JavaScript charting framework
10 lines • 7.25 kB
JavaScript
/**
* Highcharts JS v12.6.0 (2026-04-13)
* @module highcharts/modules/geoheatmap
* @requires highcharts
*
* (c) 2009-2026
*
* A commercial license may be required depending on use.
* See www.highcharts.com/license
*/import*as t from"../highcharts.js";var e={};e.n=t=>{var i=t&&t.__esModule?()=>t.default:()=>t;return e.d(i,{a:i}),i},e.d=(t,i)=>{for(var o in i)e.o(i,o)&&!e.o(t,o)&&Object.defineProperty(t,o,{enumerable:!0,get:i[o]})},e.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e);let i=t.default;var o=e.n(i);let r=t.default.SeriesRegistry;var a=e.n(r);let{doc:n,win:s}=o();function l(t){return h(t)&&"number"==typeof t.nodeType}function p(t){return"number"==typeof t&&!isNaN(t)&&t<1/0&&t>-1/0}function h(t,e){let i;return!!t&&"object"==typeof t&&(!e||"[object Array]"!==(i=Object.prototype.toString.call(t))&&"[object Array Iterator]"!==i)}function c(t,...e){let i,o=[t,...e],r={},a=function(t,e){return"object"!=typeof t&&(t={}),function(t,e,i){for(let o in t)Object.hasOwnProperty.call(t,o)&&e.call(i||t[o],t[o],o,t)}(e,function(i,o){if("__proto__"!==o&&"constructor"!==o){let r;!h(i,!0)||(r=i?.constructor,h(i,!0)&&!l(i)&&r?.name&&"Object"!==r.name)||l(i)?t[o]=e[o]:t[o]=a(t[o]||{},i)}}),t};!0===t&&(r=o[1],o=Array.prototype.slice.call(o,2));let n=o.length;for(i=0;i<n;i++)r=a(r,o[i]);return r}Array.prototype.find;function d(){let t=arguments,e=t.length;for(let i=0;i<e;i++){let e=t[i];if(null!=e)return e}}let{map:{prototype:{pointClass:u}}}=a().seriesTypes,y=class extends u{applyOptions(t,e){let i=super.applyOptions.call(this,t,e),{lat:o,lon:r}=i.options;if(p(r)&&p(o)){let{colsize:t=1,rowsize:e=1}=this.series.options,a=r-t/2,n=o-e/2;i.geometry=i.options.geometry={type:"Polygon",coordinates:[[[a,n],[a+t,n],[a+t,n+e],[a,n+e],[a,n]]]}}return i}},{doc:g}=o(),{animObject:f,stop:m}=o(),{noop:b}=o(),{colorFromPoint:v,getContext:x}={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=>d(parseFloat(t),parseInt(t,10)));return o[3]=255*d(o[3],1),null!=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=g.createElement("canvas"),t.context=t.canvas.getContext("2d",{willReadFrequently:!0})||void 0,t.context)}},{seriesTypes:{map:w}}=a();function D(t){return t-360*Math.floor((t+180)/360)}class C extends w{constructor(){super(...arguments),this.isDirtyCanvas=!0}update(){this.options=c(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 h(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 r=this.context||x(this),{canvas:a,colorAxis:n,image:s,chart:l,points:h}=this,[u,y]=[d(e.colsize,1),d(e.rowsize,1)],g=t.projectedUnitsToPixels({x:this.bounds.x1,y:this.bounds.y2}),b=t.projectedUnitsToPixels({x:this.bounds.x2,y:this.bounds.y1});if(a&&r&&n&&g&&b){let{x:e,y:n}=g,d=b.x-e,x=b.y-n,w={x:e,y:n,width:d,height:x};if(this.isDirtyCanvas||this.isDirtyData||"Orthographic"===t.projection.options.name){let s=a.width=~~(360/u)+1,l=a.height=~~(180/y)+1,c=new Uint8ClampedArray(s*l*4),{lat:g=0,lon:f=0}=h[0].options,m=f%y!=0,b=g%u!=0,w=m?t=>Math.round(t/y)*y:t=>t,D=b?t=>Math.round(t/u)*u:t=>t,C=h.length;(m||b)&&(0,i.error)("Highcharts Warning: For best performance, lon/lat datapoints should spaced by a single colsize/rowsize",!1,this.chart,{colsize:String(u),rowsize:String(y)}),this.directTouch=!1,this.isDirtyCanvas=!0;for(let t=0;t<C;t++){var o;let e=h[t],{lon:i,lat:r}=e.options;p(i)&&p(r)&&c.set(v(e.value,e),4*(o=w(i),Math.ceil(s*(l-1-(D(r)+90)/y)+(o+180)/u)))}let P=this.getInterpolation().blur,j=0===P?1:11*P,O=~~(s*j),I=~~(l*j),T=~~d,A=~~x,L=new ImageData(c,s,l);a.width=O,a.height=I,r.putImageData(L,0,0),r.globalCompositeOperation="copy",r.drawImage(a,0,0,L.width,L.height,0,0,O,I);let z=this.getProjectedImageData(t,T,A,r.getImageData(0,0,O,I),a,e,n);a.width=T,a.height=A,r.putImageData(new ImageData(z,T,A),0,0)}if(s)if(l.renderer.globalAnimation&&l.hasRendered){let t=Number(s.attr("x")),i=Number(s.attr("y")),o=Number(s.attr("width")),r=Number(s.attr("height")),p=(a,l)=>{let p=l.pos;s.attr({x:t+(e-t)*p,y:i+(n-i)*p,width:o+(d-o)*p,height:r+(x-r)*p})},h=c(f(l.renderer.globalAnimation)),u=h.step;h.step=function(){u&&u.apply(this,arguments),p.apply(this,arguments)},s.attr(c({animator:0},this.isDirtyCanvas?{href:a.toDataURL("image/png",1)}:void 0)).animate({animator:1},h)}else m(s),s.attr(c(w,this.isDirtyCanvas?{href:a.toDataURL("image/png",1)}:void 0));else this.image=l.renderer.image(a.toDataURL("image/png",1)).attr(w).add(this.group);this.isDirtyCanvas=!1}}else super.drawPoints.apply(this,arguments)}getProjectedImageData(t,e,i,o,r,a,n){let s=new Uint8ClampedArray(e*i*4),l=d(t.projection.options.rotation?.[0],0),p=r.width/360,h=-1*r.height/180,c=-1;for(let i=0;i<s.length;i+=4){let d=i/4%e;0===d&&c++;let u=t.pixelsToLonLat({x:a+d,y:n+c});if(u){u.lon>-180-l&&u.lon<180-l&&(u.lon=D(u.lon));let t=[u.lon,u.lat],e=t[0]*p+r.width/2,a=t[1]*h+r.height/2;if(e>=0&&e<=r.width&&a>=0&&a<=r.height){let t=Math.floor(a)*r.width*4+4*Math.round(e);s[i]=o.data[t],s[i+1]=o.data[t+1],s[i+2]=o.data[t+2],s[i+3]=o.data[t+3]}}}return s}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 r=o.projectedUnitsToPixels({x:this.bounds.x1,y:this.bounds.y2}),a=o.projectedUnitsToPixels({x:this.bounds.x2,y:this.bounds.y1});if(i.pointer.normalize(t),t.lon&&t.lat&&r&&a&&t.chartX-i.plotLeft>r.x&&t.chartX-i.plotLeft<a.x&&t.chartY-i.plotTop>r.y&&t.chartY-i.plotTop<a.y)return this.searchKDTree({clientX:t.chartX,lon:D(t.lon),lat:t.lat},e,t)}else i.tooltip.destroy()}}C.defaultOptions=c(w.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}}),function(t,e,i,r={}){let a="function"==typeof t&&t.prototype||t;Object.hasOwnProperty.call(a,"hcEvents")||(a.hcEvents={});let n=a.hcEvents;o().Point&&t instanceof o().Point&&t.series&&t.series.chart&&(t.series.chart.runTrackerClick=!0);let s=t.addEventListener;s&&s.call(t,e,i,!!o().supportsPassiveEvents&&{passive:void 0===r.passive?-1!==e.indexOf("touch"):r.passive,capture:!1}),n[e]||(n[e]=[]);let l={fn:i,order:"number"==typeof r.order?r.order:1/0};n[e].push(l),n[e].sort((t,e)=>t.order-e.order)}(C,"afterDataClassLegendClick",function(){this.isDirtyCanvas=!0,this.drawPoints()}),function(t,e){let i;for(i in t||(t={}),e)t[i]=e[i]}(C.prototype,{type:"geoheatmap",applyJitter:b,pointClass:y,pointArrayMap:["lon","lat","value"],kdAxisArray:["lon","lat"]}),a().registerSeriesType("geoheatmap",C);let P=o();export{P as default};