highcharts
Version:
JavaScript charting framework
13 lines • 7.72 kB
JavaScript
!/**
* Highcharts JS v12.6.0 (2026-04-13)
* @module highcharts/modules/windbarb
* @requires highcharts
*
* Wind barb series module
*
* (c) 2010-2026 Highsoft AS
* Author: Torstein Hønsi
*
* 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.dataGrouping.approximations,t._Highcharts.Series.types.column,t._Highcharts.Series,t._Highcharts.SeriesRegistry):"function"==typeof define&&define.amd?define("highcharts/modules/windbarb",["highcharts/highcharts"],function(t){return e(t,t.dataGrouping,["approximations"],t.Series,["types"],["column"],t.Series,t.SeriesRegistry)}):"object"==typeof exports?exports["highcharts/modules/windbarb"]=e(t._Highcharts,t._Highcharts.dataGrouping.approximations,t._Highcharts.Series.types.column,t._Highcharts.Series,t._Highcharts.SeriesRegistry):t.Highcharts=e(t.Highcharts,t.Highcharts.dataGrouping.approximations,t.Highcharts.Series.types.column,t.Highcharts.Series,t.Highcharts.SeriesRegistry)}("u"<typeof window?this:window,(t,e,r,o,i)=>(()=>{"use strict";var s,n={448:t=>{t.exports=r},512:t=>{t.exports=i},820:t=>{t.exports=o},944:e=>{e.exports=t},956:t=>{t.exports=e}},a={};function l(t){var e=a[t];if(void 0!==e)return e.exports;var r=a[t]={exports:{}};return n[t](r,r.exports,l),r.exports}l.n=t=>{var e=t&&t.__esModule?()=>t.default:()=>t;return l.d(e,{a:e}),e},l.d=(t,e)=>{for(var r in e)l.o(e,r)&&!l.o(t,r)&&Object.defineProperty(t,r,{enumerable:!0,get:e[r]})},l.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e);var p={};l.d(p,{default:()=>Y});var h=l(944),c=l.n(h),u=l(956),f=l.n(u),d=l(448),g=l.n(d),y=l(820),b=l.n(y);let{doc:x,win:m}=c();function v(t){return S(t)&&"number"==typeof t.nodeType}function S(t,e){let r;return!!t&&"object"==typeof t&&(!e||"[object Array]"!==(r=Object.prototype.toString.call(t))&&"[object Array Iterator]"!==r)}Array.prototype.find;let{composed:w}=c(),{prototype:L}=g(),{prototype:O}=b();var H=s||(s={});function A(t){return O.getPlotBox.call(this.options.onSeries&&this.chart.get(this.options.onSeries)||this,t)}function X(){L.translate.apply(this);let t=this,e=t.options,r=t.chart,o=t.points,i=e.onSeries,s=i&&r.get(i),n=s&&s.options.step,a=s&&s.points,l=r.inverted,p=t.xAxis,h=t.yAxis,c=o.length-1,u,f,d=e.onKey||"y",g=a&&a.length,y=0,b,x,m,v,S;if(s&&s.visible&&g){for(y=(s.pointXOffset||0)+(s.barW||0)/2,v=s.currentDataGrouping,x=a[g-1].x+(v?v.totalRange:0),!function(t,e){let r,o,i=t.length;for(o=0;o<i;o++)t[o].safeI=o;for(t.sort(function(t,o){return 0===(r=e(t,o))?t.safeI-o.safeI:r}),o=0;o<i;o++)delete t[o].safeI}(o,(t,e)=>t.x-e.x),d="plot"+d[0].toUpperCase()+d.substr(1);g--&&o[c];)if(b=a[g],(u=o[c]).y=b.y,b.x<=u.x&&void 0!==b[d]){if(u.x<=x&&(u.plotY=b[d],b.x<u.x&&!n&&(m=a[g+1]))&&void 0!==m[d])if(null!=u.plotX&&s.is("spline")){let t=[b.plotX||0,b.plotY||0],e=[m.plotX||0,m.plotY||0],r=b.controlPoints?.high||t,o=m.controlPoints?.low||e,i=(i,s)=>Math.pow(1-i,3)*t[s]+3*(1-i)*(1-i)*i*r[s]+3*(1-i)*i*i*o[s]+i*i*i*e[s],s=0,n=1,a;for(let t=0;t<100;t++){let t=(s+n)/2,e=i(t,0);if(null===e)break;if(.25>Math.abs(e-u.plotX)){a=t;break}e<u.plotX?s=t:n=t}null!=a&&(u.plotY=i(a,1),u.y=h.toValue(u.plotY,!0))}else S=(u.x-b.x)/(m.x-b.x),u.plotY+=S*(m[d]-b[d]),u.y+=S*(m.y-b.y);if(c--,g++,c<0)break}}o.forEach((e,r)=>{let i;if(e.plotX+=y,void 0===e.plotY||l)if(e.plotX>=0&&e.plotX<=p.len)if(l)e.plotY=p.translate(e.x,0,1,0,1),e.plotX=null!=e.y?h.translate(e.y,0,0,0,1):0;else e.plotY=(p.opposite?0:t.yAxis.len)+p.offset;else e.shapeArgs={};(f=o[r-1])&&f.plotX===e.plotX&&(void 0===f.stackIndex&&(f.stackIndex=0),i=f.stackIndex+1),e.stackIndex=i}),this.onSeries=s}H.compose=function(t){var e;if(e="OnSeries",0>w.indexOf(e)&&w.push(e)){let e=t.prototype;e.getPlotBox=A,e.translate=X}return t},H.getPlotBox=A,H.translate=X;let _=s;var k=l(512),P=l.n(k);class G extends g().prototype.pointClass{isValid(){var t;return"number"==typeof(t=this.value)&&!isNaN(t)&&t<1/0&&t>-1/0&&this.value>=0}}let{animObject:M}=c(),{column:j}=P().seriesTypes;class I extends j{init(t,e){super.init(t,e)}pointAttribs(t,e){let r=this.options,o=t.color||this.color,i=this.options.lineWidth;return e&&(o=r.states[e].color||o,i=(r.states[e].lineWidth||i)+(r.states[e].lineWidthPlus||0)),{stroke:o,"stroke-width":i}}windArrow(t){let e=t.beaufortLevel,r=this.options.vectorLength/20,o=1.943844*t.value,i,s=-10;if(t.isNull)return[];if(0===e)return this.chart.renderer.symbols.circle(-10*r,-10*r,20*r,20*r);let n=[["M",0,7*r],["L",-1.5*r,7*r],["L",0,10*r],["L",1.5*r,7*r],["L",0,7*r],["L",0,-10*r]];if((i=(o-o%50)/50)>0)for(;i--;)n.push(-10===s?["L",0,s*r]:["M",0,s*r],["L",5*r,s*r+2],["L",0,s*r+4]),o-=50,s+=7;if((i=(o-o%10)/10)>0)for(;i--;)n.push(-10===s?["L",0,s*r]:["M",0,s*r],["L",7*r,s*r]),o-=10,s+=3;if((i=(o-o%5)/5)>0)for(;i--;)n.push(-10===s?["L",0,s*r]:["M",0,s*r],["L",4*r,s*r]),o-=5,s+=3;return n}drawPoints(){let t=this.chart,e=this.yAxis,r=t.inverted,o=this.options.vectorLength/2;for(let i of this.points){let s=i.plotX,n=i.plotY;!1===this.options.clip||t.isInsidePlot(s,0)?(i.graphic||(i.graphic=this.chart.renderer.path().add(this.markerGroup).addClass("highcharts-point highcharts-color-"+function(){let t=arguments,e=t.length;for(let r=0;r<e;r++){let e=t[r];if(null!=e)return e}}(i.colorIndex,i.series.colorIndex))),i.graphic.attr({d:this.windArrow(i),translateX:s+this.options.xOffset,translateY:n+this.options.yOffset,rotation:i.direction}),this.chart.styledMode||i.graphic.attr(this.pointAttribs(i))):i.graphic&&(i.graphic=i.graphic.destroy()),i.tooltipPos=[s+this.options.xOffset+(r&&!this.onSeries?o:0),n+this.options.yOffset-(r?0:o+e.pos-t.plotTop)]}}animate(t){t?this.markerGroup.attr({opacity:.01}):this.markerGroup.animate({opacity:1},M(this.options.animation))}markerAttribs(){return{}}getExtremes(){return{}}shouldShowTooltip(t,e,r={}){return r.ignoreX=this.chart.inverted,r.ignoreY=!r.ignoreX,super.shouldShowTooltip(t,e,r)}}I.defaultOptions=function(t,...e){let r,o=[t,...e],i={},s=function(t,e){return"object"!=typeof t&&(t={}),function(t,e,r){for(let r in t)Object.hasOwnProperty.call(t,r)&&e.call((0,t[r]),t[r],r,t)}(e,function(r,o){if("__proto__"!==o&&"constructor"!==o){let i;!S(r,!0)||(i=r?.constructor,S(r,!0)&&!v(r)&&i?.name&&"Object"!==i.name)||v(r)?t[o]=e[o]:t[o]=s(t[o]||{},r)}}),t};!0===t&&(i=o[1],o=Array.prototype.slice.call(o,2));let n=o.length;for(r=0;r<n;r++)i=s(i,o[r]);return i}(j.defaultOptions,{dataGrouping:{enabled:!0,approximation:"windbarb",groupPixelWidth:30},lineWidth:2,onSeries:null,states:{hover:{lineWidthPlus:0}},tooltip:{pointFormat:'<span style="color:{point.color}">●</span> {series.name}: <b>{point.value}</b> ({point.beaufort})<br/>'},vectorLength:20,colorKey:"value",yOffset:-20,xOffset:0}),_.compose(I),function(t,e){let r;for(r in t||(t={}),e)t[r]=e[r]}(I.prototype,{beaufortFloor:[0,.3,1.6,3.4,5.5,8,10.8,13.9,17.2,20.8,24.5,28.5,32.7],beaufortName:["Calm","Light air","Light breeze","Gentle breeze","Moderate breeze","Fresh breeze","Strong breeze","Near gale","Gale","Strong gale","Storm","Violent storm","Hurricane"],invertible:!1,parallelArrays:["x","value","direction"],pointArrayMap:["value","direction"],pointClass:G,trackerGroups:["markerGroup"],translate:function(){let t=this.beaufortFloor,e=this.beaufortName;for(let r of(_.translate.call(this),this.points)){let o=0;for(;o<t.length&&!(t[o]>r.value);o++);r.beaufortLevel=o-1,r.beaufort=e[o-1]}}}),P().registerSeriesType("windbarb",I),f().windbarb||(f().windbarb=(t,e)=>{let r=0,o=0;for(let i=0,s=t.length;i<s;i++)r+=t[i]*Math.cos(e[i]*c().deg2rad),o+=t[i]*Math.sin(e[i]*c().deg2rad);return[t.reduce((t,e)=>t+e,0)/t.length,Math.atan2(o,r)/c().deg2rad]});let Y=c();return p.default})());