highcharts
Version:
JavaScript charting framework
14 lines • 5.69 kB
JavaScript
/**
* Highcharts JS v12.6.0 (2026-04-13)
* @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";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 r in n)e.o(n,r)&&!e.o(t,r)&&Object.defineProperty(t,r,{enumerable:!0,get:n[r]})},e.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e);let n=t.default;var r=e.n(n);let{doc:o,win:s}=r();function i(t,e){let n;for(n in t||(t={}),e)t[n]=e[n];return t}function l(t){return p(t)&&"number"==typeof t.nodeType}function p(t,e){let n;return!!t&&"object"==typeof t&&(!e||"[object Array]"!==(n=Object.prototype.toString.call(t))&&"[object Array Iterator]"!==n)}function c(){let t=arguments,e=t.length;for(let n=0;n<e;n++){let e=t[n];if(null!=e)return e}}Array.prototype.find;let{deg2rad:a}=r();function u(t,e,n,r){let o=e.options.chart.options3d,s=c(r,!!n&&e.inverted),i={x:e.plotWidth/2,y:e.plotHeight/2,z:o.depth/2,vd:c(o.depth,1)*c(o.viewDistance,0)},l=e.scale3d||1,p=a*o.beta*(s?-1:1),u=a*o.alpha*(s?-1:1),h={cosA:Math.cos(u),cosB:Math.cos(-p),sinA:Math.sin(u),sinB:Math.sin(-p)};return n||(i.x+=e.plotLeft,i.y+=e.plotTop),t.map(function(t){var e,n,r;let o=(e=(s?t.y:t.x)-i.x,n=(s?t.x:t.y)-i.y,r=(t.z||0)-i.z,{x:h.cosB*e-h.sinB*r,y:-h.sinA*h.sinB*e+h.cosA*n-h.cosB*h.sinA*r,z:h.cosA*h.sinB*e+h.sinA*n+h.cosA*h.cosB*r}),p=y(o,i,i.vd);return p.x=p.x*l+i.x,p.y=p.y*l+i.y,p.z=o.z*l+i.z,{x:s?p.y:p.x,y:s?p.x:p.y,z:p.z}})}function y(t,e,n){let r=n>0&&n<1/0?n/(t.z+e.z+n):1;return{x:t.x*r,y:t.y*r}}function h(t){let e=0,n,r;for(n=0;n<t.length;n++)r=(n+1)%t.length,e+=t[n].x*t[r].y-t[r].x*t[n].y;return e/2}let d=t.default.Color;var f=e.n(d);let x=t.default.RendererRegistry;var g=e.n(x);let{parse:z}=f(),{Element3D:b}=g().getRendererType().prototype,C=class extends b{constructor(){super(...arguments),this.parts=["top","bottom","front","back"],this.pathType="cylinder"}fillSetter(t){return this.singleSetterForParts("fill",null,{front:t,back:t,top:z(t).brighten(.1).get(),bottom:z(t).brighten(-.1).get()}),this.color=this.fill=t,this}},{charts:m,deg2rad:M}=r(),{perspective:v}={perspective:u,perspective3D:y,pointCameraDistance:function(t,e){let n=e.options.chart.options3d,r={x:e.plotWidth/2,y:e.plotHeight/2,z:c(n.depth,1)*c(n.viewDistance,0)+n.depth};return Math.sqrt(Math.pow(r.x-c(t.plotX,t.x),2)+Math.pow(r.y-c(t.plotY,t.y),2)+Math.pow(r.z-c(t.plotZ,t.z),2))},shapeArea:h,shapeArea3D:function(t,e,n){return h(u(t,e,n))}};function A(t){return!t.some(t=>"C"===t[0])}function j(t){return this.element3d("cylinder",t)}function B(t){let e=m[this.chartIndex],n=this.cuboidPath(t),r=!n.isTop,o=!n.isFront,s=this.getCylinderEnd(e,t),i=this.getCylinderEnd(e,t,!0);return{front:this.getCylinderFront(s,i),back:this.getCylinderBack(s,i),top:s,bottom:i,zIndexes:{top:3*!!r,bottom:3*!r,front:o?2:1,back:o?1:2,group:n.zIndexes.group}}}function T(t){let e=[["M",t[0].x,t[0].y]],n=t.length-2;for(let r=1;r<n;r+=3)e.push(["C",t[r].x,t[r].y,t[r+1].x,t[r+1].y,t[r+2].x,t[r+2].y]);return e}function O(t,e){let n=[];if(A(t)){let e=t[0],r=t[2];"M"===e[0]&&"L"===r[0]&&(n.push(["M",r[1],r[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(A(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],r=e[3],o=e[4];"C"===t[0]&&"C"===r[0]&&"C"===o[0]&&(n.push(["L",o[5],o[6]]),n.push(["C",o[3],o[4],o[1],o[2],r[5],r[6]]),n.push(["C",r[3],r[4],r[1],r[2],t[5],t[6]]))}return n.push(["Z"]),n}function P(t,e,n){let r,o,{width:s=0,height:i=0,alphaCorrection:l=0}=e,p=c(e.depth,s,0),a=Math.min(s,p)/2,u=M*(t.options.chart.options3d.beta-90+l),y=(e.y||0)+(n?i:0),h=.5519*a,d=s/2+(e.x||0),f=p/2+(e.z||0),x=[{x:0,y:y,z:a},{x:h,y:y,z:a},{x:a,y:y,z:h},{x:a,y:y,z:0},{x:a,y:y,z:-h},{x:h,y:y,z:-a},{x:0,y:y,z:-a},{x:-h,y:y,z:-a},{x:-a,y:y,z:-h},{x:-a,y:y,z:0},{x:-a,y:y,z:h},{x:-h,y:y,z:a},{x:0,y:y,z:a}],g=Math.cos(u),z=Math.sin(u);for(let t of x)r=t.x,o=t.z,t.x=r*g-o*z+d,t.z=o*g+r*z+f;let b=v(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 L(t,e){let n=t.slice(0,3);if(A(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],r=e[1],o=e[2];"M"===t[0]&&"C"===r[0]&&"C"===o[0]&&(n.push(["L",o[5],o[6]]),n.push(["C",o[3],o[4],o[1],o[2],r[5],r[6]]),n.push(["C",r[3],r[4],r[1],r[2],t[1],t[2]]))}return n.push(["Z"]),n}let w=t.default.SeriesRegistry;var _=e.n(w);let{column:{prototype:{pointClass:k}}}=_().seriesTypes;class D extends k{}i(D.prototype,{shapeType:"cylinder"});let{column:E}=_().seriesTypes;class R extends E{}R.compose=function(t){let e=t.prototype;e.cylinder||(e.Element3D.types.cylinder=C,i(e,{cylinder:j,cylinderPath:B,getCurvedPath:T,getCylinderBack:O,getCylinderEnd:P,getCylinderFront:L}))},R.defaultOptions=function(t,...e){let n,r=[t,...e],o={},s=function(t,e){return"object"!=typeof t&&(t={}),function(t,e,n){for(let n in t)Object.hasOwnProperty.call(t,n)&&e.call((0,t[n]),t[n],n,t)}(e,function(n,r){if("__proto__"!==r&&"constructor"!==r){let o;!p(n,!0)||(o=n?.constructor,p(n,!0)&&!l(n)&&o?.name&&"Object"!==o.name)||l(n)?t[r]=e[r]:t[r]=s(t[r]||{},n)}}),t};!0===t&&(o=r[1],r=Array.prototype.slice.call(r,2));let i=r.length;for(n=0;n<i;n++)o=s(o,r[n]);return o}(E.defaultOptions,{}),i(R.prototype,{pointClass:D}),_().registerSeriesType("cylinder",R),R.compose(g().getRendererType());let S=r();export{S as default};