UNPKG

highcharts

Version:
14 lines 7.85 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 */function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e(t._Highcharts,t._Highcharts.SVGRenderer,t._Highcharts.Color,t._Highcharts.SVGElement,t._Highcharts.SeriesRegistry):"function"==typeof define&&define.amd?define("highcharts/modules/cylinder",["highcharts/highcharts"],function(t){return e(t,t.SVGRenderer,t.Color,t.SVGElement,t.SeriesRegistry)}):"object"==typeof exports?exports["highcharts/modules/cylinder"]=e(t._Highcharts,t._Highcharts.SVGRenderer,t._Highcharts.Color,t._Highcharts.SVGElement,t._Highcharts.SeriesRegistry):t.Highcharts=e(t.Highcharts,t.Highcharts.SVGRenderer,t.Highcharts.Color,t.Highcharts.SVGElement,t.Highcharts.SeriesRegistry)}("u"<typeof window?this:window,(t,e,r,s,i)=>(()=>{"use strict";var n={620(t){t.exports=r},28(t){t.exports=s},540(t){t.exports=e},512(t){t.exports=i},944(e){e.exports=t}};let o={};function h(t){let e=o[t];if(void 0!==e)return e.exports;let r=o[t]={exports:{}};return n[t](r,r.exports,h),r.exports}h.n=t=>{let e=t&&t.__esModule?()=>t.default:()=>t;return h.d(e,{a:e}),e},h.d=(t,e)=>{if(Array.isArray(e))for(var r=0;r<e.length;){var s=e[r++],i=e[r++];h.o(t,s)?0===i&&r++:0===i?Object.defineProperty(t,s,{enumerable:!0,value:e[r++]}):Object.defineProperty(t,s,{enumerable:!0,get:i})}else for(var s in e)h.o(e,s)&&!h.o(t,s)&&Object.defineProperty(t,s,{enumerable:!0,get:e[s]})},h.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e);let l={};h.d(l,{default:()=>D});var p=h(944),a=h.n(p),d=h(540),c=h.n(d);let{deg2rad:u}=a();function y(t,e,r,s){let i=e.options.chart.options3d,n=(0,p.pick)(s,!!r&&e.inverted),o={x:e.plotWidth/2,y:e.plotHeight/2,z:i.depth/2,vd:(0,p.pick)(i.depth,1)*(0,p.pick)(i.viewDistance,0)},h=e.scale3d||1,l=u*i.beta*(n?-1:1),a=u*i.alpha*(n?-1:1),d={cosA:Math.cos(a),cosB:Math.cos(-l),sinA:Math.sin(a),sinB:Math.sin(-l)};return r||(o.x+=e.plotLeft,o.y+=e.plotTop),t.map(function(t){var e,r,s;let i=(e=(n?t.y:t.x)-o.x,r=(n?t.x:t.y)-o.y,s=(t.z||0)-o.z,{x:d.cosB*e-d.sinB*s,y:-d.sinA*d.sinB*e+d.cosA*r-d.cosB*d.sinA*s,z:d.cosA*d.sinB*e+d.sinA*r+d.cosA*d.cosB*s}),l=f(i,o,o.vd);return l.x=l.x*h+o.x,l.y=l.y*h+o.y,l.z=i.z*h+o.z,{x:n?l.y:l.x,y:n?l.x:l.y,z:l.z}})}function f(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 x(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}var g=h(620),z=h.n(g),b=h(28),m=h.n(b);let{parse:S}=z();class C extends m(){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={},h=[null,null,s||"attr",i,n],l=r?.zIndexes;if(r){for(let e of(l?.group&&this.attr({zIndex:l.group}),Object.keys(r)))o[e]={},o[e][t]=r[e],l&&(o[e].zIndex=r.zIndexes[e]||0);h[1]=o}else o[t]=e,h[0]=o;return this.processParts.apply(this,h)}processParts(t,e,r,s,i){for(let n of this.parts)e&&(t=(0,p.pick)(e[n],!1)),!1!==t&&this[n][r](t,s,i);return this}destroy(){return this.processParts(null,null,"destroy"),super.destroy()}attr(t,e,r,s){if("string"==typeof t&&void 0!==e){let r=t;(t={})[r]=e}return t.shapeArgs||(0,p.defined)(t.x)?this.singleSetterForParts("d",null,this.renderer[this.pathType+"Path"](t.shapeArgs||t)):super.attr(t,void 0,r,s)}animate(t,e,r){if((0,p.defined)(t.x)&&(0,p.defined)(t.y)){let s=this.renderer[this.pathType+"Path"](t),i=s.forcedSides;this.singleSetterForParts("d",null,s,"animate",e,r),this.attr({zIndex:s.zIndexes.group}),i!==this.forcedSides&&(this.forcedSides=i,this.renderer.styledMode||this.fillSetter(this.fill))}else super.animate(t,e,r);return this}fillSetter(t){return this.forcedSides=this.forcedSides||[],this.singleSetterForParts("fill",null,{front:t,top:S(t).brighten(this.forcedSides.indexOf("top")>=0?0:.1).get(),side:S(t).brighten(this.forcedSides.indexOf("side")>=0?0:-.1).get()}),this.color=this.fill=t,this}}C.types={base:C,cuboid:C};let M=C,{parse:v}=z(),P=class extends M{constructor(){super(...arguments),this.parts=["top","bottom","front","back"],this.pathType="cylinder"}fillSetter(t){return this.singleSetterForParts("fill",null,{front:t,back:t,top:v(t).brighten(.1).get(),bottom:v(t).brighten(-.1).get()}),this.color=this.fill=t,this}},{charts:k,deg2rad:H}=a(),{perspective:A}={perspective:y,perspective3D:f,pointCameraDistance:function(t,e){let r=e.options.chart.options3d,s={x:e.plotWidth/2,y:e.plotHeight/2,z:(0,p.pick)(r.depth,1)*(0,p.pick)(r.viewDistance,0)+r.depth};return Math.sqrt(Math.pow(s.x-(0,p.pick)(t.plotX,t.x),2)+Math.pow(s.y-(0,p.pick)(t.plotY,t.y),2)+Math.pow(s.z-(0,p.pick)(t.plotZ,t.z),2))},shapeArea:x,shapeArea3D:function(t,e,r){return x(y(t,e,r))}};function I(t){return!t.some(t=>"C"===t[0])}function _(t){return this.element3d("cylinder",t)}function T(t){let e=k[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 w(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 B(t,e){let r=[];if(I(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(I(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 O(t,e,r){let s,i,{width:n=0,height:o=0,alphaCorrection:h=0}=e,l=(0,p.pick)(e.depth,n,0),a=Math.min(n,l)/2,d=H*(t.options.chart.options3d.beta-90+h),c=(e.y||0)+(r?o:0),u=.5519*a,y=n/2+(e.x||0),f=l/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)s=t.x,i=t.z,t.x=s*g-i*z+y,t.z=i*g+s*z+f;let b=A(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 j(t,e){let r=t.slice(0,3);if(I(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}var E=h(512),F=h.n(E);let{column:{prototype:{pointClass:G}}}=F().seriesTypes;class L extends G{}(0,p.extend)(L.prototype,{shapeType:"cylinder"});let{column:R}=F().seriesTypes;class V extends R{}V.compose=function(t){let e=t.prototype;e.cylinder||(e.Element3D.types.cylinder=P,(0,p.extend)(e,{cylinder:_,cylinderPath:T,getCurvedPath:w,getCylinderBack:B,getCylinderEnd:O,getCylinderFront:j}))},V.defaultOptions=(0,p.merge)(R.defaultOptions,{}),(0,p.extend)(V.prototype,{pointClass:L}),F().registerSeriesType("cylinder",V),V.compose(c());let D=a();return l.default})());