UNPKG

highcharts

Version:
33 lines (31 loc) 12.4 kB
/* Highmaps JS v8.0.0 (2019-12-10) (c) 2009-2019 Torstein Honsi License: www.highcharts.com/license */ (function(f){"object"===typeof module&&module.exports?(f["default"]=f,module.exports=f):"function"===typeof define&&define.amd?define("highcharts/modules/heatmap",["highcharts"],function(n){f(n);f.Highcharts=n;return f}):f("undefined"!==typeof Highcharts?Highcharts:void 0)})(function(f){function n(a,c,f,k){a.hasOwnProperty(c)||(a[c]=k.apply(null,f))}f=f?f._modules:{};n(f,"parts-map/ColorSeriesMixin.js",[f["parts/Globals.js"]],function(a){a.colorPointMixin={setVisible:function(a){var c=this,f=a?"show": "hide";c.visible=c.options.visible=!!a;["graphic","dataLabel"].forEach(function(a){if(c[a])c[a][f]()})}};a.colorSeriesMixin={optionalAxis:"colorAxis",colorAxis:0,translateColors:function(){var a=this,f=this.options.nullColor,k=this.colorAxis,u=this.colorKey;(this.data.length?this.data:this.points).forEach(function(c){var m=c[u];if(m=c.options.color||(c.isNull?f:k&&"undefined"!==typeof m?k.toColor(m,c):c.color||a.color))c.color=m})}}});n(f,"parts-map/ColorAxis.js",[f["parts/Globals.js"],f["parts/Utilities.js"]], function(a,c){var f=c.erase,k=c.extend,u=c.isNumber,m=c.pick,n=c.splat;c=a.addEvent;var p=a.Axis,q=a.Chart,t=a.Series,v=a.Point,l=a.color,g=a.Legend,A=a.LegendSymbolMixin,B=a.colorPointMixin,y=a.noop,r=a.merge;k(t.prototype,a.colorSeriesMixin);k(v.prototype,B);q.prototype.collectionsWithUpdate.push("colorAxis");q.prototype.collectionsWithInit.colorAxis=[q.prototype.addColorAxis];var w=a.ColorAxis=function(){this.init.apply(this,arguments)};k(w.prototype,p.prototype);k(w.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",rotation:0},minColor:"#e6ebf5",maxColor:"#003399",tickLength:5,showInLegend:!0},keepProps:["legendGroup","legendItemHeight","legendItemWidth","legendItem","legendSymbol"].concat(p.prototype.keepProps),init:function(b,d){this.coll="colorAxis";var h=this.buildOptions.call(b,this.defaultColorAxisOptions,d);p.prototype.init.call(this, b,h);d.dataClasses&&this.initDataClasses(d);this.initStops();this.horiz=!h.opposite;this.zoomEnabled=!1;this.defaultLegendLength=200},initDataClasses:function(b){var d=this.chart,h,e=0,z=d.options.chart.colorCount,a=this.options,c=b.dataClasses.length;this.dataClasses=h=[];this.legendItems=[];b.dataClasses.forEach(function(b,f){b=r(b);h.push(b);if(d.styledMode||!b.color)"category"===a.dataClassColor?(d.styledMode||(f=d.options.colors,z=f.length,b.color=f[e]),b.colorIndex=e,e++,e===z&&(e=0)):b.color= l(a.minColor).tweenTo(l(a.maxColor),2>c?.5:f/(c-1))})},hasData:function(){return!(!this.tickPositions||!this.tickPositions.length)},setTickPositions:function(){if(!this.dataClasses)return p.prototype.setTickPositions.call(this)},initStops:function(){this.stops=this.options.stops||[[0,this.options.minColor],[1,this.options.maxColor]];this.stops.forEach(function(b){b.color=l(b[1])})},buildOptions:function(b,d){var h=this.options.legend,e=d.layout?"vertical"!==d.layout:"vertical"!==h.layout;return r(b, {side:e?2:1,reversed:!e},d,{opposite:!e,showEmpty:!1,title:null,visible:h.enabled&&(d?!1!==d.visible:!0)})},setOptions:function(b){p.prototype.setOptions.call(this,b);this.options.crosshair=this.options.marker},setAxisSize:function(){var b=this.legendSymbol,d=this.chart,h=d.options.legend||{},e,a;b?(this.left=h=b.attr("x"),this.top=e=b.attr("y"),this.width=a=b.attr("width"),this.height=b=b.attr("height"),this.right=d.chartWidth-h-a,this.bottom=d.chartHeight-e-b,this.len=this.horiz?a:b,this.pos=this.horiz? h:e):this.len=(this.horiz?h.symbolWidth:h.symbolHeight)||this.defaultLegendLength},normalizedValue:function(b){this.isLog&&(b=this.val2lin(b));return 1-(this.max-b)/(this.max-this.min||1)},toColor:function(b,d){var h=this.stops,e=this.dataClasses,a;if(e)for(a=e.length;a--;){var c=e[a];var f=c.from;h=c.to;if(("undefined"===typeof f||b>=f)&&("undefined"===typeof h||b<=h)){var g=c.color;d&&(d.dataClass=a,d.colorIndex=c.colorIndex);break}}else{b=this.normalizedValue(b);for(a=h.length;a--&&!(b>h[a][0]);); f=h[a]||h[a+1];h=h[a+1]||f;b=1-(h[0]-b)/(h[0]-f[0]||1);g=f.color.tweenTo(h.color,b)}return g},getOffset:function(){var b=this.legendGroup,d=this.chart.axisOffset[this.side];b&&(this.axisParent=b,p.prototype.getOffset.call(this),this.added||(this.added=!0,this.labelLeft=0,this.labelRight=this.width),this.chart.axisOffset[this.side]=d)},setLegendColor:function(){var b=this.reversed;var d=b?1:0;b=b?0:1;d=this.horiz?[d,0,b,0]:[0,b,0,d];this.legendColor={linearGradient:{x1:d[0],y1:d[1],x2:d[2],y2:d[3]}, stops:this.stops}},drawLegendSymbol:function(b,d){var a=b.padding,e=b.options,c=this.horiz,f=m(e.symbolWidth,c?this.defaultLegendLength:12),g=m(e.symbolHeight,c?12:this.defaultLegendLength),l=m(e.labelPadding,c?16:30);e=m(e.itemDistance,10);this.setLegendColor();d.legendSymbol=this.chart.renderer.rect(0,b.baseline-11,f,g).attr({zIndex:1}).add(d.legendGroup);this.legendItemWidth=f+a+(c?e:l);this.legendItemHeight=g+a+(c?l:0)},setState:function(b){this.series.forEach(function(d){d.setState(b)})},visible:!0, setVisible:y,getSeriesExtremes:function(){var b=this.series,d=b.length,a;this.dataMin=Infinity;for(this.dataMax=-Infinity;d--;){var e=b[d];var c=e.colorKey=m(e.options.colorKey,e.colorKey,e.pointValKey,e.zoneAxis,"y");var f=e.pointArrayMap;var g=e[c+"Min"]&&e[c+"Max"];if(e[c+"Data"])var l=e[c+"Data"];else if(f){l=[];f=f.indexOf(c);var k=e.yData;if(0<=f&&k)for(a=0;a<k.length;a++)l.push(m(k[a][f],k[a]))}else l=e.yData;g?(e.minColorValue=e[c+"Min"],e.maxColorValue=e[c+"Max"]):(t.prototype.getExtremes.call(e, l),e.minColorValue=e.dataMin,e.maxColorValue=e.dataMax);"undefined"!==typeof e.minColorValue&&(this.dataMin=Math.min(this.dataMin,e.minColorValue),this.dataMax=Math.max(this.dataMax,e.maxColorValue));g||t.prototype.getExtremes.call(e)}},drawCrosshair:function(b,d){var a=d&&d.plotX,e=d&&d.plotY,c=this.pos,f=this.len;if(d){var g=this.toPixels(d[d.series.colorKey]);g<c?g=c-2:g>c+f&&(g=c+f+2);d.plotX=g;d.plotY=this.len-g;p.prototype.drawCrosshair.call(this,b,d);d.plotX=a;d.plotY=e;this.cross&&!this.cross.addedToColorAxis&& this.legendGroup&&(this.cross.addClass("highcharts-coloraxis-marker").add(this.legendGroup),this.cross.addedToColorAxis=!0,this.chart.styledMode||this.cross.attr({fill:this.crosshair.color}))}},getPlotLinePath:function(b){var d=b.translatedValue;return u(d)?this.horiz?["M",d-4,this.top-6,"L",d+4,this.top-6,d,this.top,"Z"]:["M",this.left,d,"L",this.left-6,d+6,this.left-6,d-6,"Z"]:p.prototype.getPlotLinePath.apply(this,arguments)},update:function(b,d){var a=this.chart,e=a.legend,c=this.buildOptions.call(a, {},b);this.series.forEach(function(b){b.isDirtyData=!0});(b.dataClasses&&e.allItems||this.dataClasses)&&this.destroyItems();a.options[this.coll]=r(this.userOptions,c);p.prototype.update.call(this,c,d);this.legendItem&&(this.setLegendColor(),e.colorizeItem(this,!0))},destroyItems:function(){var b=this.chart;this.legendItem?b.legend.destroyItem(this):this.legendItems&&this.legendItems.forEach(function(d){b.legend.destroyItem(d)});b.isDirtyLegend=!0},remove:function(b){this.destroyItems();p.prototype.remove.call(this, b)},getDataClassLegendSymbols:function(){var b=this,d=this.chart,a=this.legendItems,e=d.options.legend,c=e.valueDecimals,f=e.valueSuffix||"",g;a.length||this.dataClasses.forEach(function(e,h){var l=!0,m=e.from,r=e.to,u=d.numberFormatter;g="";"undefined"===typeof m?g="< ":"undefined"===typeof r&&(g="> ");"undefined"!==typeof m&&(g+=u(m,c)+f);"undefined"!==typeof m&&"undefined"!==typeof r&&(g+=" - ");"undefined"!==typeof r&&(g+=u(r,c)+f);a.push(k({chart:d,name:g,options:{},drawLegendSymbol:A.drawRectangle, visible:!0,setState:y,isDataClass:!0,setVisible:function(){l=this.visible=!l;b.series.forEach(function(b){b.points.forEach(function(b){b.dataClass===h&&b.setVisible(l)})});d.legend.colorizeItem(this,l)}},e))});return a},beforePadding:!1,name:""});["fill","stroke"].forEach(function(b){a.Fx.prototype[b+"Setter"]=function(){this.elem.attr(b,l(this.start).tweenTo(l(this.end),this.pos),null,!0)}});c(q,"afterGetAxes",function(){var b=this,d=b.options;this.colorAxis=[];d.colorAxis&&(d.colorAxis=n(d.colorAxis), d.colorAxis.forEach(function(d,a){d.index=a;new w(b,d)}))});c(t,"bindAxes",function(){var b=this.axisTypes;b?-1===b.indexOf("colorAxis")&&b.push("colorAxis"):this.axisTypes=["colorAxis"]});c(g,"afterGetAllItems",function(b){var d=[],a,e;(this.chart.colorAxis||[]).forEach(function(e){(a=e.options)&&a.showInLegend&&(a.dataClasses&&a.visible?d=d.concat(e.getDataClassLegendSymbols()):a.visible&&d.push(e),e.series.forEach(function(d){if(!d.options.showInLegend||a.dataClasses)"point"===d.options.legendType? d.points.forEach(function(d){f(b.allItems,d)}):f(b.allItems,d)}))});for(e=d.length;e--;)b.allItems.unshift(d[e])});c(g,"afterColorizeItem",function(b){b.visible&&b.item.legendColor&&b.item.legendSymbol.attr({fill:b.item.legendColor})});c(g,"afterUpdate",function(){var b=this.chart.colorAxis;b&&b.forEach(function(b,a,e){b.update({},e)})});c(t,"afterTranslate",function(){(this.chart.colorAxis&&this.chart.colorAxis.length||this.colorAttribs)&&this.translateColors()})});n(f,"parts-map/ColorMapSeriesMixin.js", [f["parts/Globals.js"],f["parts/Utilities.js"]],function(a,c){var f=c.defined;c=a.noop;var k=a.seriesTypes;a.colorMapPointMixin={dataLabelOnNull:!0,isValid:function(){return null!==this.value&&Infinity!==this.value&&-Infinity!==this.value},setState:function(c){a.Point.prototype.setState.call(this,c);this.graphic&&this.graphic.attr({zIndex:"hover"===c?1:0})}};a.colorMapSeriesMixin={pointArrayMap:["value"],axisTypes:["xAxis","yAxis","colorAxis"],trackerGroups:["group","markerGroup","dataLabelsGroup"], getSymbol:c,parallelArrays:["x","y","value"],colorKey:"value",pointAttribs:k.column.prototype.pointAttribs,colorAttribs:function(a){var c={};f(a.color)&&(c[this.colorProp||"fill"]=a.color);return c}}});n(f,"parts-map/HeatmapSeries.js",[f["parts/Globals.js"],f["parts/Utilities.js"]],function(a,c){var f=c.clamp,k=c.extend,n=c.pick;c=a.colorMapPointMixin;var m=a.merge,x=a.noop,p=a.fireEvent,q=a.Series,t=a.seriesType,v=a.seriesTypes;t("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:{hover:{halo:!1,brightness:.2}}},m(a.colorMapSeriesMixin,{pointArrayMap:["y","value"],hasPointSpecificOptions:!0,getExtremesFromAll:!0,directTouch:!0,init:function(){v.scatter.prototype.init.apply(this,arguments);var a=this.options;a.pointRange=n(a.pointRange,a.colsize||1);this.yAxis.axisPointRange= a.rowsize||1},translate:function(){var a=this.options,c=this.xAxis,k=this.yAxis,m=a.pointPadding||0,q=this.pointPlacementToXValue();this.generatePoints();this.points.forEach(function(g){var l=(a.colsize||1)/2,b=(a.rowsize||1)/2,d=f(Math.round(c.len-c.translate(g.x-l,0,1,0,1,-q)),-c.len,2*c.len);l=f(Math.round(c.len-c.translate(g.x+l,0,1,0,1,-q)),-c.len,2*c.len);var h=f(Math.round(k.translate(g.y-b,0,1,0,1)),-k.len,2*k.len);b=f(Math.round(k.translate(g.y+b,0,1,0,1)),-k.len,2*k.len);var e=n(g.pointPadding, m);g.plotX=g.clientX=(d+l)/2;g.plotY=(h+b)/2;g.shapeType="rect";g.shapeArgs={x:Math.min(d,l)+e,y:Math.min(h,b)+e,width:Math.max(Math.abs(l-d)-2*e,0),height:Math.max(Math.abs(b-h)-2*e,0)}});p(this,"afterTranslate")},drawPoints:function(){var a=this.chart.styledMode?"css":"animate";v.column.prototype.drawPoints.call(this);this.points.forEach(function(c){c.graphic[a](this.colorAttribs(c))},this)},hasData:function(){return!!this.processedXData.length},getValidPoints:function(a,c){return q.prototype.getValidPoints.call(this, a,c,!0)},animate:x,getBox:x,drawLegendSymbol:a.LegendSymbolMixin.drawRectangle,alignDataLabel:v.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)}}),k({haloPath:function(a){if(!a)return[];var c=this.shapeArgs;return["M",c.x-a,c.y-a,"L",c.x-a,c.y+c.height+a,c.x+c.width+a,c.y+c.height+a,c.x+c.width+a,c.y-a,"Z"]}},c));""});n(f,"masters/modules/heatmap.src.js", [],function(){})}); //# sourceMappingURL=heatmap.js.map