highcharts
Version:
JavaScript charting framework
13 lines • 21.9 kB
JavaScript
let t;/**
* Highcharts JS v12.6.0 (2026-04-13)
* @module highcharts/modules/marker-clusters
* @requires highcharts
*
* Marker clusters module for Highcharts
*
* (c) 2010-2026 Highsoft AS
* Author: Wojciech Chmiel
*
* A commercial license may be required depending on use.
* See www.highcharts.com/license
*/import*as e from"../highcharts.js";var i={};i.n=t=>{var e=t&&t.__esModule?()=>t.default:()=>t;return i.d(e,{a:e}),e},i.d=(t,e)=>{for(var r in e)i.o(e,r)&&!i.o(t,r)&&Object.defineProperty(t,r,{enumerable:!0,get:e[r]})},i.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e);let r=e.default;var s=i.n(r);let o={cluster:{enabled:!1,allowOverlap:!0,animation:{duration:500},drillToCluster:!0,minimumClusterSize:2,layoutAlgorithm:{gridSize:50,distance:40,kmeansThreshold:100},marker:{symbol:"cluster",radius:15,lineWidth:0,lineColor:"#ffffff"},dataLabels:{enabled:!0,format:"{point.clusterPointsAmount}",verticalAlign:"middle",align:"center",style:{color:"contrast"},inside:!0}},tooltip:{clusterFormat:"<span>Clustered points: {point.clusterPointsAmount}</span><br/>"}},{doc:n,win:a}=s();function l(t,e,i,r={}){let o="function"==typeof t&&t.prototype||t;Object.hasOwnProperty.call(o,"hcEvents")||(o.hcEvents={});let n=o.hcEvents;s().Point&&t instanceof s().Point&&t.series&&t.series.chart&&(t.series.chart.runTrackerClick=!0);let a=t.addEventListener;a&&a.call(t,e,i,!!s().supportsPassiveEvents&&{passive:void 0===r.passive?-1!==e.indexOf("touch"):r.passive,capture:!1}),n[e]||(n[e]=[]);let u={fn:i,order:"number"==typeof r.order?r.order:1/0};return n[e].push(u),n[e].sort((t,e)=>t.order-e.order),function(){!function(t,e,i){function r(e,i){let r=t.removeEventListener;r&&r.call(t,e,i,!1)}function s(i){let s,o;t.nodeName&&(e?(s={})[e]=!0:s=i,x(s,function(t,e){if(i[e])for(o=i[e].length;o--;)r(e,i[e][o].fn)}))}let o="function"==typeof t&&t.prototype||t;if(Object.hasOwnProperty.call(o,"hcEvents")){let t=o.hcEvents;if(e){let o=t[e]||[];i?(t[e]=o.filter(function(t){return i!==t.fn}),r(e,i)):(s(t),t[e]=[])}else s(t),delete o.hcEvents}}(t,e,i)}}function u(t){return null!=t}function p(t,e){let i;for(i in t||(t={}),e)t[i]=e[i];return t}function h(t,e,i,r){if(i=i||{},n?.createEvent&&(t.dispatchEvent||t.fireEvent&&t!==s())){let r=n.createEvent("Events");r.initEvent(e,!0,!0),i=p(r,i),t.dispatchEvent?t.dispatchEvent(i):t.fireEvent(e,i)}else if(t.hcEvents){i.target||p(i,{preventDefault:function(){i.defaultPrevented=!0},target:t,type:e});let r=[],s=t,o=!1;for(;s.hcEvents;)Object.hasOwnProperty.call(s,"hcEvents")&&s.hcEvents[e]&&(r.length&&(o=!0),r.unshift.apply(r,s.hcEvents[e])),s=Object.getPrototypeOf(s);o&&r.sort((t,e)=>t.order-e.order),r.forEach(e=>{!1===e.fn.call(t,i,t)&&i.preventDefault()})}r&&!i.defaultPrevented&&r.call(t,i)}function d(t){return g(t)&&"number"==typeof t.nodeType}function c(t){return"number"==typeof t&&!isNaN(t)&&t<1/0&&t>-1/0}function f(t){let e=Object.prototype.toString.call(t);return"[object Array]"===e||"[object Array Iterator]"===e}function m(t){return"function"==typeof t}function g(t,e){return!!t&&"object"==typeof t&&(!e||!f(t))}function y(t,...e){let i,r=[t,...e],s={},o=function(t,e){return"object"!=typeof t&&(t={}),x(e,function(i,r){if("__proto__"!==r&&"constructor"!==r){let s;!g(i,!0)||(s=i?.constructor,g(i,!0)&&!d(i)&&s?.name&&"Object"!==s.name)||d(i)?t[r]=e[r]:t[r]=o(t[r]||{},i)}}),t};!0===t&&(s=r[1],r=Array.prototype.slice.call(r,2));let n=r.length;for(i=0;i<n;i++)s=o(s,r[i]);return s}function x(t,e,i){for(let r in t)Object.hasOwnProperty.call(t,r)&&e.call(i||t[r],t[r],r,t)}function C(t,e,i){return/%$/.test(t)?e*parseFloat(t)/100+(i||0):parseFloat(t)}function b(t,e,i){return e>0?setTimeout(t,e,i):(t.call(0,i),-1)}Array.prototype.find;let{setLength:k,splice:I}={convertToNumber:function(t,e){switch(typeof t){case"boolean":return+!!t;case"number":return isNaN(t)&&!e?null:t;default:return isNaN(t=parseFloat(`${t??""}`))&&!e?null:t}},setLength:function(t,e,i){return Array.isArray(t)?(t.length=e,t):t[i?"subarray":"slice"](0,e)},splice:function(t,e,i,r,s=[]){if(Array.isArray(t))return Array.isArray(s)||(s=Array.from(s)),{removed:t.splice(e,i,...s),array:t};let o=Object.getPrototypeOf(t).constructor,n=t[r?"subarray":"slice"](e,e+i),a=new o(t.length-i+s.length);return a.set(t.subarray(0,e),0),a.set(s,e),a.set(t.subarray(e+i),e+s.length),{removed:n,array:a}}},M=class{constructor(t={}){this.autoId=!t.id,this.columns={},this.id=t.id||(0,r.uniqueKey)(),this.rowCount=0,this.versionTag=(0,r.uniqueKey)();let e=0;x(t.columns||{},(t,i)=>{this.columns[i]=t.slice(),e=Math.max(e,t.length)}),this.applyRowCount(e)}applyRowCount(t){this.rowCount=t,x(this.columns,(e,i)=>{e.length!==t&&(this.columns[i]=k(e,t))})}deleteRows(t,e=1){if(e>0&&t<this.rowCount){let i=0;x(this.columns,(r,s)=>{this.columns[s]=I(r,t,e).array,i=r.length}),this.rowCount=i}h(this,"afterDeleteRows",{rowIndex:t,rowCount:e}),this.versionTag=(0,r.uniqueKey)()}getColumn(t,e){return this.columns[t]}getColumns(t,e){return(t||Object.keys(this.columns)).reduce((t,e)=>(t[e]=this.columns[e],t),{})}getRow(t,e){return(e||Object.keys(this.columns)).map(e=>this.columns[e]?.[t])}setColumn(t,e=[],i=0,r){this.setColumns({[t]:e},i,r)}setColumns(t,e,i){let s=this.rowCount;x(t,(t,e)=>{this.columns[e]=t.slice(),s=t.length}),this.applyRowCount(s),i?.silent||(h(this,"afterSetColumns"),this.versionTag=(0,r.uniqueKey)())}setRow(t,e=this.rowCount,i,s){let{columns:o}=this,n=i?this.rowCount+1:e+1,a=Object.keys(t);if(s?.addColumns!==!1)for(let t=0,e=a.length;t<e;t++){let e=a[t];o[e]||(o[e]=[])}x(o,(r,a)=>{r||s?.addColumns===!1||(r=Array(n)),r&&(i?r=I(r,e,0,!0,[t[a]??null]).array:r[e]=t[a]??null,o[a]=r)}),n>this.rowCount&&this.applyRowCount(n),s?.silent||(h(this,"afterSetRows"),this.versionTag=(0,r.uniqueKey)())}getModified(){return this.modified||this}},{animObject:S}=s(),{cluster:v}=o,w={grid:function(t,e,i,r){let s,o,n,a,l,u={},p=this.getGridOffset(),h=this.getScaledGridSize(r);for(l=0;l<t.length;l++){let r=$(this,{x:t[l],y:e[l]});s=r.x-p.plotLeft,o=r.y-p.plotTop,n=Math.floor(s/h),u[a=Math.floor(o/h)+":"+n]??(u[a]=[]),u[a].push({dataIndex:i[l],x:t[l],y:e[l]})}return u},kmeans:function(t,e,i,r){let s=[],o=[],n={},a=Number(r.processedDistance??C(r.distance||v.layoutAlgorithm.distance,this.chart.plotWidth)),l=r.iterations,u=0,p=!0,h=0,d=0,c,f=[];r.processedGridSize=a;let m=this.markerClusterAlgorithms?this.markerClusterAlgorithms.grid.call(this,t,e,i,r):{};for(let t in m)m[t].length>1&&(c=L(m[t]),s.push({posX:c.x,posY:c.y,oldX:0,oldY:0,startPointsLen:m[t].length,points:[]}));for(;p;){for(let t of s)t.points.length=0;o.length=0;for(let r=0;r<t.length;r++)h=t[r],d=e[r],(f=this.getClusterDistancesFromPoint(s,h,d)).length&&f[0].distance<a?s[f[0].clusterIndex].points.push({x:h,y:d,dataIndex:i[r]}):o.push({x:h,y:d,dataIndex:i[r]});for(let t=0;t<s.length;t++)1===s[t].points.length&&(f=this.getClusterDistancesFromPoint(s,s[t].points[0].x,s[t].points[0].y))[1].distance<a&&(s[f[1].clusterIndex].points.push(s[t].points[0]),s[f[0].clusterIndex].points.length=0);p=!1;for(let t=0;t<s.length;t++)c=L(s[t].points),s[t].oldX=s[t].posX,s[t].oldY=s[t].posY,s[t].posX=c.x,s[t].posY=c.y,(s[t].posX>s[t].oldX+1||s[t].posX<s[t].oldX-1||s[t].posY>s[t].oldY+1||s[t].posY<s[t].oldY-1)&&(p=!0);l&&(p=u<l-1),u++}for(let t=0,e=s.length;t<e;++t)n["cluster"+t]=s[t].points;for(let t=0,e=o.length;t<e;++t)n["noise"+t]=[o[t]];return n},optimizedKmeans:function(t,e,i,r){let s=Number(r.processedDistance??C(r.distance||v.layoutAlgorithm.gridSize,this.chart.plotWidth)),o=this.getRealExtremes(),n=(this.options.cluster||{}).marker,a,l={};if(!this.markerClusterInfo||this.initMaxX&&this.initMaxX<o.maxX||this.initMinX&&this.initMinX>o.minX||this.initMaxY&&this.initMaxY<o.maxY||this.initMinY&&this.initMinY>o.minY)this.initMaxX=o.maxX,this.initMinX=o.minX,this.initMaxY=o.maxY,this.initMinY=o.minY,l=this.markerClusterAlgorithms?this.markerClusterAlgorithms.kmeans.call(this,t,e,i,r):{},this.baseClusters=null;else{for(let t of(this.baseClusters??(this.baseClusters={clusters:this.markerClusterInfo.clusters,noise:this.markerClusterInfo.noise}),this.baseClusters.clusters)){for(let e of(t.pointsOutside=[],t.pointsInside=[],t.data)){let i=$(this,e),r=$(this,t);a=Math.sqrt(Math.pow(i.x-r.x,2)+Math.pow(i.y-r.y,2));let o=t.clusterZone?.marker?.radius??n?.radius??v.marker.radius??0,l=s-o>=0?s-o:o;a>o+l&&u(t.pointsOutside)?t.pointsOutside.push(e):u(t.pointsInside)&&t.pointsInside.push(e)}t.pointsInside.length&&(l[t.id]=t.pointsInside);let e=0;for(let i of t.pointsOutside)l[t.id+"_noise"+e++]=[i]}for(let t of this.baseClusters.noise)l[t.id]=t.data}return l}},A,P=[],O=0;function X(t,e,i){t.attr({opacity:e}).animate({opacity:1},i)}function Y(t,e,i,r){for(let s of(E(t,r,i,!0,!0),e))s.point?.destroy?.()}function E(t,e,i,r,s){t.point&&(r&&t.point.graphic&&(t.point.graphic.show(),X(t.point.graphic,e,i)),s&&t.point.dataLabel&&(t.point.dataLabel.show(),X(t.point.dataLabel,e,i)))}function L(t){let e=t.length,i=0,r=0;for(let s=0;s<e;s++)i+=t[s].x,r+=t[s].y;return{x:i/e,y:r/e}}function z(t,e){let i=[];return i.length=e,t.clusters.forEach(function(t){t.data.forEach(function(t){i[t.dataIndex]=t})}),t.noise.forEach(function(t){i[t.data[0].dataIndex]=t.data[0]}),i}function D(){return Math.random().toString(36).substring(2,7)+"-"+O++}function T(t,e,i){t.point&&(e&&t.point.graphic&&t.point.graphic.hide(),i&&t.point.dataLabel&&t.point.dataLabel.hide())}function j(t){(t.point||t.target).firePointEvent("drillToCluster",t,function(t){let e=t.point||t.target,i=e.series,{xAxis:r,yAxis:s,chart:o}=i,{inverted:n,mapView:a,pointer:l}=o;if(i.options.cluster?.drillToCluster&&e.clusteredData){let t=e.clusteredData.map(t=>t.x).sort((t,e)=>t-e),i=e.clusteredData.map(t=>t.y).sort((t,e)=>t-e),u=t[0],p=t[t.length-1],h=i[0],d=i[i.length-1],c=Math.abs((p-u)*.1),f=Math.abs((d-h)*.1),m=Math.min(u,p)-c,g=Math.max(u,p)+c,y=Math.min(h,d)-f,x=Math.max(h,d)+f;if(a)a.fitToBounds({x1:m,x2:g,y1:y,y2:x});else if(r&&s){let t=r.toPixels(m),e=r.toPixels(g),i=s.toPixels(y),a=s.toPixels(x);n&&([t,e,i,a]=[i,a,t,e]),t>e&&([t,e]=[e,t]),i>a&&([i,a]=[a,i]),l&&(l.zoomX=!0,l.zoomY=!0),o.transform({from:{x:t,y:i,width:e-t,height:a-i}})}}})}function R(t,e){let{chart:i,xAxis:r,yAxis:s}=t;return i.mapView?i.mapView.pixelsToProjectedUnits(e):{x:r?r.toValue(e.x):0,y:s?s.toValue(e.y):0}}function V(t){let e=this.chart,i=e.mapView,r=S(this.options.cluster?.animation),s=r.duration||500,o=this.markerClusterInfo?.pointsState,n=o?.newState,a=o?.oldState,l=[],u,p,h,d=0,c=0,f=0,m=!1,g=!1;if(a&&n){let o=$(this,p=n[t.stateId]);c=o.x-(i?0:e.plotLeft),f=o.y-(i?0:e.plotTop),1===p.parentsId.length?(u=a[n?.[t.stateId].parentsId[0]],p.point?.graphic&&u.point?.plotX&&u.point.plotY&&(u.point.plotX!==p.point.plotX||u.point.plotY!==p.point.plotY)&&(h=p.point.graphic.getBBox(),d=p.point.graphic?.isImg?0:h.width/2,p.point.graphic.attr({x:u.point.plotX-d,y:u.point.plotY-d}),p.point.graphic.animate({x:c-(p.point.graphic.radius||0),y:f-(p.point.graphic.radius||0)},r,function(){g=!0,u.point?.destroy?.()}),p.point.dataLabel?.alignAttr&&u.point.dataLabel?.alignAttr&&(p.point.dataLabel.attr({x:u.point.dataLabel.alignAttr.x,y:u.point.dataLabel.alignAttr.y}),p.point.dataLabel.animate({x:p.point.dataLabel.alignAttr.x,y:p.point.dataLabel.alignAttr.y},r)))):0===p.parentsId.length?(T(p,!0,!0),b(function(){E(p,.1,r,!0,!0)},s/2)):(T(p,!0,!0),p.parentsId.forEach(function(t){a?.[t]&&(u=a[t],l.push(u),u.point?.graphic&&(m=!0,u.point.graphic.show(),u.point.graphic.animate({x:c-(u.point.graphic.radius||0),y:f-(u.point.graphic.radius||0),opacity:.4},r,function(){g=!0,Y(p,l,r,.7)}),u.point.dataLabel&&-9999!==u.point.dataLabel.y&&p.point?.dataLabel?.alignAttr&&(u.point.dataLabel.show(),u.point.dataLabel.animate({x:p.point.dataLabel.alignAttr.x,y:p.point.dataLabel.alignAttr.y,opacity:.4},r))))}),b(function(){g||Y(p,l,r,.85)},s),m||b(function(){Y(p,l,r,.1)},s/2))}}function G(){this.markerClusterSeriesData?.forEach(t=>{t?.destroy?.()}),this.markerClusterSeriesData=null}function N(){let t,e,i,r,s,o,n,a,p,h,d,f,g,y,x,b=this,{chart:k}=b,I=k.mapView,S=b.getColumn("x"),w=b.getColumn("y"),P=b.options.cluster,O=b.getRealExtremes(),X=[],Y=[],E=[];if(I&&b.is("mappoint")&&S&&w&&b.options.data?.forEach((t,e)=>{let i=b.projectPoint(t);i&&(S[e]=i.x,w[e]=i.y)}),P?.enabled&&S?.length&&w?.length&&!k.polar){d=P.layoutAlgorithm.type,(y=P.layoutAlgorithm).processedGridSize=C(y.gridSize||v.layoutAlgorithm.gridSize,k.plotWidth),y.processedDistance=C(y.distance||v.layoutAlgorithm.distance,k.plotWidth),r=y.kmeansThreshold||v.layoutAlgorithm.kmeansThreshold;let I=y.processedGridSize/2,z=R(b,{x:0,y:0}),D=R(b,{x:I,y:I});s=Math.abs(z.x-D.x),o=Math.abs(z.y-D.y);for(let t=0;t<S.length;t++)!b.dataMaxX&&(u(a)&&u(n)&&u(h)&&u(p)?c(w[t])&&c(h)&&c(p)&&(a=Math.max(S[t],a),n=Math.min(S[t],n),h=Math.max(w[t]||h,h),p=Math.min(w[t]||p,p)):(a=n=S[t],h=p=w[t])),S[t]>=O.minX-s&&S[t]<=O.maxX+s&&(w[t]||O.minY)>=O.minY-o&&(w[t]||O.maxY)<=O.maxY+o&&(X.push(S[t]),Y.push(w[t]),E.push(t));if(u(a)&&u(n)&&c(h)&&c(p)&&(b.dataMaxX=a,b.dataMinX=n,b.dataMaxY=h,b.dataMinY=p),f=(g=(m(d)?d:b.markerClusterAlgorithms?d&&b.markerClusterAlgorithms[d]?b.markerClusterAlgorithms[d]:X.length<r?b.markerClusterAlgorithms.kmeans:b.markerClusterAlgorithms.grid:()=>!1).call(this,X,Y,E,y))?b.getClusteredData(g,P):g,P.animation&&b.markerClusterInfo?.pointsState?.oldState){var L=b.markerClusterInfo.pointsState.oldState;for(let t of Object.keys(L))L[t].point?.destroy?.();t=b.markerClusterInfo.pointsState.newState}else t={};e=S.length,i=b.markerClusterInfo,f&&(b.dataTable.modified=new M({columns:{x:f.groupedXData,y:f.groupedYData}}),b.hasGroupedData=!0,b.markerClusterInfo=f,b.groupMap=f.groupMap),A.apply(this),f&&b.markerClusterInfo&&(b.markerClusterInfo.clusters?.forEach(t=>{(x=b.points[t.index]).isCluster=!0,x.clusteredData=t.data,x.clusterPointsAmount=t.data.length,t.point=x,l(x,"click",j)}),b.markerClusterInfo.noise?.forEach(t=>{t.point=b.points[t.index]}),P.animation&&b.markerClusterInfo&&(b.markerClusterInfo.pointsState={oldState:t,newState:b.getPointsState(f,i,e)}),P.animation?this.hideClusteredData():this.destroyClusteredData(),this.markerClusterSeriesData=this.hasGroupedData?this.points:null)}else A.apply(this)}function F(t,e,i){let r=[];for(let s=0;s<t.length;s++){let o=$(this,{x:e,y:i}),n=$(this,{x:t[s].posX,y:t[s].posY}),a=Math.sqrt(Math.pow(o.x-n.x,2)+Math.pow(o.y-n.y,2));r.push({clusterIndex:s,distance:a})}return r.sort((t,e)=>t.distance-e.distance)}function _(t,e){let i=this.options.data,s=[],o=[],n=[],a=[],l=[],u=Math.max(2,e.minimumClusterSize||2),p=0,h,d,c,x,C,b,k,I,M,S,w,A;if(m(e.layoutAlgorithm.type)&&!this.isValidGroupedDataObject(t))return(0,r.error)("Highcharts marker-clusters module: The custom algorithm result is not valid!",!1,this.chart),!1;for(let r in t)if(t[r].length>=u){if(c=t[r],h=D(),C=c.length,e.zones)for(let t=0;t<e.zones.length;t++)C>=e.zones[t].from&&C<=e.zones[t].to&&((w=e.zones[t]).zoneIndex=t,S=e.zones[t].marker,A=e.zones[t].className);M=L(c),"grid"!==e.layoutAlgorithm.type||e.allowOverlap?k={x:M.x,y:M.y}:(b=this.options.marker||{},k=this.preventClusterCollisions({x:M.x,y:M.y,key:r,groupedData:t,gridSize:this.getScaledGridSize(e.layoutAlgorithm),defaultRadius:b.radius||3+(b.lineWidth||0),clusterRadius:S?.radius??e.marker?.radius??v.marker.radius??0}));for(let t=0;t<C;t++)c[t].parentStateId=h;if(n.push({x:k.x,y:k.y,id:r,stateId:h,index:p,data:c,clusterZone:w,clusterZoneClassName:A}),s.push(k.x),o.push(k.y),l.push({options:{formatPrefix:"cluster",dataLabels:e.dataLabels,marker:y(e.marker,{states:e.states},S||{})}}),i?.length)for(let t=0;t<C;t++)g(i[c[t].dataIndex])&&(c[t].options=i[c[t].dataIndex]);p++,S=null}else for(let e=0;e<t[r].length;e++)d=t[r][e],h=D(),I=null,x=i?.[d.dataIndex],s.push(d.x),o.push(d.y),d.parentStateId=h,a.push({x:d.x,y:d.y,id:r,stateId:h,index:p,data:t[r]}),I=x&&"object"==typeof x&&!f(x)?y(x,{x:d.x,y:d.y}):{userOptions:x,x:d.x,y:d.y},l.push({options:I}),p++;return{clusters:n,noise:a,groupedXData:s,groupedYData:o,groupMap:l}}function W(){let{chart:t,xAxis:e,yAxis:i}=this,r=0;return{plotLeft:r=e&&this.dataMinX&&this.dataMaxX?e.reversed?e.toPixels(this.dataMaxX):e.toPixels(this.dataMinX):t.plotLeft,plotTop:i&&this.dataMinY&&this.dataMaxY?i.reversed?i.toPixels(this.dataMinY):i.toPixels(this.dataMaxY):t.plotTop}}function q(t,e,i){let r,s,o=e?z(e,i):[],n=z(t,i),a={};P=[],t.clusters.forEach(t=>{a[t.stateId]={x:t.x,y:t.y,id:t.stateId,point:t.point,parentsId:[]}}),t.noise.forEach(t=>{a[t.stateId]={x:t.x,y:t.y,id:t.stateId,point:t.point,parentsId:[]}});for(let t=0;t<n.length;t++)r=n[t],s=o[t],r?.parentStateId&&s?.parentStateId&&a[r.parentStateId]?.parentsId.indexOf(s.parentStateId)===-1&&(a[r.parentStateId].parentsId.push(s.parentStateId),-1===P.indexOf(s.parentStateId)&&P.push(s.parentStateId));return a}function K(){let t=this.chart,e=t.mapView?0:t.plotLeft,i=R(this,{x:e,y:t.mapView?0:t.plotTop}),r=R(this,{x:e+t.plotWidth,y:e+t.plotHeight}),s=i.x,o=r.x,n=i.y,a=r.y;return{minX:Math.min(s,o),maxX:Math.max(s,o),minY:Math.min(n,a),maxY:Math.max(n,a)}}function Z(t){let e=this.xAxis,i=this.chart.mapView,r=Number(t.processedGridSize??C(t.gridSize||v.layoutAlgorithm.gridSize,this.chart.plotWidth)),s=!0,o=1,n=1;this.gridValueSize||(i?this.gridValueSize=r/i.getScale():this.gridValueSize=Math.abs(e.toValue(r)-e.toValue(0)));let a=+(r/(i?this.gridValueSize*i.getScale():e.toPixels(this.gridValueSize)-e.toPixels(0))).toFixed(14);for(;s&&1!==a;){let t=Math.pow(2,o);a>.75&&a<1.25?s=!1:a>=1/t&&a<1/t*2?(s=!1,n=t):a<=t&&a>t/2&&(s=!1,n=1/t),o++}return r/n/a}function B(){let t=this.markerClusterSeriesData,e=this.markerClusterInfo?.pointsState?.oldState,i=P.map(t=>e?.[t].point?.id||"");t?.forEach(t=>{t&&-1!==i.indexOf(t.id)?(t.graphic&&t.graphic.hide(),t.dataLabel&&t.dataLabel.hide()):t?.destroy?.()})}function H(t){let e=!1;return!!g(t)&&(x(t,t=>{if(e=!0,!f(t)||!t.length){e=!1;return}for(let i=0;i<t.length;i++)if(!g(t[i])||!t[i].x||!t[i].y){e=!1;return}}),e)}function U(t){let[e,i]=t.key.split(":").map(parseFloat),r=t.gridSize,s=t.groupedData,o=t.defaultRadius,n=t.clusterRadius,a=i*r,l=e*r,p=$(this,t),h=[],d=this.options.cluster?.marker,c=this.options.cluster?.zones,f=this.getGridOffset(),m=p.x,g=p.y,y=0,x=0,C,b,k,I,M,S,w,A,P,O,X,Y;m-=f.plotLeft,g-=f.plotTop;for(let s=1;s<5;s++)for(w=0,k=s%2?-1:1,I=s<3?-1:1,M=Math.floor((m+k*n)/r),Y=[(S=Math.floor((g+I*n)/r))+":"+M,S+":"+i,e+":"+M];w<Y.length;w++)-1===h.indexOf(Y[w])&&Y[w]!==t.key&&h.push(Y[w]);for(let t of h)if(s[t]){s[t].posX||(O=L(s[t]),s[t].posX=O.x,s[t].posY=O.y);let p=$(this,{x:s[t].posX||0,y:s[t].posY||0});if(C=p.x-f.plotLeft,b=p.y-f.plotTop,[P,A]=t.split(":").map(parseFloat),c){y=s[t].length;for(let t=0;t<c.length;t++)y>=c[t].from&&y<=c[t].to&&(x=u(c[t].marker?.radius)?c[t].marker.radius||0:d?.radius?d.radius:v.marker.radius??0)}s[t].length>1&&0===x&&d?.radius?x=d.radius:1===s[t].length&&(x=o),X=n+x,x=0,A!==i&&Math.abs(m-C)<X&&(m=A-i<0?a+n:a+r-n),P!==e&&Math.abs(g-b)<X&&(g=P-e<0?l+n:l+r-n)}let E=R(this,{x:m+f.plotLeft,y:g+f.plotTop});return s[t.key].posX=E.x,s[t.key].posY=E.y,E}function $(t,e){let{chart:i,xAxis:r,yAxis:s}=t;return i.mapView?i.mapView.projectedUnitsToPixels(e):{x:r?r.toPixels(e.x):0,y:s?s.toPixels(e.y):0}}let J=function(t,e){let i=e.prototype;!i.markerClusterAlgorithms&&(A=i.generatePoints,i.markerClusterAlgorithms=w,i.animateClusterPoint=V,i.destroyClusteredData=G,i.generatePoints=N,i.getClusterDistancesFromPoint=F,i.getClusteredData=_,i.getGridOffset=W,i.getPointsState=q,i.getRealExtremes=K,i.getScaledGridSize=Z,i.hideClusteredData=B,i.isValidGroupedDataObject=H,i.preventClusterCollisions=U,l(e,"destroy",i.destroyClusteredData),t.plotOptions&&(t.plotOptions.series=y(t.plotOptions.series,o)))},{animObject:Q}=s(),{defaultOptions:tt}=s(),{composed:te}=s();function ti(){let t=this.chart,e=0;for(let i of t.series)i.markerClusterInfo&&(e=Q((i.options.cluster||{}).animation).duration||0);b(()=>{t.tooltip&&t.tooltip.destroy()},e)}function tr(){for(let t of this.series||[])if(t.markerClusterInfo){let e=t.options.cluster,i=((t.markerClusterInfo||{}).pointsState||{}).oldState;if((e||{}).animation&&t.markerClusterInfo&&0===(t.chart.pointer?.pinchDown||[]).length&&"pan"!==((t.xAxis||{}).eventArgs||{}).trigger&&i&&Object.keys(i).length){for(let e of t.markerClusterInfo.clusters)t.animateClusterPoint(e);for(let e of t.markerClusterInfo.noise)t.animateClusterPoint(e)}}}function ts(t){let e=(((t.point||t.target).series.options.cluster||{}).events||{}).drillToCluster;m(e)&&e.call(this,t)}function to(){if(this.dataGroup)return(0,r.error)("Highcharts marker-clusters module: Running `Point.update` when point belongs to clustered series is not supported.",!1,this.series.chart),!1}function tn(){let t=(this.options.cluster||{}).drillToCluster;if(this.markerClusterInfo&&this.markerClusterInfo.clusters)for(let e of this.markerClusterInfo.clusters)e.point&&e.point.graphic&&(e.point.graphic.addClass("highcharts-cluster-point"),t&&e.point&&(e.point.graphic.css({cursor:"pointer"}),e.point.dataLabel&&e.point.dataLabel.css({cursor:"pointer"})),u(e.clusterZone)&&e.point.graphic.addClass(e.clusterZoneClassName||"highcharts-cluster-zone-"+e.clusterZone.zoneIndex))}function ta(e,i,r,s){let o=r/2,n=s/2,a=t.arc(e+o,i+n,o-4,n-4,{start:.5*Math.PI,end:2.5*Math.PI,open:!1}),l=t.arc(e+o,i+n,o-3,n-3,{start:.5*Math.PI,end:2.5*Math.PI,innerR:o-2,open:!1});return t.arc(e+o,i+n,o-1,n-1,{start:.5*Math.PI,end:2.5*Math.PI,innerR:o,open:!1}).concat(l,a)}(tt.plotOptions||{}).series=y((tt.plotOptions||{}).series,o);let tl=s();({compose:function(t,e,i,r){var s;if(s="MarkerClusters",0>te.indexOf(s)&&te.push(s)){let s=r.prototype.pointClass,{scatter:o}=r.types;l(t,"setExtremes",ti),l(e,"render",tr),l(s,"drillToCluster",ts),l(s,"update",to),l(r,"afterRender",tn),o&&J(i,o)}}}).compose(tl.Axis,tl.Chart,tl.defaultOptions,tl.Series),({compose:function(e){(t=e.prototype.symbols).cluster=ta}}).compose(tl.SVGRenderer);let tu=s();export{tu as default};