1 |
- (function(j){function C(k,g,p){for(var n=4,l=[];n--;){l[n]=Math.round(g.rgba[n]+(k.rgba[n]-g.rgba[n])*(1-p))}return"rgba("+l.join(",")+")"}var a=j.Axis,o=j.Chart,H=j.Point,m=j.Pointer,h=j.each,E=j.extend,d=j.merge,f=j.pick,e=j.numberFormat,c=j.getOptions(),i=j.seriesTypes,b=c.plotOptions,G=j.wrap,F=j.Color,D=function(){};c.mapNavigation={buttonOptions:{align:"right",verticalAlign:"bottom",x:0,width:18,height:18,style:{fontSize:"15px",fontWeight:"bold",textAlign:"center"}},buttons:{zoomIn:{onclick:function(){this.mapZoom(0.5)},text:"+",y:-32},zoomOut:{onclick:function(){this.mapZoom(2)},text:"-",y:0}}};j.splitPath=function(k){var g,k=k.replace(/([A-Za-z])/g," $1 "),k=k.replace(/^\s*/,"").replace(/\s*$/,""),k=k.split(/[ ,]+/);for(g=0;g<k.length;g++){/[a-zA-Z]/.test(k[g])||(k[g]=parseFloat(k[g]))}return k};j.maps={};G(a.prototype,"getSeriesExtremes",function(k){var g=this.isXAxis,p,n,l=[];h(this.series,function(r,q){if(r.useMapGeometry){l[q]=r.xData,r.xData=[]}});k.call(this);p=f(this.dataMin,Number.MAX_VALUE);n=f(this.dataMax,Number.MIN_VALUE);h(this.series,function(q,r){if(q.useMapGeometry){p=Math.min(p,q[g?"minX":"minY"]),n=Math.max(n,q[g?"maxX":"maxY"]),q.xData=l[r]}});this.dataMin=p;this.dataMax=n});G(a.prototype,"setAxisTranslation",function(k){var g=this.chart,p=g.plotWidth/g.plotHeight,n=this.isXAxis,l=g.xAxis[0];k.call(this);if(g.options.chart.type==="map"&&!n&&l.transA!==void 0){this.transA=l.transA=Math.min(this.transA,l.transA),k=(l.max-l.min)/(this.max-this.min),l=k>p?this:l,p=(l.max-l.min)*l.transA,l.minPixelPadding=(l.len-p)/2}});G(o.prototype,"render",function(k){var g=this,l=g.options.mapNavigation;k.call(g);g.renderMapNavigation();l.zoomOnDoubleClick&&j.addEvent(g.container,"dblclick",function(n){g.pointer.onContainerDblClick(n)});l.zoomOnMouseWheel&&j.addEvent(g.container,document.onmousewheel===void 0?"DOMMouseScroll":"mousewheel",function(n){g.pointer.onContainerMouseWheel(n)})});E(m.prototype,{onContainerDblClick:function(k){var g=this.chart,k=this.normalize(k);g.isInsidePlot(k.chartX-g.plotLeft,k.chartY-g.plotTop)&&g.mapZoom(0.5,g.xAxis[0].toValue(k.chartX),g.yAxis[0].toValue(k.chartY))},onContainerMouseWheel:function(k){var g=this.chart,l,k=this.normalize(k);l=k.detail||-(k.wheelDelta/120);g.isInsidePlot(k.chartX-g.plotLeft,k.chartY-g.plotTop)&&g.mapZoom(l>0?2:0.5,g.xAxis[0].toValue(k.chartX),g.yAxis[0].toValue(k.chartY))}});G(m.prototype,"init",function(k,g,l){k.call(this,g,l);if(l.mapNavigation.enableTouchZoom){this.pinchX=this.pinchHor=this.pinchY=this.pinchVert=!0}});E(o.prototype,{renderMapNavigation:function(){var k=this,g=this.options.mapNavigation,r=g.buttons,q,p,n,l=function(){this.handler.call(k)};if(g.enableButtons){for(q in r){if(r.hasOwnProperty(q)){n=d(g.buttonOptions,r[q]),p=k.renderer.button(n.text,0,0,l).attr({width:n.width,height:n.height}).css(n.style).add(),p.handler=n.onclick,p.align(E(n,{width:p.width,height:p.height}),null,"spacingBox")}}}},fitToBox:function(k,g){h([["x","width"],["y","height"]],function(n){var l=n[0],n=n[1];k[l]+k[n]>g[l]+g[n]&&(k[n]>g[n]?(k[n]=g[n],k[l]=g[l]):k[l]=g[l]+g[n]-k[n]);k[n]>g[n]&&(k[n]=g[n]);k[l]<g[l]&&(k[l]=g[l])});return k},mapZoom:function(k,g,s){if(!this.isMapZooming){var r=this,q=r.xAxis[0],p=q.max-q.min,l=f(g,q.min+p/2),g=p*k,p=r.yAxis[0],n=p.max-p.min,s=f(s,p.min+n/2);k*=n;l-=g/2;n=s-k/2;s=f(r.options.chart.animation,!0);g=r.fitToBox({x:l,y:n,width:g,height:k},{x:q.dataMin,y:p.dataMin,width:q.dataMax-q.dataMin,height:p.dataMax-p.dataMin});q.setExtremes(g.x,g.x+g.width,!1);p.setExtremes(g.y,g.y+g.height,!1);if(q=s?s.duration||500:0){r.isMapZooming=!0,setTimeout(function(){r.isMapZooming=!1},q)}r.redraw()}}});b.map=d(b.scatter,{animation:!1,nullColor:"#F8F8F8",borderColor:"silver",borderWidth:1,marker:null,stickyTracking:!1,dataLabels:{verticalAlign:"middle"},turboThreshold:0,tooltip:{followPointer:!0,pointFormat:"{point.name}: {point.y}<br/>"},states:{normal:{animation:!0}}});a=j.extendClass(H,{applyOptions:function(k,g){var l=H.prototype.applyOptions.call(this,k,g);if(l.path&&typeof l.path==="string"){l.path=l.options.path=j.splitPath(l.path)}return l},onMouseOver:function(){clearTimeout(this.colorInterval);H.prototype.onMouseOver.call(this)},onMouseOut:function(){var k=this,g=+new Date,q=F(k.options.color),p=F(k.pointAttr.hover.fill),n=k.series.options.states.normal.animation,l=n&&(n.duration||500);if(l&&q.rgba.length===4&&p.rgba.length===4){delete k.pointAttr[""].fill,clearTimeout(k.colorInterval),k.colorInterval=setInterval(function(){var s=(new Date-g)/l,r=k.graphic;s>1&&(s=1);r&&r.attr("fill",C(p,q,s));s>=1&&clearTimeout(k.colorInterval)},13)}H.prototype.onMouseOut.call(k)}});i.map=j.extendClass(i.scatter,{type:"map",pointAttrToOptions:{stroke:"borderColor","stroke-width":"borderWidth",fill:"color"},colorKey:"y",pointClass:a,trackerGroups:["group","markerGroup","dataLabelsGroup"],getSymbol:D,supportsDrilldown:!0,getExtremesFromAll:!0,useMapGeometry:!0,init:function(v){var u=this,t=v.options.legend.valueDecimals,s=[],r,q,n,p,l,g,k;g=v.options.legend.layout==="horizontal";j.Series.prototype.init.apply(this,arguments);l=u.options.colorRange;if(p=u.options.valueRanges){h(p,function(w){q=w.from;n=w.to;r="";q===void 0?r="< ":n===void 0&&(r="> ");q!==void 0&&(r+=e(q,t));q!==void 0&&n!==void 0&&(r+=" - ");n!==void 0&&(r+=e(n,t));s.push(j.extend({chart:u.chart,name:r,options:{},drawLegendSymbol:i.area.prototype.drawLegendSymbol,visible:!0,setState:function(){},setVisible:function(){}},w))}),u.legendItems=s}else{if(l){q=l.from,n=l.to,p=l.fromLabel,l=l.toLabel,k=g?[0,0,1,0]:[0,1,0,0],g||(g=p,p=l,l=g),g={linearGradient:{x1:k[0],y1:k[1],x2:k[2],y2:k[3]},stops:[[0,q],[1,n]]},s=[{chart:u.chart,options:{},fromLabel:p,toLabel:l,color:g,drawLegendSymbol:this.drawLegendSymbolGradient,visible:!0,setState:function(){},setVisible:function(){}}],u.legendItems=s}}},drawLegendSymbol:i.area.prototype.drawLegendSymbol,drawLegendSymbolGradient:function(t,s){var r=t.options.symbolPadding,q=f(t.options.padding,8),p,n,k=this.chart.renderer.fontMetrics(t.options.itemStyle.fontSize).h,l=t.options.layout==="horizontal",g;g=f(t.options.rectangleLength,200);l?(p=-(r/2),n=0):(p=-g+t.baseline-r/2,n=q+k);s.fromText=this.chart.renderer.text(s.fromLabel,n,p).attr({zIndex:2}).add(s.legendGroup);n=s.fromText.getBBox();s.legendSymbol=this.chart.renderer.rect(l?n.x+n.width+r:n.x-k-r,n.y,l?g:k,l?k:g,2).attr({zIndex:1}).add(s.legendGroup);g=s.legendSymbol.getBBox();s.toText=this.chart.renderer.text(s.toLabel,g.x+g.width+r,l?p:g.y+g.height-r).attr({zIndex:2}).add(s.legendGroup);p=s.toText.getBBox();l?(t.offsetWidth=n.width+g.width+p.width+r*2+q,t.itemY=k+q):(t.offsetWidth=Math.max(n.width,p.width)+r+g.width+q,t.itemY=g.height+q,t.itemX=r)},getBox:function(k){var g=Number.MIN_VALUE,p=Number.MAX_VALUE,n=Number.MIN_VALUE,l=Number.MAX_VALUE;h(k||this.options.data,function(s){for(var v=s.path,w=v.length,u=!1,x=Number.MIN_VALUE,q=Number.MAX_VALUE,t=Number.MIN_VALUE,r=Number.MAX_VALUE;w--;){typeof v[w]==="number"&&!isNaN(v[w])&&(u?(x=Math.max(x,v[w]),q=Math.min(q,v[w])):(t=Math.max(t,v[w]),r=Math.min(r,v[w])),u=!u)}s._maxX=x;s._minX=q;s._maxY=t;s._minY=r;g=Math.max(g,x);p=Math.min(p,q);n=Math.max(n,t);l=Math.min(l,r)});this.minY=l;this.maxY=n;this.minX=p;this.maxX=g},translatePath:function(k){var g=!1,p=this.xAxis,n=this.yAxis,l,k=[].concat(k);for(l=k.length;l--;){typeof k[l]==="number"&&(k[l]=g?Math.round(p.translate(k[l])):Math.round(n.len-n.translate(k[l])),g=!g)}return k},setData:function(){j.Series.prototype.setData.apply(this,arguments);this.getBox()},translate:function(){var k=this,g=Number.MAX_VALUE,l=Number.MIN_VALUE;k.generatePoints();h(k.data,function(n){n.shapeType="path";n.shapeArgs={d:k.translatePath(n.path)};if(typeof n.y==="number"){if(n.y>l){l=n.y}else{if(n.y<g){g=n.y}}}});k.translateColors(g,l)},translateColors:function(k,g){var s=this.options,r=s.valueRanges,q=s.colorRange,p=this.colorKey,l,n;q&&(l=F(q.from),n=F(q.to));h(this.data,function(w){var v=w[p],t,u,x;if(r){for(x=r.length;x--;){if(t=r[x],l=t.from,n=t.to,(l===void 0||v>=l)&&(n===void 0||v<=n)){u=t.color;break}}}else{q&&v!==void 0&&(t=1-(g-v)/(g-k),u=v===null?s.nullColor:C(l,n,t))}if(u){w.color=null,w.options.color=u}})},drawGraph:D,drawDataLabels:D,drawPoints:function(){var k=this.xAxis,g=this.yAxis,l=this.colorKey;h(this.data,function(n){n.plotY=1;if(n[l]===null){n[l]=0,n.isNull=!0}});i.column.prototype.drawPoints.apply(this);h(this.data,function(t){var s=t.dataLabels,r=k.toPixels(t._minX,!0),q=k.toPixels(t._maxX,!0),p=g.toPixels(t._minY,!0),n=g.toPixels(t._maxY,!0);t.plotX=Math.round(r+(q-r)*f(s&&s.anchorX,0.5));t.plotY=Math.round(p+(n-p)*f(s&&s.anchorY,0.5));t.isNull&&(t[l]=null)});j.Series.prototype.drawDataLabels.call(this)},animateDrilldown:function(k){var g=this.chart.plotBox,p=this.chart.drilldownLevels[this.chart.drilldownLevels.length-1],n=p.bBox,l=this.chart.options.drilldown.animation;if(!k){k=Math.min(n.width/g.width,n.height/g.height),p.shapeArgs={scaleX:k,scaleY:k,translateX:n.x,translateY:n.y},h(this.points,function(q){q.graphic.attr(p.shapeArgs).animate({scaleX:1,scaleY:1,translateX:0,translateY:0},l)}),delete this.animate}},animateDrillupFrom:function(g){i.column.prototype.animateDrillupFrom.call(this,g)},animateDrillupTo:function(g){i.column.prototype.animateDrillupTo.call(this,g)}});b.mapline=d(b.map,{lineWidth:1,backgroundColor:"none"});i.mapline=j.extendClass(i.map,{type:"mapline",pointAttrToOptions:{stroke:"color","stroke-width":"lineWidth",fill:"backgroundColor"},drawLegendSymbol:i.line.prototype.drawLegendSymbol});b.mappoint=d(b.scatter,{dataLabels:{enabled:!0,format:"{point.name}",color:"black",style:{textShadow:"0 0 5px white"}}});i.mappoint=j.extendClass(i.scatter,{type:"mappoint"});j.Map=function(k,g){var n={endOnTick:!1,gridLineWidth:0,labels:{enabled:!1},lineWidth:0,minPadding:0,maxPadding:0,startOnTick:!1,tickWidth:0,title:null},l;l=k.series;k.series=null;k=d({chart:{type:"map",panning:"xy"},xAxis:n,yAxis:d(n,{reversed:!0})},k,{chart:{inverted:!1}});k.series=l;return new j.Chart(k,g)}})(Highcharts);
|