highcharts
Version:
JavaScript charting framework
10 lines • 7.7 kB
JavaScript
!/**
* Highcharts JS v12.6.0 (2026-04-13)
* @module highcharts/modules/flowmap
* @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/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 o={512:t=>{t.exports=e},944:e=>{e.exports=t}},i={};function r(t){var e=i[t];if(void 0!==e)return e.exports;var s=i[t]={exports:{}};return o[t](s,s.exports,r),s.exports}r.n=t=>{var e=t&&t.__esModule?()=>t.default:()=>t;return r.d(e,{a:e}),e},r.d=(t,e)=>{for(var o in e)r.o(e,o)&&!r.o(t,o)&&Object.defineProperty(t,o,{enumerable:!0,get:e[o]})},r.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e);var s={};r.d(s,{default:()=>L});var n=r(944),a=r.n(n),l=r(512),p=r.n(l);let{doc:h,win:c}=a();function f(t){return y(t)&&"number"==typeof t.nodeType}function u(t){return"number"==typeof t&&!isNaN(t)&&t<1/0&&t>-1/0}function d(t){let e=Object.prototype.toString.call(t);return"[object Array]"===e||"[object Array Iterator]"===e}function y(t,e){return!!t&&"object"==typeof t&&(!e||!d(t))}function g(t,...e){let o,i=[t,...e],r={},s=function(t,e){return"object"!=typeof t&&(t={}),function(t,e,o){for(let i in t)Object.hasOwnProperty.call(t,i)&&e.call(o||t[i],t[i],i,t)}(e,function(o,i){if("__proto__"!==i&&"constructor"!==i){let r;!y(o,!0)||(r=o?.constructor,y(o,!0)&&!f(o)&&r?.name&&"Object"!==r.name)||f(o)?t[i]=e[i]:t[i]=s(t[i]||{},o)}}),t};!0===t&&(r=i[1],i=Array.prototype.slice.call(i,2));let n=i.length;for(o=0;o<n;o++)r=s(r,i[o]);return r}Array.prototype.find;function m(){let t=arguments,e=t.length;for(let o=0;o<e;o++){let e=t[o];if(null!=e)return e}}function w(t,e,o){return/%$/.test(t)?e*parseFloat(t)/100+(o||0):parseFloat(t)}let{seriesTypes:{mapline:{prototype:{pointClass:x}}}}=p(),b=class extends x{isValid(){let t=!!(this.options.to&&this.options.from);return[this.options.to,this.options.from].forEach(function(e){t=!!(t&&e&&("string"==typeof e||u(m(e[0],e.lat))&&u(m(e[1],e.lon))))}),t}},{series:{prototype:{pointClass:P}},seriesTypes:{column:v,map:O,mapline:j}}=p();class A extends j{static getLength(t,e){return Math.sqrt(t*t+e*e)}static normalize(t,e){let o=this.getLength(t,e);return[t/o,e/o]}static markerEndPath(t,e,o,i){let r=w(i.width||0,this.getLength(e[0]-t[0],e[1]-t[1])),s=i.markerType||"arrow",[n,a]=this.normalize(e[0]-t[0],e[1]-t[1]),l=[];if("arrow"===s){let[i,s]=t;i-=n*r,s-=a*r,l.push(["L",i,s]),l.push(["L",o[0],o[1]]),[i,s]=e,i+=n*r,s+=a*r,l.push(["L",i,s])}if("mushroom"===s){let[i,s]=t,[p,h]=e,[c,f]=o,u=(p-i)/2+i,d=(h-s)/2+s;i-=n*r,s-=a*r,l.push(["L",i,s]),p+=n*r,h+=a*r,l.push(["Q",(c-u)*2+u,(f-d)*2+d,p,h])}return l}animate(t){let e=this.points;t||e.forEach(t=>{if(t.shapeArgs&&d(t.shapeArgs.d)&&t.shapeArgs.d.length){let e=t.shapeArgs.d,o=e[0][1],i=e[0][2];if(o&&i){let r=[];for(let t=0;t<e.length;t++){r.push([...e[t]]);for(let s=1;s<e[t].length;s++)r[t][s]=s%2?o:i}t.graphic&&(t.graphic.attr({d:r}),t.graphic.animate({d:e}))}}})}getLinkWidth(t){let e=this.options.width,o=t.options.weight||this.options.weight;if(t.options.weight=o,e&&!o)return e;let i=this.smallestWeight,r=this.greatestWeight;if(null==o||!i||!r)return 0;let s=this.options.minWidth;return(o-i)*(this.options.maxWidth-s)/(r-i||1)+s}autoCurve(t,e,o,i,r,s){let n={x:o-t,y:i-e},a={x:(o-t)/2+t,y:(i-e)/2+e},l={x:a.x-r,y:a.y-s},p=n.x*l.x+n.y*l.y,h=Math.atan2(n.x*l.y-n.y*l.x,p),c=180*h/Math.PI;return c<0&&(c=360+c),-(.7*Math.sin(h=c*Math.PI/180))}pointAttribs(t,e){let o=O.prototype.pointAttribs.call(this,t,e);return o.fill=m(t.options.fillColor,t.options.color,"none"===this.options.fillColor?null:this.options.fillColor,this.color),o["fill-opacity"]=m(t.options.fillOpacity,this.options.fillOpacity),o["stroke-width"]=m(t.options.lineWidth,this.options.lineWidth,1),t.options.opacity&&(o.opacity=t.options.opacity),o}translate(){this.chart.hasRendered&&(this.isDirtyData||!this.hasRendered)&&(this.processData(),this.generatePoints());let t=[],e=0,o=0;this.points.forEach(i=>{let r,s,n=this.chart,l=n.mapView,p=i.options,h=()=>{i.series.isDirty=!0},c=t=>{let e=n.get(t);if(e instanceof P&&e.plotX&&e.plotY)return!function(t,e,o,i={}){let r="function"==typeof t&&t.prototype||t;Object.hasOwnProperty.call(r,"hcEvents")||(r.hcEvents={});let s=r.hcEvents;a().Point&&t instanceof a().Point&&t.series&&t.series.chart&&(t.series.chart.runTrackerClick=!0);let n=t.addEventListener;n&&n.call(t,e,o,!!a().supportsPassiveEvents&&{passive:void 0===i.passive?-1!==e.indexOf("touch"):i.passive,capture:!1}),s[e]||(s[e]=[]);let l={fn:o,order:"number"==typeof i.order?i.order:1/0};s[e].push(l),s[e].sort((t,e)=>t.order-e.order)}(e,"update",h),{x:e.plotX,y:e.plotY}},f=t=>d(t)?{lon:t[0],lat:t[1]}:t;"string"==typeof p.from?r=c(p.from):"object"==typeof p.from&&l&&(r=l.lonLatToPixels(f(p.from))),"string"==typeof p.to?s=c(p.to):"object"==typeof p.to&&l&&(s=l.lonLatToPixels(f(p.to))),i.fromPos=r,i.toPos=s,r&&s&&(e+=(r.x+s.x)/2,o+=(r.y+s.y)/2),m(i.options.weight,this.options.weight)&&t.push(m(i.options.weight,this.options.weight))}),this.smallestWeight=function(t){let e=t.length,o=t[0];for(;e--;)t[e]<o&&(o=t[e]);return o}(t),this.greatestWeight=function(t){let e=t.length,o=t[0];for(;e--;)t[e]>o&&(o=t[e]);return o}(t),this.centerOfPoints={x:e/this.points.length,y:o/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=m(t.options.color,t.series.color)})}getPointShapeArgs(t){let{fromPos:e,toPos:o}=t;if(!e||!o)return{};let i=this.getLinkWidth(t)/2,r=t.options,s=g(this.options.markerEnd,r.markerEnd),n=m(r.growTowards,this.options.growTowards),a=e.x||0,l=e.y||0,p=o.x||0,h=o.y||0,c=m(r.curveFactor,this.options.curveFactor),f=s&&s.enabled&&s.height||0;if(null==c&&(c=this.autoCurve(a,l,p,h,this.centerOfPoints.x,this.centerOfPoints.y)),f){f=w(f,4*i);let t=p-a,e=h-l,o=a+(t*=.5),r=l+(e*=.5),s=t,n=o+(t=e)*c,u=r+(e=-s)*c,[d,y]=A.normalize(n-p,u-h);d*=f,y*=f,p+=d,h+=y}let u=p-a,d=h-l,y=a+(u*=.5),x=l+(d*=.5),b=u;u=d,d=-b;let[P,v]=A.normalize(u,d),O=1+.25*Math.sqrt(c*c);P*=i*O,v*=i*O;let j=y+u*c,L=x+d*c,[E,W]=A.normalize(j-a,L-l);b=E,E=W,W=-b,E*=i,W*=i;let[k,T]=A.normalize(j-p,L-h);b=k,k=-T,T=b,k*=i,T*=i,n&&(E/=i,W/=i,P/=4,v/=4);let C={d:[["M",a-E,l-W],["Q",j-P,L-v,p-k,h-T],["L",p+k,h+T],["Q",j+P,L+v,a+E,l+W],["Z"]]};if(s&&s.enabled&&C.d){let t=A.markerEndPath([p-k,h-T],[p+k,h+T],[o.x,o.y],s);C.d.splice(2,0,...t)}let M=t.options.from,_=t.options.to,S=M.lat,z=M.lon,H=_.lat,F=_.lon;return S&&z&&(t.options.from=`${+S}, ${+z}`),H&&F&&(t.options.to=`${+H}, ${+F}`),C}}A.defaultOptions=g(j.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>"}}),function(t,e){let o;for(o in t||(t={}),e)t[o]=e[o]}(A.prototype,{pointClass:b,pointArrayMap:["from","to","weight"],drawPoints:v.prototype.drawPoints,dataColumnKeys:v.prototype.dataColumnKeys,useMapGeometry:!0}),p().registerSeriesType("flowmap",A);let L=a();return s.default})());