Files

18 lines
4.0 KiB
JavaScript
Raw Permalink Normal View History

2023-01-13 15:30:20 +08:00
/*
Highcharts JS v7.0.0 (2018-12-11)
Wind barb series module
(c) 2010-2018 Torstein Honsi
License: www.highcharts.com/license
*/
(function(k){"object"===typeof module&&module.exports?module.exports=k:"function"===typeof define&&define.amd?define(function(){return k}):k("undefined"!==typeof Highcharts?Highcharts:void 0)})(function(k){var z=function(f){var k=f.defined,r=f.seriesTypes,d=f.stableSort;return{getPlotBox:function(){return f.Series.prototype.getPlotBox.call(this.options.onSeries&&this.chart.get(this.options.onSeries)||this)},translate:function(){r.column.prototype.translate.apply(this);var c=this.options,e=this.chart,
b=this.points,a=b.length-1,g,f,h=c.onSeries,h=h&&e.get(h),c=c.onKey||"y",y=h&&h.options.step,p=h&&h.points,m=p&&p.length,u=e.inverted,n=this.xAxis,v=this.yAxis,w=0,l,x,q,t;if(h&&h.visible&&m)for(w=(h.pointXOffset||0)+(h.barW||0)/2,g=h.currentDataGrouping,x=p[m-1].x+(g?g.totalRange:0),d(b,function(b,a){return b.x-a.x}),c="plot"+c[0].toUpperCase()+c.substr(1);m--&&b[a]&&!(l=p[m],g=b[a],g.y=l.y,l.x<=g.x&&void 0!==l[c]&&(g.x<=x&&(g.plotY=l[c],l.x<g.x&&!y&&(q=p[m+1])&&void 0!==q[c]&&(t=(g.x-l.x)/(q.x-
l.x),g.plotY+=t*(q[c]-l[c]),g.y+=t*(q.y-l.y))),a--,m++,0>a)););b.forEach(function(a,c){var d;a.plotX+=w;if(void 0===a.plotY||u)0<=a.plotX&&a.plotX<=n.len?u?(a.plotY=n.translate(a.x,0,1,0,1),a.plotX=k(a.y)?v.translate(a.y,0,0,0,1):0):a.plotY=e.chartHeight-n.bottom-(n.opposite?n.height:0)+n.offset-v.top:a.shapeArgs={};(f=b[c-1])&&f.plotX===a.plotX&&(void 0===f.stackIndex&&(f.stackIndex=0),d=f.stackIndex+1);a.stackIndex=d});this.onSeries=h}}}(k);(function(f,k){var r=f.seriesType;r("windbarb","column",
{lineWidth:2,onSeries:null,states:{hover:{lineWidthPlus:0}},tooltip:{pointFormat:'\x3cspan style\x3d"color:{point.color}"\x3e\u25cf\x3c/span\x3e {series.name}: \x3cb\x3e{point.value}\x3c/b\x3e ({point.beaufort})\x3cbr/\x3e'},vectorLength:20,yOffset:-20,xOffset:0},{pointArrayMap:["value","direction"],parallelArrays:["x","value","direction"],beaufortName:"Calm;Light air;Light breeze;Gentle breeze;Moderate breeze;Fresh breeze;Strong breeze;Near gale;Gale;Strong gale;Storm;Violent storm;Hurricane".split(";"),
beaufortFloor:[0,.3,1.6,3.4,5.5,8,10.8,13.9,17.2,20.8,24.5,28.5,32.7],trackerGroups:["markerGroup"],pointAttribs:function(d,c){var e=this.options;d=d.color||this.color;var b=this.options.lineWidth;c&&(d=e.states[c].color||d,b=(e.states[c].lineWidth||b)+(e.states[c].lineWidthPlus||0));return{stroke:d,"stroke-width":b}},markerAttribs:function(){},getPlotBox:k.getPlotBox,windArrow:function(d){var c=1.943844*d.value,e,b=this.options.vectorLength/20,a=-10;if(d.isNull)return[];if(0===d.beaufortLevel)return this.chart.renderer.symbols.circle(-10*
b,-10*b,20*b,20*b);d=["M",0,7*b,"L",-1.5*b,7*b,0,10*b,1.5*b,7*b,0,7*b,0,-10*b];e=(c-c%50)/50;if(0<e)for(;e--;)d.push(-10===a?"L":"M",0,a*b,"L",5*b,a*b+2,"L",0,a*b+4),c-=50,a+=7;e=(c-c%10)/10;if(0<e)for(;e--;)d.push(-10===a?"L":"M",0,a*b,"L",7*b,a*b),c-=10,a+=3;e=(c-c%5)/5;if(0<e)for(;e--;)d.push(-10===a?"L":"M",0,a*b,"L",4*b,a*b),c-=5,a+=3;return d},translate:function(){var d=this.beaufortFloor,c=this.beaufortName;k.translate.call(this);this.points.forEach(function(e){for(var b=0;b<d.length&&!(d[b]>
e.value);b++);e.beaufortLevel=b-1;e.beaufort=c[b-1]})},drawPoints:function(){var d=this.chart,c=this.yAxis,e=d.inverted,b=this.options.vectorLength/2;this.points.forEach(function(a){var g=a.plotX,f=a.plotY;d.isInsidePlot(g,0,!1)?(a.graphic||(a.graphic=this.chart.renderer.path().add(this.markerGroup)),a.graphic.attr({d:this.windArrow(a),translateX:g+this.options.xOffset,translateY:f+this.options.yOffset,rotation:a.direction}).attr(this.pointAttribs(a))):a.graphic&&(a.graphic=a.graphic.destroy());a.tooltipPos=
[g+this.options.xOffset+(e&&!this.onSeries?b:0),f+this.options.yOffset-(e?0:b+c.pos-d.plotTop)]},this)},animate:function(d){d?this.markerGroup.attr({opacity:.01}):(this.markerGroup.animate({opacity:1},f.animObject(this.options.animation)),this.animate=null)},invertGroups:f.noop},{isValid:function(){return f.isNumber(this.value)&&0<=this.value}})})(k,z)});
//# sourceMappingURL=windbarb.js.map