UNPKG

highcharts

Version:
14 lines 6.97 kB
/** * Highcharts JS v13.0.1 (2026-08-17) * @module highcharts/modules/cylinder * @requires highcharts * @requires highcharts/highcharts-3d * * Highcharts cylinder module * * (c) 2010-2026 Highsoft AS * Author: Kacper Madej * * 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 r=t&&t.__esModule?()=>t.default:()=>t;return e.d(r,{a:r}),r},e.d=(t,r)=>{if(Array.isArray(r))for(var s=0;s<r.length;){var i=r[s++],n=r[s++];e.o(t,i)?0===n&&s++:0===n?Object.defineProperty(t,i,{enumerable:!0,value:r[s++]}):Object.defineProperty(t,i,{enumerable:!0,get:n})}else for(var i in r)e.o(r,i)&&!e.o(t,i)&&Object.defineProperty(t,i,{enumerable:!0,get:r[i]})},e.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e);let r=t.default;var s=e.n(r);let i=t.default.SVGRenderer;var n=e.n(i);let{deg2rad:o}=s();function l(t,e,s,i){let n=e.options.chart.options3d,l=(0,r.pick)(i,!!s&&e.inverted),p={x:e.plotWidth/2,y:e.plotHeight/2,z:n.depth/2,vd:(0,r.pick)(n.depth,1)*(0,r.pick)(n.viewDistance,0)},a=e.scale3d||1,d=o*n.beta*(l?-1:1),c=o*n.alpha*(l?-1:1),u={cosA:Math.cos(c),cosB:Math.cos(-d),sinA:Math.sin(c),sinB:Math.sin(-d)};return s||(p.x+=e.plotLeft,p.y+=e.plotTop),t.map(function(t){var e,r,s;let i=(e=(l?t.y:t.x)-p.x,r=(l?t.x:t.y)-p.y,s=(t.z||0)-p.z,{x:u.cosB*e-u.sinB*s,y:-u.sinA*u.sinB*e+u.cosA*r-u.cosB*u.sinA*s,z:u.cosA*u.sinB*e+u.sinA*r+u.cosA*u.cosB*s}),n=h(i,p,p.vd);return n.x=n.x*a+p.x,n.y=n.y*a+p.y,n.z=i.z*a+p.z,{x:l?n.y:n.x,y:l?n.x:n.y,z:n.z}})}function h(t,e,r){let s=r>0&&r<1/0?r/(t.z+e.z+r):1;return{x:t.x*s,y:t.y*s}}function p(t){let e=0,r,s;for(r=0;r<t.length;r++)s=(r+1)%t.length,e+=t[r].x*t[s].y-t[s].x*t[r].y;return e/2}let a=t.default.Color;var d=e.n(a);let c=t.default.SVGElement;var u=e.n(c);let{parse:y}=d();class f extends u(){constructor(){super(...arguments),this.parts=["front","top","side"],this.pathType="cuboid"}initArgs(t){let e=this.renderer,r=e[this.pathType+"Path"](t),s=r.zIndexes;for(let t of this.parts){let i={class:"highcharts-3d-"+t,zIndex:s[t]||0};e.styledMode&&("top"===t?i.filter="url(#highcharts-brighter)":"side"===t&&(i.filter="url(#highcharts-darker)")),this[t]=e.path(r[t]).attr(i).add(this)}this.attr({"stroke-linejoin":"round",zIndex:s.group}),this.forcedSides=r.forcedSides}singleSetterForParts(t,e,r,s,i,n){let o={},l=[null,null,s||"attr",i,n],h=r?.zIndexes;if(r){for(let e of(h?.group&&this.attr({zIndex:h.group}),Object.keys(r)))o[e]={},o[e][t]=r[e],h&&(o[e].zIndex=r.zIndexes[e]||0);l[1]=o}else o[t]=e,l[0]=o;return this.processParts.apply(this,l)}processParts(t,e,s,i,n){for(let o of this.parts)e&&(t=(0,r.pick)(e[o],!1)),!1!==t&&this[o][s](t,i,n);return this}destroy(){return this.processParts(null,null,"destroy"),super.destroy()}attr(t,e,s,i){if("string"==typeof t&&void 0!==e){let r=t;(t={})[r]=e}return t.shapeArgs||(0,r.defined)(t.x)?this.singleSetterForParts("d",null,this.renderer[this.pathType+"Path"](t.shapeArgs||t)):super.attr(t,void 0,s,i)}animate(t,e,s){if((0,r.defined)(t.x)&&(0,r.defined)(t.y)){let r=this.renderer[this.pathType+"Path"](t),i=r.forcedSides;this.singleSetterForParts("d",null,r,"animate",e,s),this.attr({zIndex:r.zIndexes.group}),i!==this.forcedSides&&(this.forcedSides=i,this.renderer.styledMode||this.fillSetter(this.fill))}else super.animate(t,e,s);return this}fillSetter(t){return this.forcedSides=this.forcedSides||[],this.singleSetterForParts("fill",null,{front:t,top:y(t).brighten(this.forcedSides.indexOf("top")>=0?0:.1).get(),side:y(t).brighten(this.forcedSides.indexOf("side")>=0?0:-.1).get()}),this.color=this.fill=t,this}}f.types={base:f,cuboid:f};let x=f,{parse:g}=d(),z=class extends x{constructor(){super(...arguments),this.parts=["top","bottom","front","back"],this.pathType="cylinder"}fillSetter(t){return this.singleSetterForParts("fill",null,{front:t,back:t,top:g(t).brighten(.1).get(),bottom:g(t).brighten(-.1).get()}),this.color=this.fill=t,this}},{charts:b,deg2rad:C}=s(),{perspective:m}={perspective:l,perspective3D:h,pointCameraDistance:function(t,e){let s=e.options.chart.options3d,i={x:e.plotWidth/2,y:e.plotHeight/2,z:(0,r.pick)(s.depth,1)*(0,r.pick)(s.viewDistance,0)+s.depth};return Math.sqrt(Math.pow(i.x-(0,r.pick)(t.plotX,t.x),2)+Math.pow(i.y-(0,r.pick)(t.plotY,t.y),2)+Math.pow(i.z-(0,r.pick)(t.plotZ,t.z),2))},shapeArea:p,shapeArea3D:function(t,e,r){return p(l(t,e,r))}};function M(t){return!t.some(t=>"C"===t[0])}function S(t){return this.element3d("cylinder",t)}function v(t){let e=b[this.chartIndex],r=this.cuboidPath(t),s=!r.isTop,i=!r.isFront,n=this.getCylinderEnd(e,t),o=this.getCylinderEnd(e,t,!0);return{front:this.getCylinderFront(n,o),back:this.getCylinderBack(n,o),top:n,bottom:o,zIndexes:{top:3*!!s,bottom:3*!s,front:i?2:1,back:i?1:2,group:r.zIndexes.group}}}function P(t){let e=[["M",t[0].x,t[0].y]],r=t.length-2;for(let s=1;s<r;s+=3)e.push(["C",t[s].x,t[s].y,t[s+1].x,t[s+1].y,t[s+2].x,t[s+2].y]);return e}function k(t,e){let r=[];if(M(t)){let e=t[0],s=t[2];"M"===e[0]&&"L"===s[0]&&(r.push(["M",s[1],s[2]]),r.push(t[3]),r.push(["L",e[1],e[2]]))}else"C"===t[2][0]&&r.push(["M",t[2][5],t[2][6]]),r.push(t[3],t[4]);if(M(e)){let t=e[0];"M"===t[0]&&(r.push(["L",t[1],t[2]]),r.push(e[3]),r.push(e[2]))}else{let t=e[2],s=e[3],i=e[4];"C"===t[0]&&"C"===s[0]&&"C"===i[0]&&(r.push(["L",i[5],i[6]]),r.push(["C",i[3],i[4],i[1],i[2],s[5],s[6]]),r.push(["C",s[3],s[4],s[1],s[2],t[5],t[6]]))}return r.push(["Z"]),r}function A(t,e,s){let i,n,{width:o=0,height:l=0,alphaCorrection:h=0}=e,p=(0,r.pick)(e.depth,o,0),a=Math.min(o,p)/2,d=C*(t.options.chart.options3d.beta-90+h),c=(e.y||0)+(s?l:0),u=.5519*a,y=o/2+(e.x||0),f=p/2+(e.z||0),x=[{x:0,y:c,z:a},{x:u,y:c,z:a},{x:a,y:c,z:u},{x:a,y:c,z:0},{x:a,y:c,z:-u},{x:u,y:c,z:-a},{x:0,y:c,z:-a},{x:-u,y:c,z:-a},{x:-a,y:c,z:-u},{x:-a,y:c,z:0},{x:-a,y:c,z:u},{x:-u,y:c,z:a},{x:0,y:c,z:a}],g=Math.cos(d),z=Math.sin(d);for(let t of x)i=t.x,n=t.z,t.x=i*g-n*z+y,t.z=n*g+i*z+f;let b=m(x,t,!0);return 2.5>Math.abs(b[3].y-b[9].y)&&2.5>Math.abs(b[0].y-b[6].y)?this.toLinePath([b[0],b[3],b[6],b[9]],!0):this.getCurvedPath(b)}function I(t,e){let r=t.slice(0,3);if(M(e)){let t=e[0];"M"===t[0]&&(r.push(e[2]),r.push(e[1]),r.push(["L",t[1],t[2]]))}else{let t=e[0],s=e[1],i=e[2];"M"===t[0]&&"C"===s[0]&&"C"===i[0]&&(r.push(["L",i[5],i[6]]),r.push(["C",i[3],i[4],i[1],i[2],s[5],s[6]]),r.push(["C",s[3],s[4],s[1],s[2],t[1],t[2]]))}return r.push(["Z"]),r}let T=t.default.SeriesRegistry;var B=e.n(T);let{column:{prototype:{pointClass:O}}}=B().seriesTypes;class F extends O{}(0,r.extend)(F.prototype,{shapeType:"cylinder"});let{column:L}=B().seriesTypes;class j extends L{}j.compose=function(t){let e=t.prototype;e.cylinder||(e.Element3D.types.cylinder=z,(0,r.extend)(e,{cylinder:S,cylinderPath:v,getCurvedPath:P,getCylinderBack:k,getCylinderEnd:A,getCylinderFront:I}))},j.defaultOptions=(0,r.merge)(L.defaultOptions,{}),(0,r.extend)(j.prototype,{pointClass:F}),B().registerSeriesType("cylinder",j),j.compose(n());let w=s();export{w as default};