highcharts
Version:
JavaScript charting framework
12 lines • 4.9 kB
JavaScript
/**
* Highcharts JS v12.3.0 (2025-06-21)
* @module highcharts/modules/cylinder
* @requires highcharts
* @requires highcharts/highcharts-3d
*
* Highcharts cylinder module
*
* (c) 2010-2025 Kacper Madej
*
* License: www.highcharts.com/license
*/import*as t from"../highcharts.js";import"../highcharts-3d.js";var e={};e.n=t=>{var n=t&&t.__esModule?()=>t.default:()=>t;return e.d(n,{a:n}),n},e.d=(t,n)=>{for(var s in n)e.o(n,s)&&!e.o(t,s)&&Object.defineProperty(t,s,{enumerable:!0,get:n[s]})},e.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e);let n=t.default;var s=e.n(n);let{deg2rad:r}=s(),{pick:o}=s();function i(t,e,n,s){let i=e.options.chart.options3d,p=o(s,!!n&&e.inverted),h={x:e.plotWidth/2,y:e.plotHeight/2,z:i.depth/2,vd:o(i.depth,1)*o(i.viewDistance,0)},a=e.scale3d||1,y=r*i.beta*(p?-1:1),c=r*i.alpha*(p?-1:1),u={cosA:Math.cos(c),cosB:Math.cos(-y),sinA:Math.sin(c),sinB:Math.sin(-y)};return n||(h.x+=e.plotLeft,h.y+=e.plotTop),t.map(function(t){var e,n,s;let r=(e=(p?t.y:t.x)-h.x,n=(p?t.x:t.y)-h.y,s=(t.z||0)-h.z,{x:u.cosB*e-u.sinB*s,y:-u.sinA*u.sinB*e+u.cosA*n-u.cosB*u.sinA*s,z:u.cosA*u.sinB*e+u.sinA*n+u.cosA*u.cosB*s}),o=l(r,h,h.vd);return o.x=o.x*a+h.x,o.y=o.y*a+h.y,o.z=r.z*a+h.z,{x:p?o.y:o.x,y:p?o.x:o.y,z:o.z}})}function l(t,e,n){let s=n>0&&n<Number.POSITIVE_INFINITY?n/(t.z+e.z+n):1;return{x:t.x*s,y:t.y*s}}function p(t){let e=0,n,s;for(n=0;n<t.length;n++)s=(n+1)%t.length,e+=t[n].x*t[s].y-t[s].x*t[n].y;return e/2}let h=t.default.Color;var a=e.n(h);let y=t.default.RendererRegistry;var c=e.n(y);let{parse:u}=a(),{Element3D:d}=c().getRendererType().prototype,x=class extends d{constructor(){super(...arguments),this.parts=["top","bottom","front","back"],this.pathType="cylinder"}fillSetter(t){return this.singleSetterForParts("fill",null,{front:t,back:t,top:u(t).brighten(.1).get(),bottom:u(t).brighten(-.1).get()}),this.color=this.fill=t,this}},{charts:f,deg2rad:z}=s(),{perspective:g}={perspective:i,perspective3D:l,pointCameraDistance:function(t,e){let n=e.options.chart.options3d,s={x:e.plotWidth/2,y:e.plotHeight/2,z:o(n.depth,1)*o(n.viewDistance,0)+n.depth};return Math.sqrt(Math.pow(s.x-o(t.plotX,t.x),2)+Math.pow(s.y-o(t.plotY,t.y),2)+Math.pow(s.z-o(t.plotZ,t.z),2))},shapeArea:p,shapeArea3D:function(t,e,n){return p(i(t,e,n))}},{extend:C,pick:M}=s();function m(t){return!t.some(t=>"C"===t[0])}function b(t){return this.element3d("cylinder",t)}function v(t){let e=f[this.chartIndex],n=this.cuboidPath(t),s=!n.isTop,r=!n.isFront,o=this.getCylinderEnd(e,t),i=this.getCylinderEnd(e,t,!0);return{front:this.getCylinderFront(o,i),back:this.getCylinderBack(o,i),top:o,bottom:i,zIndexes:{top:3*!!s,bottom:3*!s,front:r?2:1,back:r?1:2,group:n.zIndexes.group}}}function T(t){let e=[["M",t[0].x,t[0].y]],n=t.length-2;for(let s=1;s<n;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 B(t,e){let n=[];if(m(t)){let e=t[0],s=t[2];"M"===e[0]&&"L"===s[0]&&(n.push(["M",s[1],s[2]]),n.push(t[3]),n.push(["L",e[1],e[2]]))}else"C"===t[2][0]&&n.push(["M",t[2][5],t[2][6]]),n.push(t[3],t[4]);if(m(e)){let t=e[0];"M"===t[0]&&(n.push(["L",t[1],t[2]]),n.push(e[3]),n.push(e[2]))}else{let t=e[2],s=e[3],r=e[4];"C"===t[0]&&"C"===s[0]&&"C"===r[0]&&(n.push(["L",r[5],r[6]]),n.push(["C",r[3],r[4],r[1],r[2],s[5],s[6]]),n.push(["C",s[3],s[4],s[1],s[2],t[5],t[6]]))}return n.push(["Z"]),n}function A(t,e,n){let s,r,o,{width:i=0,height:l=0,alphaCorrection:p=0}=e,h=M(e.depth,i,0),a=Math.min(i,h)/2,y=z*(t.options.chart.options3d.beta-90+p),c=(e.y||0)+(n?l:0),u=.5519*a,d=i/2+(e.x||0),x=h/2+(e.z||0),f=[{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}],C=Math.cos(y),m=Math.sin(y);for(let t of f)r=t.x,o=t.z,t.x=r*C-o*m+d,t.z=o*C+r*m+x;let b=g(f,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 P(t,e){let n=t.slice(0,3);if(m(e)){let t=e[0];"M"===t[0]&&(n.push(e[2]),n.push(e[1]),n.push(["L",t[1],t[2]]))}else{let t=e[0],s=e[1],r=e[2];"M"===t[0]&&"C"===s[0]&&"C"===r[0]&&(n.push(["L",r[5],r[6]]),n.push(["C",r[3],r[4],r[1],r[2],s[5],s[6]]),n.push(["C",s[3],s[4],s[1],s[2],t[1],t[2]]))}return n.push(["Z"]),n}let I=t.default.SeriesRegistry;var L=e.n(I);let{column:{prototype:{pointClass:k}}}=L().seriesTypes,{extend:w}=s();class D extends k{}w(D.prototype,{shapeType:"cylinder"});let{column:E}=L().seriesTypes,{extend:O,merge:F}=s();class R extends E{}R.compose=function(t){let e=t.prototype;e.cylinder||(e.Element3D.types.cylinder=x,C(e,{cylinder:b,cylinderPath:v,getCurvedPath:T,getCylinderBack:B,getCylinderEnd:A,getCylinderFront:P}))},R.defaultOptions=F(E.defaultOptions,{}),O(R.prototype,{pointClass:D}),L().registerSeriesType("cylinder",R),e.d({},{}),R.compose(c().getRendererType());let S=s();export{S as default};