heatmap.js 8.6 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
/*
 Highcharts JS v5.0.0 (2016-09-29)

 (c) 2009-2016 Torstein Honsi

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