heatmap.js 18 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. /*
  2. Highmaps JS v9.1.0 (2021-05-03)
  3. (c) 2009-2021 Torstein Honsi
  4. License: www.highcharts.com/license
  5. */
  6. (function(a){"object"===typeof module&&module.exports?(a["default"]=a,module.exports=a):"function"===typeof define&&define.amd?define("highcharts/modules/heatmap",["highcharts"],function(u){a(u);a.Highcharts=u;return a}):a("undefined"!==typeof Highcharts?Highcharts:void 0)})(function(a){function u(a,n,m,w){a.hasOwnProperty(n)||(a[n]=w.apply(null,m))}a=a?a._modules:{};u(a,"Mixins/ColorSeries.js",[],function(){return{colorPointMixin:{setVisible:function(a){var f=this,m=a?"show":"hide";f.visible=f.options.visible=
  7. !!a;["graphic","dataLabel"].forEach(function(a){if(f[a])f[a][m]()});this.series.buildKDTree()}},colorSeriesMixin:{optionalAxis:"colorAxis",colorAxis:0,translateColors:function(){var a=this,n=this.options.nullColor,m=this.colorAxis,w=this.colorKey;(this.data.length?this.data:this.points).forEach(function(f){var p=f.getNestedProperty(w);(p=f.options.color||(f.isNull||null===f.value?n:m&&"undefined"!==typeof p?m.toColor(p,f):f.color||a.color))&&f.color!==p&&(f.color=p,"point"===a.options.legendType&&
  8. f.legendItem&&a.chart.legend.colorizeItem(f,f.visible))})}}}});u(a,"Core/Axis/ColorAxis.js",[a["Core/Axis/Axis.js"],a["Core/Chart/Chart.js"],a["Core/Color/Color.js"],a["Mixins/ColorSeries.js"],a["Core/Animation/Fx.js"],a["Core/Globals.js"],a["Core/Legend.js"],a["Mixins/LegendSymbol.js"],a["Core/Color/Palette.js"],a["Core/Series/Point.js"],a["Core/Series/Series.js"],a["Core/Utilities.js"]],function(a,n,m,w,y,p,x,H,F,l,t,z){var f=this&&this.__extends||function(){var c=function(k,b){c=Object.setPrototypeOf||
  9. {__proto__:[]}instanceof Array&&function(b,e){b.__proto__=e}||function(b,e){for(var d in e)e.hasOwnProperty(d)&&(b[d]=e[d])};return c(k,b)};return function(k,b){function g(){this.constructor=k}c(k,b);k.prototype=null===b?Object.create(b):(g.prototype=b.prototype,new g)}}(),q=m.parse;m=w.colorPointMixin;w=w.colorSeriesMixin;var C=p.noop,v=z.addEvent,A=z.extend,r=z.isNumber,D=z.merge,B=z.pick,E=z.splat;"";A(t.prototype,w);A(l.prototype,m);n.prototype.collectionsWithUpdate.push("colorAxis");n.prototype.collectionsWithInit.colorAxis=
  10. [n.prototype.addColorAxis];var h=function(c){function k(b,g){var e=c.call(this,b,g)||this;e.beforePadding=!1;e.chart=void 0;e.coll="colorAxis";e.dataClasses=void 0;e.legendItem=void 0;e.legendItems=void 0;e.name="";e.options=void 0;e.stops=void 0;e.visible=!0;e.init(b,g);return e}f(k,c);k.prototype.init=function(b,g){var e=b.options.legend||{},d=g.layout?"vertical"!==g.layout:"vertical"!==e.layout;e=D(k.defaultColorAxisOptions,g,{showEmpty:!1,title:null,visible:e.enabled&&(g?!1!==g.visible:!0)});
  11. this.coll="colorAxis";this.side=g.side||d?2:1;this.reversed=g.reversed||!d;this.opposite=!d;c.prototype.init.call(this,b,e);g.dataClasses&&this.initDataClasses(g);this.initStops();this.horiz=d;this.zoomEnabled=!1};k.prototype.initDataClasses=function(b){var g=this.chart,e,d=0,c=g.options.chart.colorCount,k=this.options,h=b.dataClasses.length;this.dataClasses=e=[];this.legendItems=[];b.dataClasses.forEach(function(b,a){b=D(b);e.push(b);if(g.styledMode||!b.color)"category"===k.dataClassColor?(g.styledMode||
  12. (a=g.options.colors,c=a.length,b.color=a[d]),b.colorIndex=d,d++,d===c&&(d=0)):b.color=q(k.minColor).tweenTo(q(k.maxColor),2>h?.5:a/(h-1))})};k.prototype.hasData=function(){return!!(this.tickPositions||[]).length};k.prototype.setTickPositions=function(){if(!this.dataClasses)return c.prototype.setTickPositions.call(this)};k.prototype.initStops=function(){this.stops=this.options.stops||[[0,this.options.minColor],[1,this.options.maxColor]];this.stops.forEach(function(b){b.color=q(b[1])})};k.prototype.setOptions=
  13. function(b){c.prototype.setOptions.call(this,b);this.options.crosshair=this.options.marker};k.prototype.setAxisSize=function(){var b=this.legendSymbol,g=this.chart,e=g.options.legend||{},d,c;b?(this.left=e=b.attr("x"),this.top=d=b.attr("y"),this.width=c=b.attr("width"),this.height=b=b.attr("height"),this.right=g.chartWidth-e-c,this.bottom=g.chartHeight-d-b,this.len=this.horiz?c:b,this.pos=this.horiz?e:d):this.len=(this.horiz?e.symbolWidth:e.symbolHeight)||k.defaultLegendLength};k.prototype.normalizedValue=
  14. function(b){this.logarithmic&&(b=this.logarithmic.log2lin(b));return 1-(this.max-b)/(this.max-this.min||1)};k.prototype.toColor=function(b,g){var e=this.dataClasses,d=this.stops,c;if(e)for(c=e.length;c--;){var k=e[c];var h=k.from;d=k.to;if(("undefined"===typeof h||b>=h)&&("undefined"===typeof d||b<=d)){var a=k.color;g&&(g.dataClass=c,g.colorIndex=k.colorIndex);break}}else{b=this.normalizedValue(b);for(c=d.length;c--&&!(b>d[c][0]););h=d[c]||d[c+1];d=d[c+1]||h;b=1-(d[0]-b)/(d[0]-h[0]||1);a=h.color.tweenTo(d.color,
  15. b)}return a};k.prototype.getOffset=function(){var b=this.legendGroup,g=this.chart.axisOffset[this.side];b&&(this.axisParent=b,c.prototype.getOffset.call(this),this.added||(this.added=!0,this.labelLeft=0,this.labelRight=this.width),this.chart.axisOffset[this.side]=g)};k.prototype.setLegendColor=function(){var b=this.reversed,g=b?1:0;b=b?0:1;g=this.horiz?[g,0,b,0]:[0,b,0,g];this.legendColor={linearGradient:{x1:g[0],y1:g[1],x2:g[2],y2:g[3]},stops:this.stops}};k.prototype.drawLegendSymbol=function(b,
  16. g){var e=b.padding,d=b.options,c=this.horiz,h=B(d.symbolWidth,c?k.defaultLegendLength:12),a=B(d.symbolHeight,c?12:k.defaultLegendLength),l=B(d.labelPadding,c?16:30);d=B(d.itemDistance,10);this.setLegendColor();g.legendSymbol=this.chart.renderer.rect(0,b.baseline-11,h,a).attr({zIndex:1}).add(g.legendGroup);this.legendItemWidth=h+e+(c?d:l);this.legendItemHeight=a+e+(c?l:0)};k.prototype.setState=function(b){this.series.forEach(function(c){c.setState(b)})};k.prototype.setVisible=function(){};k.prototype.getSeriesExtremes=
  17. function(){var b=this.series,c=b.length,e;this.dataMin=Infinity;for(this.dataMax=-Infinity;c--;){var d=b[c];var h=d.colorKey=B(d.options.colorKey,d.colorKey,d.pointValKey,d.zoneAxis,"y");var k=d.pointArrayMap;var a=d[h+"Min"]&&d[h+"Max"];if(d[h+"Data"])var l=d[h+"Data"];else if(k){l=[];k=k.indexOf(h);var f=d.yData;if(0<=k&&f)for(e=0;e<f.length;e++)l.push(B(f[e][k],f[e]))}else l=d.yData;a?(d.minColorValue=d[h+"Min"],d.maxColorValue=d[h+"Max"]):(l=t.prototype.getExtremes.call(d,l),d.minColorValue=l.dataMin,
  18. d.maxColorValue=l.dataMax);"undefined"!==typeof d.minColorValue&&(this.dataMin=Math.min(this.dataMin,d.minColorValue),this.dataMax=Math.max(this.dataMax,d.maxColorValue));a||t.prototype.applyExtremes.call(d)}};k.prototype.drawCrosshair=function(b,g){var e=g&&g.plotX,d=g&&g.plotY,h=this.pos,k=this.len;if(g){var a=this.toPixels(g.getNestedProperty(g.series.colorKey));a<h?a=h-2:a>h+k&&(a=h+k+2);g.plotX=a;g.plotY=this.len-a;c.prototype.drawCrosshair.call(this,b,g);g.plotX=e;g.plotY=d;this.cross&&!this.cross.addedToColorAxis&&
  19. this.legendGroup&&(this.cross.addClass("highcharts-coloraxis-marker").add(this.legendGroup),this.cross.addedToColorAxis=!0,this.chart.styledMode||"object"!==typeof this.crosshair||this.cross.attr({fill:this.crosshair.color}))}};k.prototype.getPlotLinePath=function(b){var g=this.left,e=b.translatedValue,d=this.top;return r(e)?this.horiz?[["M",e-4,d-6],["L",e+4,d-6],["L",e,d],["Z"]]:[["M",g,e],["L",g-6,e+6],["L",g-6,e-6],["Z"]]:c.prototype.getPlotLinePath.call(this,b)};k.prototype.update=function(b,
  20. g){var e=this.chart.legend;this.series.forEach(function(b){b.isDirtyData=!0});(b.dataClasses&&e.allItems||this.dataClasses)&&this.destroyItems();c.prototype.update.call(this,b,g);this.legendItem&&(this.setLegendColor(),e.colorizeItem(this,!0))};k.prototype.destroyItems=function(){var b=this.chart;this.legendItem?b.legend.destroyItem(this):this.legendItems&&this.legendItems.forEach(function(c){b.legend.destroyItem(c)});b.isDirtyLegend=!0};k.prototype.destroy=function(){this.chart.isDirtyLegend=!0;
  21. this.destroyItems();c.prototype.destroy.apply(this,[].slice.call(arguments))};k.prototype.remove=function(b){this.destroyItems();c.prototype.remove.call(this,b)};k.prototype.getDataClassLegendSymbols=function(){var b=this,c=b.chart,e=b.legendItems,d=c.options.legend,h=d.valueDecimals,k=d.valueSuffix||"",a;e.length||b.dataClasses.forEach(function(d,g){var l=!0,f=d.from,t=d.to,E=c.numberFormatter;a="";"undefined"===typeof f?a="< ":"undefined"===typeof t&&(a="> ");"undefined"!==typeof f&&(a+=E(f,h)+
  22. k);"undefined"!==typeof f&&"undefined"!==typeof t&&(a+=" - ");"undefined"!==typeof t&&(a+=E(t,h)+k);e.push(A({chart:c,name:a,options:{},drawLegendSymbol:H.drawRectangle,visible:!0,setState:C,isDataClass:!0,setVisible:function(){l=b.visible=!l;b.series.forEach(function(b){b.points.forEach(function(b){b.dataClass===g&&b.setVisible(l)})});c.legend.colorizeItem(this,l)}},d))});return e};k.defaultLegendLength=200;k.defaultColorAxisOptions={lineWidth:0,minPadding:0,maxPadding:0,gridLineWidth:1,tickPixelInterval:72,
  23. startOnTick:!0,endOnTick:!0,offset:0,marker:{animation:{duration:50},width:.01,color:F.neutralColor40},labels:{overflow:"justify",rotation:0},minColor:F.highlightColor10,maxColor:F.highlightColor100,tickLength:5,showInLegend:!0};k.keepProps=["legendGroup","legendItemHeight","legendItemWidth","legendItem","legendSymbol"];return k}(a);Array.prototype.push.apply(a.keepProps,h.keepProps);p.ColorAxis=h;["fill","stroke"].forEach(function(c){y.prototype[c+"Setter"]=function(){this.elem.attr(c,q(this.start).tweenTo(q(this.end),
  24. this.pos),null,!0)}});v(n,"afterGetAxes",function(){var c=this,k=c.options;this.colorAxis=[];k.colorAxis&&(k.colorAxis=E(k.colorAxis),k.colorAxis.forEach(function(b,k){b.index=k;new h(c,b)}))});v(t,"bindAxes",function(){var c=this.axisTypes;c?-1===c.indexOf("colorAxis")&&c.push("colorAxis"):this.axisTypes=["colorAxis"]});v(x,"afterGetAllItems",function(c){var h=this,b=[],a,e,d=function(b){b=c.allItems.indexOf(b);-1!==b&&(h.destroyItem(c.allItems[b]),c.allItems.splice(b,1))};(this.chart.colorAxis||
  25. []).forEach(function(c){(a=c.options)&&a.showInLegend&&(a.dataClasses&&a.visible?b=b.concat(c.getDataClassLegendSymbols()):a.visible&&b.push(c),c.series.forEach(function(b){if(!b.options.showInLegend||a.dataClasses)"point"===b.options.legendType?b.points.forEach(function(b){d(b)}):d(b)}))});for(e=b.length;e--;)c.allItems.unshift(b[e])});v(x,"afterColorizeItem",function(c){c.visible&&c.item.legendColor&&c.item.legendSymbol.attr({fill:c.item.legendColor})});v(x,"afterUpdate",function(){var c=this.chart.colorAxis;
  26. c&&c.forEach(function(c,b,h){c.update({},h)})});v(t,"afterTranslate",function(){(this.chart.colorAxis&&this.chart.colorAxis.length||this.colorAttribs)&&this.translateColors()});return h});u(a,"Mixins/ColorMapSeries.js",[a["Core/Globals.js"],a["Core/Series/Point.js"],a["Core/Utilities.js"]],function(a,n,m){var f=m.defined;m=m.addEvent;var y=a.noop;a=a.seriesTypes;m(n,"afterSetState",function(a){this.moveToTopOnHover&&this.graphic&&this.graphic.attr({zIndex:a&&"hover"===a.state?1:0})});return{colorMapPointMixin:{dataLabelOnNull:!0,
  27. moveToTopOnHover:!0,isValid:function(){return null!==this.value&&Infinity!==this.value&&-Infinity!==this.value}},colorMapSeriesMixin:{pointArrayMap:["value"],axisTypes:["xAxis","yAxis","colorAxis"],trackerGroups:["group","markerGroup","dataLabelsGroup"],getSymbol:y,parallelArrays:["x","y","value"],colorKey:"value",pointAttribs:a.column.prototype.pointAttribs,colorAttribs:function(a){var m={};f(a.color)&&(m[this.colorProp||"fill"]=a.color);return m}}}});u(a,"Series/Heatmap/HeatmapPoint.js",[a["Mixins/ColorMapSeries.js"],
  28. a["Core/Series/SeriesRegistry.js"],a["Core/Utilities.js"]],function(a,n,m){var f=this&&this.__extends||function(){var a=function(f,l){a=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(a,l){a.__proto__=l}||function(a,l){for(var f in l)l.hasOwnProperty(f)&&(a[f]=l[f])};return a(f,l)};return function(f,l){function t(){this.constructor=f}a(f,l);f.prototype=null===l?Object.create(l):(t.prototype=l.prototype,new t)}}();a=a.colorMapPointMixin;var y=m.clamp,p=m.extend,x=m.pick;n=function(a){function m(){var l=
  29. null!==a&&a.apply(this,arguments)||this;l.options=void 0;l.series=void 0;l.value=void 0;l.x=void 0;l.y=void 0;return l}f(m,a);m.prototype.applyOptions=function(l,f){l=a.prototype.applyOptions.call(this,l,f);l.formatPrefix=l.isNull||null===l.value?"null":"point";return l};m.prototype.getCellAttributes=function(){var a=this.series,f=a.options,m=(f.colsize||1)/2,n=(f.rowsize||1)/2,q=a.xAxis,p=a.yAxis,v=this.options.marker||a.options.marker;a=a.pointPlacementToXValue();var w=x(this.pointPadding,f.pointPadding,
  30. 0),r={x1:y(Math.round(q.len-(q.translate(this.x-m,!1,!0,!1,!0,-a)||0)),-q.len,2*q.len),x2:y(Math.round(q.len-(q.translate(this.x+m,!1,!0,!1,!0,-a)||0)),-q.len,2*q.len),y1:y(Math.round(p.translate(this.y-n,!1,!0,!1,!0)||0),-p.len,2*p.len),y2:y(Math.round(p.translate(this.y+n,!1,!0,!1,!0)||0),-p.len,2*p.len)};[["width","x"],["height","y"]].forEach(function(a){var l=a[0];a=a[1];var f=a+"1",h=a+"2",c=Math.abs(r[f]-r[h]),k=v&&v.lineWidth||0,b=Math.abs(r[f]+r[h])/2;v[l]&&v[l]<c&&(r[f]=b-v[l]/2-k/2,r[h]=
  31. b+v[l]/2+k/2);w&&("y"===a&&(f=h,h=a+"1"),r[f]+=w,r[h]-=w)});return r};m.prototype.haloPath=function(a){if(!a)return[];var f=this.shapeArgs;return["M",f.x-a,f.y-a,"L",f.x-a,f.y+f.height+a,f.x+f.width+a,f.y+f.height+a,f.x+f.width+a,f.y-a,"Z"]};m.prototype.isValid=function(){return Infinity!==this.value&&-Infinity!==this.value};return m}(n.seriesTypes.scatter.prototype.pointClass);p(n.prototype,{dataLabelOnNull:a.dataLabelOnNull,moveToTopOnHover:a.moveToTopOnHover});return n});u(a,"Series/Heatmap/HeatmapSeries.js",
  32. [a["Mixins/ColorMapSeries.js"],a["Core/Globals.js"],a["Series/Heatmap/HeatmapPoint.js"],a["Mixins/LegendSymbol.js"],a["Core/Color/Palette.js"],a["Core/Series/SeriesRegistry.js"],a["Core/Renderer/SVG/SVGRenderer.js"],a["Core/Utilities.js"]],function(a,n,m,w,y,p,x,u){var f=this&&this.__extends||function(){var a=function(f,h){a=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(a,h){a.__proto__=h}||function(a,h){for(var b in h)h.hasOwnProperty(b)&&(a[b]=h[b])};return a(f,h)};return function(f,
  33. h){function c(){this.constructor=f}a(f,h);f.prototype=null===h?Object.create(h):(c.prototype=h.prototype,new c)}}();a=a.colorMapSeriesMixin;var l=p.series,t=p.seriesTypes,z=t.column,G=t.scatter,q=x.prototype.symbols,C=u.extend,v=u.fireEvent,A=u.isNumber,r=u.merge,D=u.pick;x=function(a){function m(){var h=null!==a&&a.apply(this,arguments)||this;h.colorAxis=void 0;h.data=void 0;h.options=void 0;h.points=void 0;h.valueMax=NaN;h.valueMin=NaN;return h}f(m,a);m.prototype.drawPoints=function(){var a=this;
  34. if((this.options.marker||{}).enabled||this._hasPointMarkers)l.prototype.drawPoints.call(this),this.points.forEach(function(c){c.graphic&&c.graphic[a.chart.styledMode?"css":"animate"](a.colorAttribs(c))})};m.prototype.getExtremes=function(){var a=l.prototype.getExtremes.call(this,this.valueData),c=a.dataMin;a=a.dataMax;A(c)&&(this.valueMin=c);A(a)&&(this.valueMax=a);return l.prototype.getExtremes.call(this)};m.prototype.getValidPoints=function(a,c){return l.prototype.getValidPoints.call(this,a,c,!0)};
  35. m.prototype.hasData=function(){return!!this.processedXData.length};m.prototype.init=function(){l.prototype.init.apply(this,arguments);var a=this.options;a.pointRange=D(a.pointRange,a.colsize||1);this.yAxis.axisPointRange=a.rowsize||1;C(q,{ellipse:q.circle})};m.prototype.markerAttribs=function(a,c){var h=a.marker||{},b=this.options.marker||{},g=a.shapeArgs||{},e={};if(a.hasImage)return{x:a.plotX,y:a.plotY};if(c){var d=b.states[c]||{};var f=h.states&&h.states[c]||{};[["width","x"],["height","y"]].forEach(function(a){e[a[0]]=
  36. (f[a[0]]||d[a[0]]||g[a[0]])+(f[a[0]+"Plus"]||d[a[0]+"Plus"]||0);e[a[1]]=g[a[1]]+(g[a[0]]-e[a[0]])/2})}return c?e:g};m.prototype.pointAttribs=function(a,c){var f=l.prototype.pointAttribs.call(this,a,c),b=this.options||{},g=this.chart.options.plotOptions||{},e=g.series||{},d=g.heatmap||{};g=b.borderColor||d.borderColor||e.borderColor;e=b.borderWidth||d.borderWidth||e.borderWidth||f["stroke-width"];f.stroke=a&&a.marker&&a.marker.lineColor||b.marker&&b.marker.lineColor||g||this.color;f["stroke-width"]=
  37. e;c&&(a=r(b.states[c],b.marker&&b.marker.states[c],a&&a.options.states&&a.options.states[c]||{}),c=a.brightness,f.fill=a.color||n.color(f.fill).brighten(c||0).get(),f.stroke=a.lineColor);return f};m.prototype.setClip=function(a){var c=this.chart;l.prototype.setClip.apply(this,arguments);(!1!==this.options.clip||a)&&this.markerGroup.clip((a||this.clipBox)&&this.sharedClipKey?c.sharedClips[this.sharedClipKey]:c.clipRect)};m.prototype.translate=function(){var a=this.options,c=a.marker&&a.marker.symbol||
  38. "",f=q[c]?c:"rect",b=-1!==["circle","square"].indexOf(f);this.generatePoints();this.points.forEach(function(a){var e=a.getCellAttributes(),d={};d.x=Math.min(e.x1,e.x2);d.y=Math.min(e.y1,e.y2);d.width=Math.max(Math.abs(e.x2-e.x1),0);d.height=Math.max(Math.abs(e.y2-e.y1),0);var g=a.hasImage=0===(a.marker&&a.marker.symbol||c||"").indexOf("url");if(b){var h=Math.abs(d.width-d.height);d.x=Math.min(e.x1,e.x2)+(d.width<d.height?0:h/2);d.y=Math.min(e.y1,e.y2)+(d.width<d.height?h/2:0);d.width=d.height=Math.min(d.width,
  39. d.height)}h={plotX:(e.x1+e.x2)/2,plotY:(e.y1+e.y2)/2,clientX:(e.x1+e.x2)/2,shapeType:"path",shapeArgs:r(!0,d,{d:q[f](d.x,d.y,d.width,d.height)})};g&&(a.marker={width:d.width,height:d.height});C(a,h)});v(this,"afterTranslate")};m.defaultOptions=r(G.defaultOptions,{animation:!1,borderWidth:0,nullColor:y.neutralColor3,dataLabels:{formatter:function(){return this.point.value},inside:!0,verticalAlign:"middle",crop:!1,overflow:!1,padding:0},marker:{symbol:"rect",radius:0,lineColor:void 0,states:{hover:{lineWidthPlus:0},
  40. select:{}}},clip:!0,pointRange:null,tooltip:{pointFormat:"{point.x}, {point.y}: {point.value}<br/>"},states:{hover:{halo:!1,brightness:.2}}});return m}(G);C(x.prototype,{alignDataLabel:z.prototype.alignDataLabel,axisTypes:a.axisTypes,colorAttribs:a.colorAttribs,colorKey:a.colorKey,directTouch:!0,drawLegendSymbol:w.drawRectangle,getExtremesFromAll:!0,getSymbol:l.prototype.getSymbol,parallelArrays:a.parallelArrays,pointArrayMap:["y","value"],pointClass:m,trackerGroups:a.trackerGroups});p.registerSeriesType("heatmap",
  41. x);"";"";return x});u(a,"masters/modules/heatmap.src.js",[],function(){})});
  42. //# sourceMappingURL=heatmap.js.map