UNPKG

highcharts

Version:
22 lines (19 loc) 5.99 kB
/* Highmaps JS v8.0.0 (2019-12-10) Tilemap module (c) 2010-2019 Highsoft AS License: www.highcharts.com/license */ (function(c){"object"===typeof module&&module.exports?(c["default"]=c,module.exports=c):"function"===typeof define&&define.amd?define("highcharts/modules/tilemap",["highcharts","highcharts/modules/map"],function(e){c(e);c.Highcharts=e;return c}):c("undefined"!==typeof Highcharts?Highcharts:void 0)})(function(c){function e(u,c,f,e){u.hasOwnProperty(c)||(u[c]=e.apply(null,f))}c=c?c._modules:{};e(c,"modules/tilemap.src.js",[c["parts/Globals.js"],c["parts/Utilities.js"]],function(c,e){var f=e.clamp,u= e.extend,y=e.pick;e=c.seriesType;var x=function(a,b,d){a=a.options;return{xPad:(a.colsize||1)/-b,yPad:(a.rowsize||1)/-d}};c.tileShapeTypes={hexagon:{alignDataLabel:c.seriesTypes.scatter.prototype.alignDataLabel,getSeriesPadding:function(a){return x(a,3,2)},haloPath:function(a){if(!a)return[];var b=this.tileEdges;return["M",b.x2-a,b.y1+a,"L",b.x3+a,b.y1+a,b.x4+1.5*a,b.y2,b.x3+a,b.y3-a,b.x2-a,b.y3-a,b.x1-1.5*a,b.y2,"Z"]},translate:function(){var a=this.options,b=this.xAxis,d=this.yAxis,c=a.pointPadding|| 0,e=(a.colsize||1)/3,v=(a.rowsize||1)/2,m;this.generatePoints();this.points.forEach(function(a){var r=f(Math.floor(b.len-b.translate(a.x-2*e,0,1,0,1)),-b.len,2*b.len),h=f(Math.floor(b.len-b.translate(a.x-e,0,1,0,1)),-b.len,2*b.len),p=f(Math.floor(b.len-b.translate(a.x+e,0,1,0,1)),-b.len,2*b.len),t=f(Math.floor(b.len-b.translate(a.x+2*e,0,1,0,1)),-b.len,2*b.len),q=f(Math.floor(d.translate(a.y-v,0,1,0,1)),-d.len,2*d.len),g=f(Math.floor(d.translate(a.y,0,1,0,1)),-d.len,2*d.len),k=f(Math.floor(d.translate(a.y+ v,0,1,0,1)),-d.len,2*d.len),l=y(a.pointPadding,c),n=l*Math.abs(h-r)/Math.abs(k-g);n=b.reversed?-n:n;var w=b.reversed?-l:l;l=d.reversed?-l:l;a.x%2&&(m=m||Math.round(Math.abs(k-q)/2)*(d.reversed?-1:1),q+=m,g+=m,k+=m);a.plotX=a.clientX=(h+p)/2;a.plotY=g;r+=n+w;h+=w;p-=w;t-=n+w;q-=l;k+=l;a.tileEdges={x1:r,x2:h,x3:p,x4:t,y1:q,y2:g,y3:k};a.shapeType="path";a.shapeArgs={d:["M",h,q,"L",p,q,t,g,p,k,h,k,r,g,"Z"]}});this.translateColors()}},diamond:{alignDataLabel:c.seriesTypes.scatter.prototype.alignDataLabel, getSeriesPadding:function(a){return x(a,2,2)},haloPath:function(a){if(!a)return[];var b=this.tileEdges;return["M",b.x2,b.y1+a,"L",b.x3+a,b.y2,b.x2,b.y3-a,b.x1-a,b.y2,"Z"]},translate:function(){var a=this.options,b=this.xAxis,d=this.yAxis,c=a.pointPadding||0,e=a.colsize||1,v=(a.rowsize||1)/2,m;this.generatePoints();this.points.forEach(function(a){var n=f(Math.round(b.len-b.translate(a.x-e,0,1,0,0)),-b.len,2*b.len),h=f(Math.round(b.len-b.translate(a.x,0,1,0,0)),-b.len,2*b.len),p=f(Math.round(b.len- b.translate(a.x+e,0,1,0,0)),-b.len,2*b.len),t=f(Math.round(d.translate(a.y-v,0,1,0,0)),-d.len,2*d.len),q=f(Math.round(d.translate(a.y,0,1,0,0)),-d.len,2*d.len),g=f(Math.round(d.translate(a.y+v,0,1,0,0)),-d.len,2*d.len),k=y(a.pointPadding,c),l=k*Math.abs(h-n)/Math.abs(g-q);l=b.reversed?-l:l;k=d.reversed?-k:k;a.x%2&&(m=Math.abs(g-t)/2*(d.reversed?-1:1),t+=m,q+=m,g+=m);a.plotX=a.clientX=h;a.plotY=q;n+=l;p-=l;t-=k;g+=k;a.tileEdges={x1:n,x2:h,x3:p,y1:t,y2:q,y3:g};a.shapeType="path";a.shapeArgs={d:["M", h,t,"L",p,q,h,g,n,q,"Z"]}});this.translateColors()}},circle:{alignDataLabel:c.seriesTypes.scatter.prototype.alignDataLabel,getSeriesPadding:function(a){return x(a,2,2)},haloPath:function(a){return c.seriesTypes.scatter.prototype.pointClass.prototype.haloPath.call(this,a+(a&&this.radius))},translate:function(){var a=this.options,b=this.xAxis,d=this.yAxis,c=a.pointPadding||0,e=(a.rowsize||1)/2,v=a.colsize||1,m,r,u,h,p=!1;this.generatePoints();this.points.forEach(function(a){var n=f(Math.round(b.len- b.translate(a.x,0,1,0,0)),-b.len,2*b.len),g=f(Math.round(d.translate(a.y,0,1,0,0)),-d.len,2*d.len),k=c,l=!1;"undefined"!==typeof a.pointPadding&&(k=a.pointPadding,p=l=!0);if(!h||p)m=Math.abs(f(Math.floor(b.len-b.translate(a.x+v,0,1,0,0)),-b.len,2*b.len)-n),r=Math.abs(f(Math.floor(d.translate(a.y+e,0,1,0,0)),-d.len,2*d.len)-g),u=Math.floor(Math.sqrt(m*m+r*r)/2),h=Math.min(m,u,r)-k,p&&!l&&(p=!1);a.x%2&&(g+=r*(d.reversed?-1:1));a.plotX=a.clientX=n;a.plotY=g;a.radius=h;a.shapeType="circle";a.shapeArgs= {x:n,y:g,r:h}});this.translateColors()}},square:{alignDataLabel:c.seriesTypes.heatmap.prototype.alignDataLabel,translate:c.seriesTypes.heatmap.prototype.translate,getSeriesPadding:function(){},haloPath:c.seriesTypes.heatmap.prototype.pointClass.prototype.haloPath}};c.addEvent(c.Axis,"afterSetAxisTranslation",function(){if(!this.recomputingForTilemap&&"colorAxis"!==this.coll){var a=this,b=a.series.map(function(b){return b.getSeriesPixelPadding&&b.getSeriesPixelPadding(a)}).reduce(function(a,b){return(a&& a.padding)>(b&&b.padding)?a:b},void 0)||{padding:0,axisLengthFactor:1},d=Math.round(b.padding*b.axisLengthFactor);b.padding&&(a.len-=d,a.recomputingForTilemap=!0,a.setAxisTranslation(),delete a.recomputingForTilemap,a.minPixelPadding+=b.padding,a.len+=d)}});e("tilemap","heatmap",{states:{hover:{halo:{enabled:!0,size:2,opacity:.5,attributes:{zIndex:3}}}},pointPadding:2,tileShape:"hexagon"},{setOptions:function(){var a=c.seriesTypes.heatmap.prototype.setOptions.apply(this,Array.prototype.slice.call(arguments)); this.tileShape=c.tileShapeTypes[a.tileShape];return a},alignDataLabel:function(){return this.tileShape.alignDataLabel.apply(this,Array.prototype.slice.call(arguments))},getSeriesPixelPadding:function(a){var b=a.isXAxis,d=this.tileShape.getSeriesPadding(this);if(!d)return{padding:0,axisLengthFactor:1};var c=Math.round(a.translate(b?2*d.xPad:d.yPad,0,1,0,1));a=Math.round(a.translate(b?d.xPad:0,0,1,0,1));return{padding:Math.abs(c-a)||0,axisLengthFactor:b?2:1.1}},translate:function(){return this.tileShape.translate.apply(this, Array.prototype.slice.call(arguments))}},u({haloPath:function(){return this.series.tileShape.haloPath.apply(this,Array.prototype.slice.call(arguments))}},c.colorPointMixin));""});e(c,"masters/modules/tilemap.src.js",[],function(){})}); //# sourceMappingURL=tilemap.js.map