UNPKG

highcharts

Version:
13 lines 13.4 kB
!/** * Highcharts Gantt JS v12.6.0 (2026-04-13) * @module highcharts/modules/grid-axis * @requires highcharts * * GridAxis * * (c) 2016-2026 Highsoft AS * Author: Lars A. V. Cabrera * * A commercial license may be required depending on use. * See www.highcharts.com/license */function(t,i){"object"==typeof exports&&"object"==typeof module?module.exports=i(t._Highcharts,t._Highcharts.Axis):"function"==typeof define&&define.amd?define("highcharts/modules/grid-axis",["highcharts/highcharts"],function(t){return i(t,t.Axis)}):"object"==typeof exports?exports["highcharts/modules/grid-axis"]=i(t._Highcharts,t._Highcharts.Axis):t.Highcharts=i(t.Highcharts,t.Highcharts.Axis)}("u"<typeof window?this:window,(t,i)=>(()=>{"use strict";var e,s,r={532:t=>{t.exports=i},944:i=>{i.exports=t}},n={};function o(t){var i=n[t];if(void 0!==i)return i.exports;var e=n[t]={exports:{}};return r[t](e,e.exports,o),e.exports}o.n=t=>{var i=t&&t.__esModule?()=>t.default:()=>t;return o.d(i,{a:i}),i},o.d=(t,i)=>{for(var e in i)o.o(i,e)&&!o.o(t,e)&&Object.defineProperty(t,e,{enumerable:!0,get:i[e]})},o.o=(t,i)=>Object.prototype.hasOwnProperty.call(t,i);var l={};o.d(l,{default:()=>U});var h=o(944),a=o.n(h),d=o(532),c=o.n(d);let{doc:f,win:u}=a();function p(t,i,e,s={}){let r="function"==typeof t&&t.prototype||t;Object.hasOwnProperty.call(r,"hcEvents")||(r.hcEvents={});let n=r.hcEvents;a().Point&&t instanceof a().Point&&t.series&&t.series.chart&&(t.series.chart.runTrackerClick=!0);let o=t.addEventListener;o&&o.call(t,i,e,!!a().supportsPassiveEvents&&{passive:void 0===s.passive?-1!==i.indexOf("touch"):s.passive,capture:!1}),n[i]||(n[i]=[]);let l={fn:e,order:"number"==typeof s.order?s.order:1/0};return n[i].push(l),n[i].sort((t,i)=>t.order-i.order),function(){!function(t,i,e){function s(i,e){let s=t.removeEventListener;s&&s.call(t,i,e,!1)}function r(e){let r,n;t.nodeName&&(i?(r={})[i]=!0:r=e,w(r,function(t,i){if(e[i])for(n=e[i].length;n--;)s(i,e[i][n].fn)}))}let n="function"==typeof t&&t.prototype||t;if(Object.hasOwnProperty.call(n,"hcEvents")){let t=n.hcEvents;if(i){let n=t[i]||[];e?(t[i]=n.filter(function(t){return e!==t.fn}),s(i,e)):(r(t),t[i]=[])}else r(t),delete n.hcEvents}}(t,i,e)}}function g(t){return null!=t}function m(t,i){let e=t.length;for(;e--;)if(t[e]===i){t.splice(e,1);break}}let x=Array.prototype.find?function(t,i){return t.find(i)}:function(t,i){let e,s=t.length;for(e=0;e<s;e++)if(i(t[e],e))return t[e]};function k(t){return P(t)&&"number"==typeof t.nodeType}function b(t){return"number"==typeof t&&!isNaN(t)&&t<1/0&&t>-1/0}function y(t){let i=Object.prototype.toString.call(t);return"[object Array]"===i||"[object Array Iterator]"===i}function P(t,i){return!!t&&"object"==typeof t&&(!i||!y(t))}function v(t,...i){let e,s=[t,...i],r={},n=function(t,i){return"object"!=typeof t&&(t={}),w(i,function(e,s){if("__proto__"!==s&&"constructor"!==s){let r;!P(e,!0)||(r=e?.constructor,P(e,!0)&&!k(e)&&r?.name&&"Object"!==r.name)||k(e)?t[s]=i[s]:t[s]=n(t[s]||{},e)}}),t};!0===t&&(r=s[1],s=Array.prototype.slice.call(s,2));let o=s.length;for(e=0;e<o;e++)r=n(r,s[e]);return r}function w(t,i,e){for(let s in t)Object.hasOwnProperty.call(t,s)&&i.call(e||t[s],t[s],s,t)}function L(){let t=arguments,i=t.length;for(let e=0;e<i;e++){let i=t[e];if(null!=i)return i}}function O(t,i,e){let s=t[i];t[i]=function(){let t=arguments,i=this;return e.apply(this,[function(){return s.apply(i,arguments.length?arguments:t)}].concat([].slice.call(arguments)))}}let{dateFormats:B}=a();(e=s||(s={}))[e.top=0]="top",e[e.right=1]="right",e[e.bottom=2]="bottom",e[e.left=3]="left";function T(t,i){let e={width:0,height:0};if(i.forEach(function(i){let s=t[i],r=0,n=0,o;P(s,!0)&&(r=(o=P(s.label,!0)?s.label:{}).getBBox?o.getBBox().height:0,o.textStr&&!b(o.textPxLength)&&(o.textPxLength=o.getBBox().width),n=b(o.textPxLength)?Math.round(o.textPxLength):0,o.textStr&&(n=Math.round(o.getBBox().width)),e.height=Math.max(r,e.height),e.width=Math.max(n,e.width))}),"treegrid"===this.type&&this.treeGrid&&this.treeGrid.mapOfPosToGridNode){let t=this.treeGrid.mapOfPosToGridNode[-1].height||0;e.width+=this.options.labels.indentation*(t-1)}return e}function E(t){let{grid:i}=this,e=3===this.side;if(e||t.apply(this),!i?.isColumn){let t=i?.columns||[];e&&(t=t.slice().reverse()),t.forEach(t=>{t.getOffset()})}e&&t.apply(this)}function M(t){if(!0===(this.options.grid||{}).enabled){let{axisTitle:i,height:e,horiz:r,left:n,offset:o,opposite:l,options:h,top:a,width:d}=this,c=this.tickSize(),f=i?.getBBox().width,u=h.title.x,p=h.title.y,g=L(h.title.margin,r?5:10),m=i?this.chart.renderer.fontMetrics(i).f:0,x=(r?a+e:n)+(r?1:-1)*(l?-1:1)*(c?c[0]/2:0)+(this.side===s.bottom?m:0);t.titlePosition.x=r?n-(f||0)/2-g+u:x+(l?d:0)+o+u,t.titlePosition.y=r?x-(l?e:0)+(l?m:-m)/2+o+p:a-g+p}}function W(){let t,{chart:i,options:{grid:e={}},userOptions:s}=this;if(e.enabled&&((t=this.options).labels.align=L(t.labels.align,"center"),this.categories||(t.showLastLabel=!1),this.labelRotation=0,t.labels.rotation=0,t.minTickInterval=1),e.columns){let t=this.grid.columns=[],r=this.grid.columnIndex=0;for(;++r<e.columns.length;){let n=v(s,e.columns[r],{isInternal:!0,linkedTo:0,scrollbar:{enabled:!1}},{grid:{columns:void 0}}),o=new(c())(this.chart,n,this.coll);o.grid.isColumn=!0,o.grid.columnIndex=r,m(i.axes,o),m(i[this.coll]||[],o),t.push(o)}}}function A(){let{axisTitle:t,grid:i,options:e}=this;if(!0===(e.grid||{}).enabled){let r=this.min||0,n=this.max||0,o=this.ticks[this.tickPositions[0]];if(t&&!this.chart.styledMode&&o?.slotWidth&&!this.options.title.style.width&&t.css({width:`${o.slotWidth}px`}),this.maxLabelDimensions=this.getMaxLabelDimensions(this.ticks,this.tickPositions),this.rightWall&&this.rightWall.destroy(),this.grid?.isOuterAxis()&&this.axisLine){let t=e.lineWidth;if(t){let i=this.getLinePath(t),o=i[0],l=i[1],h=(this.tickSize("tick")||[1])[0]*(this.side===s.top||this.side===s.left?-1:1);if("M"===o[0]&&"L"===l[0]&&(this.horiz?(o[2]+=h,l[2]+=h):(o[1]+=h,l[1]+=h)),!this.horiz&&this.chart.marginRight){let t=["L",this.left,o[2]||0],i=[o,t],s=["L",this.chart.chartWidth-this.chart.marginRight,this.toPixels(n+this.tickmarkOffset)],h=[["M",l[1]||0,this.toPixels(n+this.tickmarkOffset)],s];this.grid.upperBorder||r%1==0||(this.grid.upperBorder=this.grid.renderBorder(i)),this.grid.upperBorder&&(this.grid.upperBorder.attr({stroke:e.lineColor,"stroke-width":e.lineWidth}),this.grid.upperBorder.animate({d:i})),this.grid.lowerBorder||n%1==0||(this.grid.lowerBorder=this.grid.renderBorder(h)),this.grid.lowerBorder&&(this.grid.lowerBorder.attr({stroke:e.lineColor,"stroke-width":e.lineWidth}),this.grid.lowerBorder.animate({d:h}))}this.grid.axisLineExtra?(this.grid.axisLineExtra.attr({stroke:e.lineColor,"stroke-width":e.lineWidth}),this.grid.axisLineExtra.animate({d:i})):this.grid.axisLineExtra=this.grid.renderBorder(i),this.axisLine[this.showAxis?"show":"hide"]()}}if((i?.columns||[]).forEach(t=>t.render()),!this.horiz&&this.chart.hasRendered&&(this.scrollbar||this.linkedParent?.scrollbar)&&this.tickPositions.length){let t,i,e=this.tickmarkOffset,s=this.tickPositions[this.tickPositions.length-1],o=this.tickPositions[0];for(;(t=this.hiddenLabels.pop())&&t.element;)t.show();for(;(i=this.hiddenMarks.pop())&&i.element;)i.show();(t=this.ticks[o].label)&&(r-o>e?this.hiddenLabels.push(t.hide()):t.show()),(t=this.ticks[s].label)&&(s-n>e?this.hiddenLabels.push(t.hide()):t.show());let l=this.ticks[s].mark;l&&s-n<e&&s-n>0&&this.ticks[s].isLast&&this.hiddenMarks.push(l.hide())}}}function S(){let t=this.tickPositions?.info,i=this.options,e=i.grid||{},s=this.userOptions.labels||{};e.enabled&&(this.horiz?(this.series.forEach(t=>{t.options.pointRange=0}),t&&i.dateTimeLabelFormats&&i.labels&&!g(s.align)&&(!1===i.dateTimeLabelFormats[t.unitName].range||t.count>1)&&(i.labels.align="left",g(s.x)||(i.labels.x=3))):"treegrid"!==this.type&&this.grid&&this.grid.columns&&(this.minPointOffset=this.tickInterval))}function z(t){let i,e=this.options,s=t.userOptions,r=e&&P(e.grid,!0)?e.grid:{};!0===r.enabled&&(i=v(!0,{className:"highcharts-grid-axis "+(s.className||""),dateTimeLabelFormats:{hour:{list:["%[HM]","%[H]"]},day:{list:["%[AeB]","%[aeb]","%[E]"]},week:{list:["Week %W","W%W"]},month:{list:["%[B]","%[b]","%o"]}},grid:{borderWidth:1},labels:{padding:2,style:{fontSize:"0.9em"}},margin:0,title:{text:null,reserveSpace:!1,rotation:0,style:{textOverflow:"ellipsis"}},units:[["millisecond",[1,10,100]],["second",[1,10]],["minute",[1,5,15]],["hour",[1,6]],["day",[1]],["week",[1]],["month",[1]],["year",null]]},s),"xAxis"===this.coll&&(g(s.linkedTo)&&!g(s.tickPixelInterval)&&(i.tickPixelInterval=350),!(!g(s.tickPixelInterval)&&g(s.linkedTo))||g(s.tickPositioner)||g(s.tickInterval)||g(s.units)||(i.tickPositioner=function(t,e){let s=this.linkedParent?.tickPositions?.info;if(s){let r=i.units||[],n,o=1,l="year";for(let t=0;t<r.length;t++){let i=r[t];if(i&&i[0]===s.unitName){n=t;break}}let a=b(n)&&r[n+1];if(a){l=a[0]||"year";let t=a[1];o=t?.[0]||1}else"year"===s.unitName&&(o=10*s.count);let d=h.timeUnits[l];return this.tickInterval=d*o,this.chart.time.getTimeTicks({unitRange:d,count:o,unitName:l},t,e,this.options.startOfWeek)}})),v(!0,this.options,i),this.horiz&&(e.minPadding=L(s.minPadding,0),e.maxPadding=L(s.maxPadding,0)),b(e.grid.borderWidth)&&(e.tickWidth=e.lineWidth=r.borderWidth))}function I(t){let i=t.userOptions,e=i?.grid||{},s=e.columns;e.enabled&&s&&v(!0,this.options,s[0])}function C(){(this.grid.columns||[]).forEach(t=>t.setScale())}function j(t){let{horiz:i,maxLabelDimensions:e,options:{grid:s={}}}=this;if(s.enabled&&e){let r=2*this.options.labels.distance,n=i?s.cellHeight||r+e.height:r+e.width;y(t.tickSize)?t.tickSize[0]=n:t.tickSize=[n,0]}}function H(){this.axes.forEach(t=>{(t.grid?.columns||[]).forEach(t=>{t.setAxisSize(),t.setAxisTranslation()})})}function N(t){let{grid:i}=this;(i.columns||[]).forEach(i=>i.destroy(t.keepEvents)),i.columns=void 0}function _(t){let i=t.userOptions||{},e=i.grid||{};e.enabled&&g(e.borderColor)&&(i.tickColor=i.lineColor=e.borderColor),this.grid||(this.grid=new X(this)),this.hiddenLabels=[],this.hiddenMarks=[]}function G(t){let i=this.label,e=this.axis,r=e.reversed,n=e.chart,o=e.options.grid||{},l=e.options.labels,h=l.align,a=s[e.side],d=t.tickmarkOffset,c=e.tickPositions,f=this.pos-d,u=b(c[t.index+1])?c[t.index+1]-d:(e.max||0)+d,p=e.tickSize("tick"),g=p?p[0]:0,m=p?p[1]/2:0;if(!0===o.enabled){let s,o,d,c;if("top"===a?o=(s=e.top+e.offset)-g:"bottom"===a?s=(o=n.chartHeight-e.bottom+e.offset)+g:(s=e.top+e.len-(e.translate(r?u:f)||0),o=e.top+e.len-(e.translate(r?f:u)||0)),"right"===a?c=(d=n.chartWidth-e.right+e.offset)+g:"left"===a?d=(c=e.left+e.offset)-g:(d=Math.round(e.left+(e.translate(r?u:f)||0))-m,c=Math.min(Math.round(e.left+(e.translate(r?f:u)||0))-m,e.left+e.len)),this.slotWidth=c-d,t.pos.x="left"===h?d:"right"===h?c:d+(c-d)/2,t.pos.y=o+(s-o)/2,i){let e=n.renderer.fontMetrics(i),s=i.getBBox().height;if(l.useHTML)t.pos.y+=e.b+-(s/2);else{let i=Math.round(s/e.h);t.pos.y+=(e.b-(e.h-e.f))/2+-((i-1)*e.h/2)}}t.pos.x+=e.horiz&&l.x||0}}function F(t){let{axis:i,value:e}=t;if(i.options.grid?.enabled){let s,r=i.tickPositions,n=(i.linkedParent||i).series[0],o=e===r[0],l=e===r[r.length-1],h=n&&x(n.options.data,function(t){return t[i.isXAxis?"x":"y"]===e});h&&n.is("gantt")&&(s=v(h),a().seriesTypes.gantt.prototype.pointClass.setGanttPointAliases(s,i.chart)),t.isFirst=o,t.isLast=l,t.point=s}}function R(){let t=this.options,i=t.grid||{},e=this.categories,s=this.tickPositions,r=s[0],n=s[1],o=s[s.length-1],l=s[s.length-2],h=this.linkedParent?.min,a=this.linkedParent?.max,d=h||this.min,c=a||this.max,f=this.tickInterval,u=b(d)&&d>=r+f&&d<n,p=b(d)&&r<d&&r+f>d,g=b(c)&&o>c&&o-f<c,m=b(c)&&c<=o-f&&c>l;!0===i.enabled&&!e&&(this.isXAxis||this.isLinked)&&((p||u)&&!t.startOnTick&&(s[0]=d),(g||m)&&!t.endOnTick&&(s[s.length-1]=c))}function D(t){var i;let{options:{grid:e={}}}=this;return!0===e.enabled&&this.categories?this.tickInterval:t.apply(this,(i=arguments,Array.prototype.slice.call(i,1)))}class X{constructor(t){this.axis=t}isOuterAxis(){let t=this.axis,i=t.chart,e=t.grid.columnIndex,s=t.linkedParent?.grid.columns||t.grid.columns||[],r=e?t.linkedParent:t,n=-1,o=0;return 3===t.side&&!i.inverted&&s.length?!t.linkedParent:((i[t.coll]||[]).forEach((i,e)=>{i.side!==t.side||i.options.isInternal||(o=e,i===r&&(n=e))}),o===n&&(!b(e)||s.length===e))}renderBorder(t){let i=this.axis,e=i.chart.renderer,s=i.options,r=e.path(t).addClass("highcharts-axis-line").add(i.axisGroup);return e.styledMode||r.attr({stroke:s.lineColor,"stroke-width":s.lineWidth,zIndex:7}),r}}B.E=function(t){return this.dateFormat("%a",t,!0).charAt(0)},B.W=function(t){let i=this.toParts(t),e=(i[7]+6)%7,s=i.slice(0);s[2]=i[2]-e+3;let r=this.toParts(this.makeTime(s[0],0,1));return 4!==r[7]&&(i[1]=0,i[2]=1+(11-r[7])%7),(1+Math.floor((this.makeTime(s[0],s[1],s[2])-this.makeTime(r[0],r[1],r[2]))/6048e5)).toString()};let q=a();({compose:function(t,i,e){return t.keepProps.includes("grid")||(t.keepProps.push("grid"),t.prototype.getMaxLabelDimensions=T,O(t.prototype,"unsquish",D),O(t.prototype,"getOffset",E),p(t,"init",_),p(t,"afterGetTitlePosition",M),p(t,"afterInit",W),p(t,"afterRender",A),p(t,"afterSetAxisTranslation",S),p(t,"afterSetOptions",z),p(t,"afterSetOptions",I),p(t,"afterSetScale",C),p(t,"afterTickSize",j),p(t,"trimTicks",R),p(t,"destroy",N),p(i,"afterSetChartSize",H),p(e,"afterGetLabelPosition",G),p(e,"labelFormat",F)),t}}).compose(q.Axis,q.Chart,q.Tick);let U=a();return l.default})());