highcharts
Version:
JavaScript charting framework
13 lines • 9.53 kB
JavaScript
/**
* Highmaps JS v13.0.1 (2026-08-17)
* @module highcharts/modules/tilemap
* @requires highcharts
* @requires highcharts/modules/map
*
* Tilemap module
*
* (c) 2010-2026 Highsoft AS
*
* A commercial license may be required depending on use,
* see www.highcharts.com/license
*/import*as t from"../highcharts.js";let e={};e.n=t=>{let a=t&&t.__esModule?()=>t.default:()=>t;return e.d(a,{a:a}),a},e.d=(t,a)=>{if(Array.isArray(a))for(var i=0;i<a.length;){var s=a[i++],o=a[i++];e.o(t,s)?0===o&&i++:0===o?Object.defineProperty(t,s,{enumerable:!0,value:a[i++]}):Object.defineProperty(t,s,{enumerable:!0,get:o})}else for(var s in a)e.o(a,s)&&!e.o(t,s)&&Object.defineProperty(t,s,{enumerable:!0,get:a[s]})},e.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e);let a=t.default;var i,s=e.n(a);let o=t.default.SeriesRegistry;var l=e.n(o);let n=t.default.Color,{parse:r}=e.n(n)();!function(t){let e;function i(){let{userOptions:t}=this;this.colorAxis=[],t.colorAxis&&(t.colorAxis=(0,a.splat)(t.colorAxis),t.colorAxis.map(t=>new e(this,t)))}function s(t){let e=this.chart.colorAxis||[],a=e=>{let a=t.allItems.indexOf(e);-1!==a&&(this.destroyItem(t.allItems[a]),t.allItems.splice(a,1))},i=[],s,o;for(e.forEach(function(t){s=t.options,s?.showInLegend&&(s.dataClasses&&s.visible?i=i.concat(t.getDataClassLegendSymbols()):s.visible&&i.push(t),t.series.forEach(function(t){(!t.options.showInLegend||s.dataClasses)&&("point"===t.options.legendType?t.points.forEach(function(t){a(t)}):a(t))}))}),o=i.length;o--;)t.allItems.unshift(i[o])}function o(t){t.visible&&t.item.legendColor&&t.item.legendItem.symbol.attr({fill:t.item.legendColor})}function l(t){this.chart.colorAxis?.forEach(e=>{e.update({},t.redraw)})}function n(){(this.chart.colorAxis?.length||this.colorAttribs)&&this.translateColors()}function p(){let t=this.axisTypes;t?-1===t.indexOf("colorAxis")&&t.push("colorAxis"):this.axisTypes=["colorAxis"]}function h(t){let e=this,a=t?"show":"hide";e.visible=e.options.visible=!!t,["graphic","dataLabel"].forEach(function(t){e[t]&&e[t][a]()}),this.series.buildKDTree()}function d(){let t=this,e=this.getPointsCollection(),a=this.options.nullColor,i=this.colorAxis,s=this.colorKey;e.forEach(e=>{let o=e.getNestedProperty(s),l=e.options.color||(e.isNull||null===e.value?a:i&&void 0!==o?i.toColor(o,e):e.color||t.color);l&&e.color!==l&&(e.color=l,"point"===t.options.legendType&&e.legendItem&&e.legendItem.label&&t.chart.legend.colorizeItem(e,e.visible))})}function c(){this.elem.attr("fill",r(this.start).tweenTo(r(this.end),this.pos),void 0,!0)}function u(){this.elem.attr("stroke",r(this.start).tweenTo(r(this.end),this.pos),void 0,!0)}t.compose=function(t,r,x,g,f){var y;let m,b=r.prototype,A=x.prototype,P=f.prototype;b.collectionsWithUpdate.includes("colorAxis")||(e=t,b.collectionsWithUpdate.push("colorAxis"),b.collectionsWithInit.colorAxis=[b.addColorAxis],(0,a.addEvent)(r,"afterCreateAxes",i),m=(y=r).prototype.createAxis,y.prototype.createAxis=function(t,i){if("colorAxis"!==t)return m.apply(this,arguments);let s=new e(this,(0,a.merge)(i.axis,{index:this[t].length,isX:!1}));return this.isDirtyLegend=!0,this.axes.forEach(t=>{t.series=[]}),this.series.forEach(t=>{t.bindAxes(),t.isDirtyData=!0}),(0,a.pick)(i.redraw,!0)&&this.redraw(i.animation),s},A.fillSetter=c,A.strokeSetter=u,(0,a.addEvent)(g,"afterGetAllItems",s),(0,a.addEvent)(g,"afterColorizeItem",o),(0,a.addEvent)(g,"afterUpdate",l),(0,a.extend)(P,{optionalAxis:"colorAxis",translateColors:d}),(0,a.extend)(P.pointClass.prototype,{setVisible:h}),(0,a.addEvent)(f,"afterTranslate",n,{order:1}),(0,a.addEvent)(f,"bindAxes",p))},t.pointSetVisible=h}(i||(i={}));let p=i,{series:{prototype:{pointClass:h}},seriesTypes:{heatmap:{prototype:{pointClass:d}}}}=l();class c extends d{haloPath(){return this.series.tileShape.haloPath.apply(this,arguments)}}(0,a.extend)(c.prototype,{setState:h.prototype.setState,setVisible:p.pointSetVisible});let{noop:u}=s(),{heatmap:x,scatter:g}=l().seriesTypes;function f(t,e,a){let i=t.options;return{xPad:-((i.colsize||1)/e),yPad:-((i.rowsize||1)/a)}}let y={hexagon:{alignDataLabel:g.prototype.alignDataLabel,getSeriesPadding:function(t){return f(t,3,2)},haloPath:function(t){if(!t)return[];let e=this.tileEdges;return[["M",e.x2-t,e.y1+t],["L",e.x3+t,e.y1+t],["L",e.x4+1.5*t,e.y2],["L",e.x3+t,e.y3-t],["L",e.x2-t,e.y3-t],["L",e.x1-1.5*t,e.y2],["Z"]]},translate:function(){let t,e=this.options,i=this.xAxis,s=this.yAxis,o=e.pointPadding||0,l=(e.colsize||1)/3,n=(e.rowsize||1)/2;for(let e of(this.generatePoints(),this.points)){let r=(0,a.clamp)(Math.floor(i.len-i.translate(e.x-2*l,0,1,0,1)),-i.len,2*i.len),p=(0,a.clamp)(Math.floor(i.len-i.translate(e.x-l,0,1,0,1)),-i.len,2*i.len),h=(0,a.clamp)(Math.floor(i.len-i.translate(e.x+l,0,1,0,1)),-i.len,2*i.len),d=(0,a.clamp)(Math.floor(i.len-i.translate(e.x+2*l,0,1,0,1)),-i.len,2*i.len),c=(0,a.clamp)(Math.floor(s.translate(e.y-n,0,1,0,1)),-s.len,2*s.len),u=(0,a.clamp)(Math.floor(s.translate(e.y,0,1,0,1)),-s.len,2*s.len),x=(0,a.clamp)(Math.floor(s.translate(e.y+n,0,1,0,1)),-s.len,2*s.len),g=e.pointPadding??o,f=g*Math.abs(p-r)/Math.abs(x-u),y=i.reversed?-f:f,m=i.reversed?-g:g,b=s.reversed?-g:g;e.x%2&&(t=t||Math.round(Math.abs(x-c)/2)*(s.reversed?-1:1),c+=t,u+=t,x+=t),e.plotX=e.clientX=(p+h)/2,e.plotY=u,e.tileEdges={x1:r+=y+m,x2:p+=m,x3:h-=m,x4:d-=y+m,y1:c-=b,y2:u,y3:x+=b},e.shapeType="path",e.shapeArgs={d:[["M",p,c],["L",h,c],["L",d,u],["L",h,x],["L",p,x],["L",r,u],["Z"]]}}this.translateColors()}},diamond:{alignDataLabel:g.prototype.alignDataLabel,getSeriesPadding:function(t){return f(t,2,2)},haloPath:function(t){if(!t)return[];let e=this.tileEdges;return[["M",e.x2,e.y1+t],["L",e.x3+t,e.y2],["L",e.x2,e.y3-t],["L",e.x1-t,e.y2],["Z"]]},translate:function(){let t,e=this.options,i=this.xAxis,s=this.yAxis,o=e.pointPadding||0,l=e.colsize||1,n=(e.rowsize||1)/2;for(let e of(this.generatePoints(),this.points)){let r=(0,a.clamp)(Math.round(i.len-i.translate(e.x-l,0,1,0,0)),-i.len,2*i.len),p=(0,a.clamp)(Math.round(i.len-i.translate(e.x+l,0,1,0,0)),-i.len,2*i.len),h=(0,a.clamp)(Math.round(s.translate(e.y-n,0,1,0,0)),-s.len,2*s.len),d=(0,a.clamp)(Math.round(s.translate(e.y,0,1,0,0)),-s.len,2*s.len),c=(0,a.clamp)(Math.round(s.translate(e.y+n,0,1,0,0)),-s.len,2*s.len),u=(0,a.clamp)(Math.round(i.len-i.translate(e.x,0,1,0,0)),-i.len,2*i.len),x=(0,a.pick)(e.pointPadding,o),g=x*Math.abs(u-r)/Math.abs(c-d),f=i.reversed?-g:g,y=s.reversed?-x:x;e.x%2&&(t=Math.abs(c-h)/2*(s.reversed?-1:1),h+=t,d+=t,c+=t),e.plotX=e.clientX=u,e.plotY=d,e.tileEdges={x1:r+=f,x2:u,x3:p-=f,y1:h-=y,y2:d,y3:c+=y},e.shapeType="path",e.shapeArgs={d:[["M",u,h],["L",p,d],["L",u,c],["L",r,d],["Z"]]}}this.translateColors()}},circle:{alignDataLabel:g.prototype.alignDataLabel,getSeriesPadding:function(t){return f(t,2,2)},haloPath:function(t){return g.prototype.pointClass.prototype.haloPath.call(this,t+(t&&this.radius))},translate:function(){let t=this.options,e=this.xAxis,i=this.yAxis,s=t.pointPadding||0,o=(t.rowsize||1)/2,l=t.colsize||1,n,r,p,h,d=!1;for(let t of(this.generatePoints(),this.points)){let c=(0,a.clamp)(Math.round(e.len-e.translate(t.x,0,1,0,0)),-e.len,2*e.len),u=s,x=!1,g=(0,a.clamp)(Math.round(i.translate(t.y,0,1,0,0)),-i.len,2*i.len);void 0!==t.pointPadding&&(u=t.pointPadding,x=!0,d=!0),(!h||d)&&(p=Math.floor(Math.sqrt((n=Math.abs((0,a.clamp)(Math.floor(e.len-e.translate(t.x+l,0,1,0,0)),-e.len,2*e.len)-c))*n+(r=Math.abs((0,a.clamp)(Math.floor(i.translate(t.y+o,0,1,0,0)),-i.len,2*i.len)-g))*r)/2),h=Math.min(n,p,r)-u,d&&!x&&(d=!1)),t.x%2&&(g+=r*(i.reversed?-1:1)),t.plotX=t.clientX=c,t.plotY=g,t.radius=h,t.shapeType="circle",t.shapeArgs={x:c,y:g,r:h}}this.translateColors()}},square:{alignDataLabel:x.prototype.alignDataLabel,translate:x.prototype.translate,getSeriesPadding:u,haloPath:x.prototype.pointClass.prototype.haloPath}},{composed:m,noop:b}=s(),{column:A,heatmap:P,scatter:M}=l().seriesTypes;function v(){if(this.recomputingForTilemap||"colorAxis"===this.coll)return;let t=this,e=t.series.map(function(e){return e.getSeriesPixelPadding&&e.getSeriesPixelPadding(t)}).reduce(function(t,e){return(t&&t.padding)>(e&&e.padding)?t:e},void 0)||{padding:0,axisLengthFactor:1},a=Math.round(e.padding*e.axisLengthFactor);e.padding&&(t.len-=a,t.recomputingForTilemap=!0,t.setAxisTranslation(),delete t.recomputingForTilemap,t.minPixelPadding+=e.padding,t.len+=a)}class L extends P{static compose(t){(0,a.pushUnique)(m,"TilemapSeries")&&(0,a.addEvent)(t,"afterSetAxisTranslation",v)}alignDataLabel(){return this.tileShape.alignDataLabel.apply(this,arguments)}drawPoints(){for(let t of(A.prototype.drawPoints.call(this),this.points))t.graphic&&t.graphic[this.chart.styledMode?"css":"animate"](this.colorAttribs(t))}getSeriesPixelPadding(t){let e=t.isXAxis,a=this.tileShape.getSeriesPadding(this);if(!a)return{padding:0,axisLengthFactor:1};let i=Math.round(t.translate(e?2*a.xPad:a.yPad,0,1,0,1)),s=Math.round(t.translate(e?a.xPad:0,0,1,0,1));return{padding:(t.single?Math.abs(i-s)/2:Math.abs(i-s))||0,axisLengthFactor:e?2:1.1}}setOptions(){let t=super.setOptions.apply(this,arguments);return this.tileShape=y[t.tileShape],t}translate(){return this.tileShape.translate.apply(this,arguments)}}L.defaultOptions=(0,a.merge)(P.defaultOptions,{marker:null,states:{hover:{halo:{enabled:!0,size:2,opacity:.5,attributes:{zIndex:3}}}},pointPadding:2,tileShape:"hexagon"}),(0,a.extend)(L.prototype,{getSymbol:b,markerAttribs:M.prototype.markerAttribs,pointAttribs:A.prototype.pointAttribs,pointClass:c}),l().registerSeriesType("tilemap",L);let S=s();L.compose(S.Axis);let C=s();export{C as default};