highcharts
Version:
JavaScript charting framework
11 lines • 6.56 kB
JavaScript
!/**
* Highcharts JS v13.0.1 (2026-08-17)
* @module highcharts/modules/flowmap
* @requires highcharts
* @requires highcharts/modules/map
*
* (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/flowmap",["highcharts/highcharts"],function(t){return e(t,t.SeriesRegistry)}):"object"==typeof exports?exports["highcharts/modules/flowmap"]=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 s(t){let e=o[t];if(void 0!==e)return e.exports;let r=o[t]={exports:{}};return i[t](r,r.exports,s),r.exports}s.n=t=>{let e=t&&t.__esModule?()=>t.default:()=>t;return s.d(e,{a:e}),e},s.d=(t,e)=>{if(Array.isArray(e))for(var i=0;i<e.length;){var o=e[i++],r=e[i++];s.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)s.o(e,o)&&!s.o(t,o)&&Object.defineProperty(t,o,{enumerable:!0,get:e[o]})},s.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e);let r={};s.d(r,{default:()=>u});var n=s(944),a=s.n(n),p=s(512),h=s.n(p);let{seriesTypes:{mapline:{prototype:{pointClass:l}}}}=h(),d=class extends l{isValid(){let t=!!(this.options.to&&this.options.from);return[this.options.to,this.options.from].forEach(function(e){t=!!(t&&e&&((0,n.isString)(e)||(0,n.isNumber)((0,n.pick)(e[0],e.lat))&&(0,n.isNumber)((0,n.pick)(e[1],e.lon))))}),t}},{series:{prototype:{pointClass:f}},seriesTypes:{column:g,map:c,mapline:y}}=h();class m extends y{static getLength(t,e){return Math.sqrt(t*t+e*e)}static normalize(t,e){let i=this.getLength(t,e);return[t/i,e/i]}static markerEndPath(t,e,i,o){let s=(0,n.relativeLength)(o.width||0,this.getLength(e[0]-t[0],e[1]-t[1])),r=o.markerType||"arrow",[a,p]=this.normalize(e[0]-t[0],e[1]-t[1]),h=[];if("arrow"===r){let[o,r]=t;o-=a*s,r-=p*s,h.push(["L",o,r]),h.push(["L",i[0],i[1]]),[o,r]=e,o+=a*s,r+=p*s,h.push(["L",o,r])}if("mushroom"===r){let[o,r]=t,[n,l]=e,[d,f]=i,g=(n-o)/2+o,c=(l-r)/2+r;o-=a*s,r-=p*s,h.push(["L",o,r]),n+=a*s,l+=p*s,h.push(["Q",(d-g)*2+g,(f-c)*2+c,n,l])}return h}animate(t){let e=this.points;t||e.forEach(t=>{if(t.shapeArgs&&(0,n.isArray)(t.shapeArgs.d)&&t.shapeArgs.d.length){let e=t.shapeArgs.d,i=e[0][1],o=e[0][2];if(i&&o){let s=[];for(let t=0;t<e.length;t++){s.push([...e[t]]);for(let r=1;r<e[t].length;r++)s[t][r]=r%2?i:o}t.graphic&&(t.graphic.attr({d:s}),t.graphic.animate({d:e}))}}})}getLinkWidth(t){let e=this.options.width,i=t.options.weight||this.options.weight;if(t.options.weight=i,e&&!i)return e;let o=this.smallestWeight,s=this.greatestWeight;if(!(0,n.defined)(i)||!o||!s)return 0;let r=this.options.minWidth;return(i-o)*(this.options.maxWidth-r)/(s-o||1)+r}autoCurve(t,e,i,o,s,r){let n={x:i-t,y:o-e},a={x:(i-t)/2+t,y:(o-e)/2+e},p={x:a.x-s,y:a.y-r},h=n.x*p.x+n.y*p.y,l=Math.atan2(n.x*p.y-n.y*p.x,h),d=180*l/Math.PI;return d<0&&(d=360+d),-(.7*Math.sin(l=d*Math.PI/180))}pointAttribs(t,e){let i=c.prototype.pointAttribs.call(this,t,e);return i.fill=(0,n.pick)(t.options.fillColor,t.options.color,"none"===this.options.fillColor?null:this.options.fillColor,this.color),i["fill-opacity"]=(0,n.pick)(t.options.fillOpacity,this.options.fillOpacity),i["stroke-width"]=(0,n.pick)(t.options.lineWidth,this.options.lineWidth,1),t.options.opacity&&(i.opacity=t.options.opacity),i}translate(){this.chart.hasRendered&&(this.isDirtyData||!this.hasRendered)&&(this.processData(),this.generatePoints());let t=[],e=0,i=0;this.points.forEach(o=>{let s,r,a=this.chart,p=a.mapView,h=o.options,l=()=>{o.series.isDirty=!0},d=t=>{let e=a.get(t);if(e instanceof f&&e.plotX&&e.plotY)return(0,n.addEvent)(e,"update",l),{x:e.plotX,y:e.plotY}},g=t=>(0,n.isArray)(t)?{lon:t[0],lat:t[1]}:t;"string"==typeof h.from?s=d(h.from):"object"==typeof h.from&&p&&(s=p.lonLatToPixels(g(h.from))),"string"==typeof h.to?r=d(h.to):"object"==typeof h.to&&p&&(r=p.lonLatToPixels(g(h.to))),o.fromPos=s,o.toPos=r,s&&r&&(e+=(s.x+r.x)/2,i+=(s.y+r.y)/2),(0,n.pick)(o.options.weight,this.options.weight)&&t.push((0,n.pick)(o.options.weight,this.options.weight))}),this.smallestWeight=(0,n.arrayMin)(t),this.greatestWeight=(0,n.arrayMax)(t),this.centerOfPoints={x:e/this.points.length,y:i/this.points.length},this.points.forEach(t=>{if(!this.getLinkWidth(t)){t.shapeArgs={d:[]};return}t.fromPos&&(t.plotX=t.fromPos.x,t.plotY=t.fromPos.y),t.shapeType="path",t.shapeArgs=this.getPointShapeArgs(t),t.color=(0,n.pick)(t.options.color,t.series.color)})}getPointShapeArgs(t){let{fromPos:e,toPos:i}=t;if(!e||!i)return{};let o=this.getLinkWidth(t)/2,s=t.options,r=(0,n.merge)(this.options.markerEnd,s.markerEnd),a=(0,n.pick)(s.growTowards,this.options.growTowards),p=e.x||0,h=e.y||0,l=i.x||0,d=i.y||0,f=(0,n.pick)(s.curveFactor,this.options.curveFactor),g=r&&r.enabled&&r.height||0;if((0,n.defined)(f)||(f=this.autoCurve(p,h,l,d,this.centerOfPoints.x,this.centerOfPoints.y)),g){g=(0,n.relativeLength)(g,4*o);let t=l-p,e=d-h,i=p+(t*=.5),s=h+(e*=.5),r=t,a=i+(t=e)*f,c=s+(e=-r)*f,[y,u]=m.normalize(a-l,c-d);y*=g,u*=g,l+=y,d+=u}let c=l-p,y=d-h,u=p+(c*=.5),x=h+(y*=.5),w=c;c=y,y=-w;let[b,P]=m.normalize(c,y),k=1+.25*Math.sqrt(f*f);b*=o*k,P*=o*k;let L=u+c*f,v=x+y*f,[A,W]=m.normalize(L-p,v-h);w=A,A=W,W=-w,A*=o,W*=o;let[O,M]=m.normalize(L-l,v-d);w=O,O=-M,M=w,O*=o,M*=o,a&&(A/=o,W/=o,b/=4,P/=4);let C={d:[["M",p-A,h-W],["Q",L-b,v-P,l-O,d-M],["L",l+O,d+M],["Q",L+b,v+P,p+A,h+W],["Z"]]};if(r&&r.enabled&&C.d){let t=m.markerEndPath([l-O,d-M],[l+O,d+M],[i.x,i.y],r);C.d.splice(2,0,...t)}let E=t.options.from,T=t.options.to,j=E.lat,S=E.lon,z=T.lat,H=T.lon;return j&&S&&(t.options.from=`${+j}, ${+S}`),z&&H&&(t.options.to=`${+z}, ${+H}`),C}}m.defaultOptions=(0,n.merge)(y.defaultOptions,{animation:!0,dataLabels:{enabled:!1},fillOpacity:.5,markerEnd:{enabled:!0,height:"40%",width:"40%",markerType:"arrow"},width:1,maxWidth:25,minWidth:5,lineWidth:void 0,tooltip:{headerFormat:'<span style="font-size: 0.8em">{series.name}</span><br/>',pointFormat:"{point.options.from} → {point.options.to}: <b>{point.options.weight}</b>"}}),(0,n.extend)(m.prototype,{pointClass:d,pointArrayMap:["from","to","weight"],drawPoints:g.prototype.drawPoints,getDataColumnKeys:g.prototype.getDataColumnKeys,useMapGeometry:!0}),h().registerSeriesType("flowmap",m);let u=a();return r.default})());