UNPKG

8.61 kBJavaScriptView Raw
1/*
2 Highcharts JS v5.0.0 (2016-09-29)
3
4 (c) 2009-2016 Torstein Honsi
5
6 License: www.highcharts.com/license
7*/
8(function(q){"object"===typeof module&&module.exports?module.exports=q:q(Highcharts)})(function(q){(function(b){var g=b.Axis,t=b.Chart,k=b.color,p,e=b.each,v=b.extend,w=b.isNumber,n=b.Legend,l=b.LegendSymbolMixin,x=b.noop,r=b.merge,u=b.pick,m=b.wrap;p=b.ColorAxis=function(){this.init.apply(this,arguments)};v(p.prototype,g.prototype);v(p.prototype,{defaultColorAxisOptions:{lineWidth:0,minPadding:0,maxPadding:0,gridLineWidth:1,tickPixelInterval:72,startOnTick:!0,endOnTick:!0,offset:0,marker:{animation:{duration:50},
9width:.01},labels:{overflow:"justify"},minColor:"#e6ebf5",maxColor:"#003399",tickLength:5,showInLegend:!0},init:function(a,c){var d="vertical"!==a.options.legend.layout,f;this.coll="colorAxis";f=r(this.defaultColorAxisOptions,{side:d?2:1,reversed:!d},c,{opposite:!d,showEmpty:!1,title:null});g.prototype.init.call(this,a,f);c.dataClasses&&this.initDataClasses(c);this.initStops(c);this.horiz=d;this.zoomEnabled=!1;this.defaultLegendLength=200},tweenColors:function(a,c,d){var f;c.rgba.length&&a.rgba.length?
10(a=a.rgba,c=c.rgba,f=1!==c[3]||1!==a[3],a=(f?"rgba(":"rgb(")+Math.round(c[0]+(a[0]-c[0])*(1-d))+","+Math.round(c[1]+(a[1]-c[1])*(1-d))+","+Math.round(c[2]+(a[2]-c[2])*(1-d))+(f?","+(c[3]+(a[3]-c[3])*(1-d)):"")+")"):a=c.input||"none";return a},initDataClasses:function(a){var c=this,d,f=0,h=this.chart.options.chart.colorCount,b=this.options,y=a.dataClasses.length;this.dataClasses=d=[];this.legendItems=[];e(a.dataClasses,function(a,l){a=r(a);d.push(a);a.color||("category"===b.dataClassColor?(a.colorIndex=
11f,f++,f===h&&(f=0)):a.color=c.tweenColors(k(b.minColor),k(b.maxColor),2>y?.5:l/(y-1)))})},initStops:function(a){this.stops=a.stops||[[0,this.options.minColor],[1,this.options.maxColor]];e(this.stops,function(a){a.color=k(a[1])})},setOptions:function(a){g.prototype.setOptions.call(this,a);this.options.crosshair=this.options.marker},setAxisSize:function(){var a=this.legendSymbol,c=this.chart,d=c.options.legend||{},f,h;a?(this.left=d=a.attr("x"),this.top=f=a.attr("y"),this.width=h=a.attr("width"),this.height=
12a=a.attr("height"),this.right=c.chartWidth-d-h,this.bottom=c.chartHeight-f-a,this.len=this.horiz?h:a,this.pos=this.horiz?d:f):this.len=(this.horiz?d.symbolWidth:d.symbolHeight)||this.defaultLegendLength},toColor:function(a,c){var d,f=this.stops,h,b=this.dataClasses,l,e;if(b)for(e=b.length;e--;){if(l=b[e],h=l.from,f=l.to,(void 0===h||a>=h)&&(void 0===f||a<=f)){d=l.color;c&&(c.dataClass=e,c.colorIndex=l.colorIndex);break}}else{this.isLog&&(a=this.val2lin(a));d=1-(this.max-a)/(this.max-this.min||1);
13for(e=f.length;e--&&!(d>f[e][0]););h=f[e]||f[e+1];f=f[e+1]||h;d=1-(f[0]-d)/(f[0]-h[0]||1);d=this.tweenColors(h.color,f.color,d)}return d},getOffset:function(){var a=this.legendGroup,c=this.chart.axisOffset[this.side];a&&(this.axisParent=a,g.prototype.getOffset.call(this),this.added||(this.added=!0,this.labelLeft=0,this.labelRight=this.width),this.chart.axisOffset[this.side]=c)},setLegendColor:function(){var a,c=this.options,d=this.reversed;a=d?1:0;d=d?0:1;a=this.horiz?[a,0,d,0]:[0,d,0,a];this.legendColor=
14{linearGradient:{x1:a[0],y1:a[1],x2:a[2],y2:a[3]},stops:c.stops||[[0,c.minColor],[1,c.maxColor]]}},drawLegendSymbol:function(a,c){var d=a.padding,f=a.options,h=this.horiz,b=u(f.symbolWidth,h?this.defaultLegendLength:12),e=u(f.symbolHeight,h?12:this.defaultLegendLength),l=u(f.labelPadding,h?16:30),f=u(f.itemDistance,10);this.setLegendColor();c.legendSymbol=this.chart.renderer.rect(0,a.baseline-11,b,e).attr({zIndex:1}).add(c.legendGroup);this.legendItemWidth=b+d+(h?f:l);this.legendItemHeight=e+d+(h?
15l:0)},setState:x,visible:!0,setVisible:x,getSeriesExtremes:function(){var a;this.series.length&&(a=this.series[0],this.dataMin=a.valueMin,this.dataMax=a.valueMax)},drawCrosshair:function(a,c){var d=c&&c.plotX,f=c&&c.plotY,b,e=this.pos,l=this.len;c&&(b=this.toPixels(c[c.series.colorKey]),b<e?b=e-2:b>e+l&&(b=e+l+2),c.plotX=b,c.plotY=this.len-b,g.prototype.drawCrosshair.call(this,a,c),c.plotX=d,c.plotY=f,this.cross&&this.cross.addClass("highcharts-coloraxis-marker").add(this.legendGroup))},getPlotLinePath:function(a,
16c,d,b,e){return w(e)?this.horiz?["M",e-4,this.top-6,"L",e+4,this.top-6,e,this.top,"Z"]:["M",this.left,e,"L",this.left-6,e+6,this.left-6,e-6,"Z"]:g.prototype.getPlotLinePath.call(this,a,c,d,b)},update:function(a,c){var d=this.chart,b=d.legend;e(this.series,function(a){a.isDirtyData=!0});a.dataClasses&&b.allItems&&(e(b.allItems,function(a){a.isDataClass&&a.legendGroup.destroy()}),d.isDirtyLegend=!0);d.options[this.coll]=r(this.userOptions,a);g.prototype.update.call(this,a,c);this.legendItem&&(this.setLegendColor(),
17b.colorizeItem(this,!0))},getDataClassLegendSymbols:function(){var a=this,c=this.chart,d=this.legendItems,f=c.options.legend,h=f.valueDecimals,p=f.valueSuffix||"",m;d.length||e(this.dataClasses,function(f,n){var g=!0,r=f.from,k=f.to;m="";void 0===r?m="< ":void 0===k&&(m="> ");void 0!==r&&(m+=b.numberFormat(r,h)+p);void 0!==r&&void 0!==k&&(m+=" - ");void 0!==k&&(m+=b.numberFormat(k,h)+p);d.push(v({chart:c,name:m,options:{},drawLegendSymbol:l.drawRectangle,visible:!0,setState:x,isDataClass:!0,setVisible:function(){g=
18this.visible=!g;e(a.series,function(a){e(a.points,function(a){a.dataClass===n&&a.setVisible(g)})});c.legend.colorizeItem(this,g)}},f))});return d},name:""});e(["fill","stroke"],function(a){b.Fx.prototype[a+"Setter"]=function(){this.elem.attr(a,p.prototype.tweenColors(k(this.start),k(this.end),this.pos))}});m(t.prototype,"getAxes",function(a){var c=this.options.colorAxis;a.call(this);this.colorAxis=[];c&&new p(this,c)});m(n.prototype,"getAllItems",function(a){var c=[],d=this.chart.colorAxis[0];d&&
19d.options&&(d.options.showInLegend&&(d.options.dataClasses?c=c.concat(d.getDataClassLegendSymbols()):c.push(d)),e(d.series,function(a){a.options.showInLegend=!1}));return c.concat(a.call(this))});m(n.prototype,"colorizeItem",function(a,c,d){a.call(this,c,d);d&&c.legendColor&&c.legendSymbol.attr({fill:c.legendColor})})})(q);(function(b){var g=b.defined,t=b.each,k=b.noop;b.colorPointMixin={setVisible:function(b){var e=this,g=b?"show":"hide";t(["graphic","dataLabel"],function(b){if(e[b])e[b][g]()})}};
20b.colorSeriesMixin={pointArrayMap:["value"],axisTypes:["xAxis","yAxis","colorAxis"],optionalAxis:"colorAxis",trackerGroups:["group","markerGroup","dataLabelsGroup"],getSymbol:k,parallelArrays:["x","y","value"],colorKey:"value",translateColors:function(){var b=this,e=this.options.nullColor,g=this.colorAxis,k=this.colorKey;t(this.data,function(n){var l=n[k];if(l=n.options.color||(null===l?e:g&&void 0!==l?g.toColor(l,n):n.color||b.color))n.color=l})},colorAttribs:function(b){var e={};g(b.color)&&(e[this.colorProp||
21"fill"]=b.color);return e}}})(q);(function(b){var g=b.colorPointMixin,t=b.each,k=b.merge,p=b.noop,e=b.pick,q=b.Series,w=b.seriesType,n=b.seriesTypes;w("heatmap","scatter",{animation:!1,borderWidth:0,dataLabels:{formatter:function(){return this.point.value},inside:!0,verticalAlign:"middle",crop:!1,overflow:!1,padding:0},marker:null,pointRange:null,tooltip:{pointFormat:"{point.x}, {point.y}: {point.value}<br/>"},states:{normal:{animation:!0},hover:{halo:!1,brightness:.2}}},k(b.colorSeriesMixin,{pointArrayMap:["y",
22"value"],hasPointSpecificOptions:!0,supportsDrilldown:!0,getExtremesFromAll:!0,directTouch:!0,init:function(){var b;n.scatter.prototype.init.apply(this,arguments);b=this.options;b.pointRange=e(b.pointRange,b.colsize||1);this.yAxis.axisPointRange=b.rowsize||1},translate:function(){var b=this.options,e=this.xAxis,g=this.yAxis,k=function(b,a,c){return Math.min(Math.max(a,b),c)};this.generatePoints();t(this.points,function(m){var a=(b.colsize||1)/2,c=(b.rowsize||1)/2,d=k(Math.round(e.len-e.translate(m.x-
23a,0,1,0,1)),-e.len,2*e.len),a=k(Math.round(e.len-e.translate(m.x+a,0,1,0,1)),-e.len,2*e.len),f=k(Math.round(g.translate(m.y-c,0,1,0,1)),-g.len,2*g.len),c=k(Math.round(g.translate(m.y+c,0,1,0,1)),-g.len,2*g.len);m.plotX=m.clientX=(d+a)/2;m.plotY=(f+c)/2;m.shapeType="rect";m.shapeArgs={x:Math.min(d,a),y:Math.min(f,c),width:Math.abs(a-d),height:Math.abs(c-f)}});this.translateColors()},drawPoints:function(){n.column.prototype.drawPoints.call(this);t(this.points,function(b){b.graphic.attr(this.colorAttribs(b,
24b.state))},this)},animate:p,getBox:p,drawLegendSymbol:b.LegendSymbolMixin.drawRectangle,alignDataLabel:n.column.prototype.alignDataLabel,getExtremes:function(){q.prototype.getExtremes.call(this,this.valueData);this.valueMin=this.dataMin;this.valueMax=this.dataMax;q.prototype.getExtremes.call(this)}}),g)})(q)});