All Downloads are FREE. Search and download functionalities are using the official Maven repository.

package.modules.marker-clusters.js Maven / Gradle / Ivy

The newest version!
!/**
 * Highcharts JS v11.4.8 (2024-08-29)
 *
 * Marker clusters module for Highcharts
 *
 * (c) 2010-2024 Wojciech Chmiel
 *
 * License: www.highcharts.com/license
 */function(t){"object"==typeof module&&module.exports?(t.default=t,module.exports=t):"function"==typeof define&&define.amd?define("highcharts/modules/marker-clusters",["highcharts"],function(e){return t(e),t.Highcharts=e,t}):t("undefined"!=typeof Highcharts?Highcharts:void 0)}(function(t){"use strict";var e=t?t._modules:{};function i(e,i,s,a){e.hasOwnProperty(i)||(e[i]=a.apply(null,s),"function"==typeof CustomEvent&&t.win.dispatchEvent(new CustomEvent("HighchartsModuleLoaded",{detail:{path:i,module:e[i]}})))}i(e,"Extensions/MarkerClusters/MarkerClusterDefaults.js",[],function(){return{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:"Clustered points: {point.clusterPointsAmount}
"}}}),i(e,"Extensions/MarkerClusters/MarkerClusterScatter.js",[e["Core/Animation/AnimationUtilities.js"],e["Extensions/MarkerClusters/MarkerClusterDefaults.js"],e["Core/Utilities.js"]],function(t,e,i){let s;let{animObject:a}=t,{cluster:r}=e,{addEvent:o,defined:n,error:l,isArray:p,isFunction:u,isObject:d,isNumber:h,merge:c,objectEach:f,relativeLength:m,syncTimeout:g}=i,x={grid:function(t,e,i,s){let a,r,o,n,l;let p={},u=this.getGridOffset(),d=this.getScaledGridSize(s);for(l=0;l1&&(f=S(g[t]),a.push({posX:f.x,posY:f.y,oldX:0,oldY:0,startPointsLen:g[t].length,points:[]}));for(;d;){for(let t of a)t.points.length=0;o.length=0;for(let s=0;sa[t].oldX+1||a[t].posXa[t].oldY+1||a[t].posYo.minX||this.initMaxY&&this.initMaxYo.minY)this.initMaxX=o.maxX,this.initMinX=o.minX,this.initMaxY=o.maxY,this.initMinY=o.minY,u=this.markerClusterAlgorithms?this.markerClusterAlgorithms.kmeans.call(this,t,e,i,s):{},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=Z(this,e),s=Z(this,t);p=Math.sqrt(Math.pow(i.x-s.x,2)+Math.pow(i.y-s.y,2)),d=a-(h=t.clusterZone&&t.clusterZone.marker&&t.clusterZone.marker.radius?t.clusterZone.marker.radius:l&&l.radius?l.radius:r.marker.radius)>=0?a-h:h,p>h+d&&n(t.pointsOutside)?t.pointsOutside.push(e):n(t.pointsInside)&&t.pointsInside.push(e)}t.pointsInside.length&&(u[t.id]=t.pointsInside);let e=0;for(let i of t.pointsOutside)u[t.id+"_noise"+e++]=[i]}for(let t of this.baseClusters.noise)u[t.id]=t.data}return u}},y=[],C=0;function k(t,e,i){t.attr({opacity:e}).animate({opacity:1},i)}function M(t,e,i,s){for(let a of(I(t,s,i,!0,!0),e))a.point&&a.point.destroy&&a.point.destroy()}function I(t,e,i,s,a){t.point&&(s&&t.point.graphic&&(t.point.graphic.show(),k(t.point.graphic,e,i)),a&&t.point.dataLabel&&(t.point.dataLabel.show(),k(t.point.dataLabel,e,i)))}function S(t){let e=t.length,i=0,s=0;for(let a=0;at.x).sort((t,e)=>t-e),i=e.clusteredData.map(t=>t.y).sort((t,e)=>t-e),p=t[0],u=t[t.length-1],d=i[0],h=i[i.length-1],c=Math.abs((u-p)*.1),f=Math.abs((h-d)*.1),m=Math.min(p,u)-c,g=Math.max(p,u)+c,x=Math.min(d,h)-f,y=Math.max(d,h)+f;if(n)n.fitToBounds({x1:m,x2:g,y1:x,y2:y});else if(s&&a){let t=s.toPixels(m),e=s.toPixels(g),i=a.toPixels(x),n=a.toPixels(y);o&&([t,e,i,n]=[i,n,t,e]),t>e&&([t,e]=[e,t]),i>n&&([i,n]=[n,i]),l&&(l.zoomX=!0,l.zoomY=!0),r.transform({from:{x:t,y:i,width:e-t,height:n-i}})}}})}function D(t,e){let{chart:i,xAxis:s,yAxis:a}=t;return i.mapView?i.mapView.pixelsToProjectedUnits(e):{x:s?s.toValue(e.x):0,y:a?a.toValue(e.y):0}}function L(t){let e=this.chart,i=e.mapView,s=a((this.options.cluster||{}).animation),r=s.duration||500,o=(this.markerClusterInfo||{}).pointsState,n=(o||{}).newState,l=(o||{}).oldState,p=[],u,d,h,c=0,f=0,m=0,x=!1,y=!1;if(l&&n){let a=Z(this,d=n[t.stateId]);f=a.x-(i?0:e.plotLeft),m=a.y-(i?0:e.plotTop),1===d.parentsId.length?(u=l[(n||{})[t.stateId].parentsId[0]],d.point&&d.point.graphic&&u&&u.point&&u.point.plotX&&u.point.plotY&&u.point.plotX!==d.point.plotX&&u.point.plotY!==d.point.plotY&&(h=d.point.graphic.getBBox(),c=d.point.graphic&&d.point.graphic.isImg?0:h.width/2,d.point.graphic.attr({x:u.point.plotX-c,y:u.point.plotY-c}),d.point.graphic.animate({x:f-(d.point.graphic.radius||0),y:m-(d.point.graphic.radius||0)},s,function(){y=!0,u.point&&u.point.destroy&&u.point.destroy()}),d.point.dataLabel&&d.point.dataLabel.alignAttr&&u.point.dataLabel&&u.point.dataLabel.alignAttr&&(d.point.dataLabel.attr({x:u.point.dataLabel.alignAttr.x,y:u.point.dataLabel.alignAttr.y}),d.point.dataLabel.animate({x:d.point.dataLabel.alignAttr.x,y:d.point.dataLabel.alignAttr.y},s)))):0===d.parentsId.length?(X(d,!0,!0),g(function(){I(d,.1,s,!0,!0)},r/2)):(X(d,!0,!0),d.parentsId.forEach(function(t){l&&l[t]&&(u=l[t],p.push(u),u.point&&u.point.graphic&&(x=!0,u.point.graphic.show(),u.point.graphic.animate({x:f-(u.point.graphic.radius||0),y:m-(u.point.graphic.radius||0),opacity:.4},s,function(){y=!0,M(d,p,s,.7)}),u.point.dataLabel&&-9999!==u.point.dataLabel.y&&d.point&&d.point.dataLabel&&d.point.dataLabel.alignAttr&&(u.point.dataLabel.show(),u.point.dataLabel.animate({x:d.point.dataLabel.alignAttr.x,y:d.point.dataLabel.alignAttr.y,opacity:.4},s))))}),g(function(){y||M(d,p,s,.85)},r),x||g(function(){M(d,p,s,.1)},r/2))}}function P(){(this.markerClusterSeriesData||[]).forEach(function(t){t&&t.destroy&&t.destroy()}),this.markerClusterSeriesData=null}function z(){let t,e,i,a,l,p,d,c,f,g,x,y,C,k,M,I;let S=this,b=S.chart,A=b.mapView,X=S.xData,L=S.yData,P=S.options.cluster,z=S.getRealExtremes(),w=[],E=[],j=[];if(A&&S.is("mappoint")&&X&&L&&(S.options.data||[]).forEach((t,e)=>{let i=S.projectPoint(t);i&&(X[e]=i.x,L[e]=i.y)}),P&&P.enabled&&X&&X.length&&L&&L.length&&!b.polar){x=P.layoutAlgorithm.type,(k=P.layoutAlgorithm).processedGridSize=m(k.gridSize||r.layoutAlgorithm.gridSize,b.plotWidth),k.processedDistance=m(k.distance||r.layoutAlgorithm.distance,b.plotWidth),a=k.kmeansThreshold||r.layoutAlgorithm.kmeansThreshold;let A=k.processedGridSize/2,O=D(S,{x:0,y:0}),T=D(S,{x:A,y:A});for(I=0,l=Math.abs(O.x-T.x),p=Math.abs(O.y-T.y);I=z.minX-l&&X[I]<=z.maxX+l&&(L[I]||z.minY)>=z.minY-p&&(L[I]||z.maxY)<=z.maxY+p&&(w.push(X[I]),E.push(L[I]),j.push(I));n(c)&&n(d)&&h(g)&&h(f)&&(S.dataMaxX=c,S.dataMinX=d,S.dataMaxY=g,S.dataMinY=f),y=(C=(u(x)?x:S.markerClusterAlgorithms?x&&S.markerClusterAlgorithms[x]?S.markerClusterAlgorithms[x]:w.lengtht.distance-e.distance)}function E(t,e){let i=[],s=[],a=[],o=[],n=[],h=Math.max(2,e.minimumClusterSize||2),f=0,m,g,x,y,C,k,M,I,b,X,Y,D,L,P;if(u(e.layoutAlgorithm.type)&&!this.isValidGroupedDataObject(t))return l("Highcharts marker-clusters module: The custom algorithm result is not valid!",!1,this.chart),!1;for(P in t)if(t[P].length>=h){if(x=t[P],m=A(),C=x.length,e.zones)for(L=0;L=e.zones[L].from&&C<=e.zones[L].to&&((Y=e.zones[L]).zoneIndex=L,X=e.zones[L].marker,D=e.zones[L].className);for(b=S(x),"grid"!==e.layoutAlgorithm.type||e.allowOverlap?M={x:b.x,y:b.y}:(k=this.options.marker||{},M=this.preventClusterCollisions({x:b.x,y:b.y,key:P,groupedData:t,gridSize:this.getScaledGridSize(e.layoutAlgorithm),defaultRadius:k.radius||3+(k.lineWidth||0),clusterRadius:X&&X.radius?X.radius:(e.marker||{}).radius||r.marker.radius})),L=0;L.75&&l<1.25?a=!1:l>=1/t&&l<1/t*2?(a=!1,n=t):l<=t&&l>t/2&&(a=!1,n=1/t),o++}return s/n/l}function G(){let t=this.markerClusterSeriesData,e=((this.markerClusterInfo||{}).pointsState||{}).oldState||{},i=y.map(t=>(e[t].point||{}).id||"");(t||[]).forEach(function(t){t&&-1!==i.indexOf(t.id)?(t.graphic&&t.graphic.hide(),t.dataLabel&&t.dataLabel.hide()):t&&t.destroy&&t.destroy()})}function v(t){let e=!1,i;return!!d(t)&&(f(t,function(t){if(e=!0,!p(t)||!t.length){e=!1;return}for(i=0;i=f[Y].from&&y<=f[Y].to&&(C=n((f[Y].marker||{}).radius)?f[Y].marker.radius||0:c&&c.radius?c.radius:r.marker.radius);a[t].length>1&&0===C&&c&&c.radius?C=c.radius:1===a[t].length&&(C=o),E=l+C,C=0,P!==i&&Math.abs(g-k){t.tooltip&&t.tooltip.destroy()},e)}function x(){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 y(t){let e=(((t.point||t.target).series.options.cluster||{}).events||{}).drillToCluster;h(e)&&e.call(this,t)}function C(){if(this.dataGroup)return d("Highcharts marker-clusters module: Running `Point.update` when point belongs to clustered series is not supported.",!1,this.series.chart),!1}function k(){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))}return(n.plotOptions||{}).series=c((n.plotOptions||{}).series,s),{compose:function(t,e,i,s){if(f(l,"MarkerClusters")){let r=s.prototype.pointClass,{scatter:o}=s.types;p(t,"setExtremes",g),p(e,"render",x),p(r,"drillToCluster",y),p(r,"update",C),p(s,"afterRender",k),o&&a.compose(i,o)}}}}),i(e,"Extensions/MarkerClusters/MarkerClusterSymbols.js",[],function(){let t;function e(e,i,s,a){let r=s/2,o=a/2,n=t.arc(e+r,i+o,r-4,o-4,{start:.5*Math.PI,end:2.5*Math.PI,open:!1}),l=t.arc(e+r,i+o,r-3,o-3,{start:.5*Math.PI,end:2.5*Math.PI,innerR:r-2,open:!1});return t.arc(e+r,i+o,r-1,o-1,{start:.5*Math.PI,end:2.5*Math.PI,innerR:r,open:!1}).concat(l,n)}return{compose:function(i){(t=i.prototype.symbols).cluster=e}}}),i(e,"masters/modules/marker-clusters.src.js",[e["Core/Globals.js"],e["Extensions/MarkerClusters/MarkerClusters.js"],e["Extensions/MarkerClusters/MarkerClusterSymbols.js"]],function(t,e,i){return e.compose(t.Axis,t.Chart,t.defaultOptions,t.Series),i.compose(t.SVGRenderer),t})});




© 2015 - 2024 Weber Informatics LLC | Privacy Policy