9 lines
11 KiB
JavaScript
9 lines
11 KiB
JavaScript
!/**
|
|
* Highcharts Gantt JS v11.4.1 (2024-04-04)
|
|
*
|
|
* GridAxis
|
|
*
|
|
* (c) 2016-2024 Lars A. V. Cabrera
|
|
*
|
|
* License: www.highcharts.com/license
|
|
*/function(t){"object"==typeof module&&module.exports?(t.default=t,module.exports=t):"function"==typeof define&&define.amd?define("highcharts/modules/grid-axis",["highcharts"],function(i){return t(i),t.Highcharts=i,t}):t("undefined"!=typeof Highcharts?Highcharts:void 0)}(function(t){"use strict";var i=t?t._modules:{};function e(t,i,e,s){t.hasOwnProperty(i)||(t[i]=s.apply(null,e),"function"==typeof CustomEvent&&window.dispatchEvent(new CustomEvent("HighchartsModuleLoaded",{detail:{path:i,module:t[i]}})))}e(i,"Core/Axis/GridAxis.js",[i["Core/Axis/Axis.js"],i["Core/Globals.js"],i["Core/Utilities.js"]],function(t,i,e){var s,o;let{dateFormats:r}=i,{addEvent:n,defined:h,erase:l,find:a,isArray:d,isNumber:c,merge:g,pick:f,timeUnits:u,wrap:p}=e;function m(t){return e.isObject(t,!0)}function k(t,i){let e={width:0,height:0};if(i.forEach(function(i){let s=t[i],o=0,r=0,n;m(s)&&(o=(n=m(s.label)?s.label:{}).getBBox?n.getBBox().height:0,n.textStr&&!c(n.textPxLength)&&(n.textPxLength=n.getBBox().width),r=c(n.textPxLength)?Math.round(n.textPxLength):0,n.textStr&&(r=Math.round(n.getBBox().width)),e.height=Math.max(o,e.height),e.width=Math.max(r,e.width))}),"treegrid"===this.options.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 x(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 b(t){if(!0===(this.options.grid||{}).enabled){let{axisTitle:i,height:e,horiz:o,left:r,offset:n,opposite:h,options:l,top:a,width:d}=this,c=this.tickSize(),g=i&&i.getBBox().width,u=l.title.x,p=l.title.y,m=f(l.title.margin,o?5:10),k=i?this.chart.renderer.fontMetrics(i).f:0,x=(o?a+e:r)+(o?1:-1)*(h?-1:1)*(c?c[0]/2:0)+(this.side===s.bottom?k:0);t.titlePosition.x=o?r-(g||0)/2-m+u:x+(h?d:0)+n+u,t.titlePosition.y=o?x-(h?e:0)+(h?k:-k)/2+n+p:a-m+p}}function P(){let{chart:i,options:{grid:e={}},userOptions:s}=this;if(e.enabled&&function(t){let i=t.options;i.labels.align=f(i.labels.align,"center"),t.categories||(i.showLastLabel=!1),t.labelRotation=0,i.labels.rotation=0,i.minTickInterval=1}(this),e.columns){let o=this.grid.columns=[],r=this.grid.columnIndex=0;for(;++r<e.columns.length;){let n=g(s,e.columns[r],{isInternal:!0,linkedTo:0,scrollbar:{enabled:!1}},{grid:{columns:void 0}}),h=new t(this.chart,n,"yAxis");h.grid.isColumn=!0,h.grid.columnIndex=r,l(i.axes,h),l(i[this.coll]||[],h),o.push(h)}}}function y(){let{axisTitle:t,grid:i,options:e}=this;if(!0===(e.grid||{}).enabled){let o=this.min||0,r=this.max||0,n=this.ticks[this.tickPositions[0]];if(t&&!this.chart.styledMode&&n?.slotWidth&&!this.options.title.style.width&&t.css({width:`${n.slotWidth}px`}),this.maxLabelDimensions=this.getMaxLabelDimensions(this.ticks,this.tickPositions),this.rightWall&&this.rightWall.destroy(),this.grid&&this.grid.isOuterAxis()&&this.axisLine){let t=e.lineWidth;if(t){let i=this.getLinePath(t),n=i[0],h=i[1],l=((this.tickSize("tick")||[1])[0]-1)*(this.side===s.top||this.side===s.left?-1:1);if("M"===n[0]&&"L"===h[0]&&(this.horiz?(n[2]+=l,h[2]+=l):(n[1]+=l,h[1]+=l)),!this.horiz&&this.chart.marginRight){let t=["L",this.left,n[2]||0],i=[n,t],s=["L",this.chart.chartWidth-this.chart.marginRight,this.toPixels(r+this.tickmarkOffset)],l=[["M",h[1]||0,this.toPixels(r+this.tickmarkOffset)],s];this.grid.upperBorder||o%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||r%1==0||(this.grid.lowerBorder=this.grid.renderBorder(l)),this.grid.lowerBorder&&(this.grid.lowerBorder.attr({stroke:e.lineColor,"stroke-width":e.lineWidth}),this.grid.lowerBorder.animate({d:l}))}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&&i.columns||[]).forEach(t=>t.render()),!this.horiz&&this.chart.hasRendered&&(this.scrollbar||this.linkedParent&&this.linkedParent.scrollbar)&&this.tickPositions.length){let t,i;let e=this.tickmarkOffset,s=this.tickPositions[this.tickPositions.length-1],n=this.tickPositions[0];for(;(t=this.hiddenLabels.pop())&&t.element;)t.show();for(;(i=this.hiddenMarks.pop())&&i.element;)i.show();(t=this.ticks[n].label)&&(o-n>e?this.hiddenLabels.push(t.hide()):t.show()),(t=this.ticks[s].label)&&(s-r>e?this.hiddenLabels.push(t.hide()):t.show());let h=this.ticks[s].mark;h&&s-r<e&&s-r>0&&this.ticks[s].isLast&&this.hiddenMarks.push(h.hide())}}}function w(){let t=this.tickPositions&&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&&!h(s.align)&&(!1===i.dateTimeLabelFormats[t.unitName].range||t.count>1)&&(i.labels.align="left",h(s.x)||(i.labels.x=3))):"treegrid"!==this.options.type&&this.grid&&this.grid.columns&&(this.minPointOffset=this.tickInterval))}function L(t){let i;let e=this.options,s=t.userOptions,o=e&&m(e.grid)?e.grid:{};!0===o.enabled&&(i=g(!0,{className:"highcharts-grid-axis "+(s.className||""),dateTimeLabelFormats:{hour:{list:["%H:%M","%H"]},day:{list:["%A, %e. %B","%a, %e. %b","%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||(h(s.linkedTo)&&!h(s.tickPixelInterval)&&(i.tickPixelInterval=350),!(!h(s.tickPixelInterval)&&h(s.linkedTo))||h(s.tickPositioner)||h(s.tickInterval)||h(s.units)||(i.tickPositioner=function(t,e){let s=this.linkedParent&&this.linkedParent.tickPositions&&this.linkedParent.tickPositions.info;if(s){let o=i.units||[],r,n=1,h="year";for(let t=0;t<o.length;t++){let i=o[t];if(i&&i[0]===s.unitName){r=t;break}}let l=c(r)&&o[r+1];if(l){h=l[0]||"year";let t=l[1];n=t&&t[0]||1}else"year"===s.unitName&&(n=10*s.count);let a=u[h];return this.tickInterval=a*n,this.chart.time.getTimeTicks({unitRange:a,count:n,unitName:h},t,e,this.options.startOfWeek)}})),g(!0,this.options,i),this.horiz&&(e.minPadding=f(s.minPadding,0),e.maxPadding=f(s.maxPadding,0)),c(e.grid.borderWidth)&&(e.tickWidth=e.lineWidth=o.borderWidth))}function B(t){let i=t.userOptions,e=i&&i.grid||{},s=e.columns;e.enabled&&s&&g(!0,this.options,s[0])}function v(){(this.grid.columns||[]).forEach(t=>t.setScale())}function M(t){let{horiz:i,maxLabelDimensions:e,options:{grid:s={}}}=this;if(s.enabled&&e){let o=2*this.options.labels.distance,r=i?s.cellHeight||o+e.height:o+e.width;d(t.tickSize)?t.tickSize[0]=r:t.tickSize=[r,0]}}function O(){this.axes.forEach(t=>{(t.grid&&t.grid.columns||[]).forEach(t=>{t.setAxisSize(),t.setAxisTranslation()})})}function W(t){let{grid:i}=this;(i.columns||[]).forEach(i=>i.destroy(t.keepEvents)),i.columns=void 0}function C(t){let i=t.userOptions||{},e=i.grid||{};e.enabled&&h(e.borderColor)&&(i.tickColor=i.lineColor=e.borderColor),this.grid||(this.grid=new z(this)),this.hiddenLabels=[],this.hiddenMarks=[]}function S(t){let i=this.label,e=this.axis,o=e.reversed,r=e.chart,n=e.options.grid||{},h=e.options.labels,l=h.align,a=s[e.side],d=t.tickmarkOffset,g=e.tickPositions,f=this.pos-d,u=c(g[t.index+1])?g[t.index+1]-d:(e.max||0)+d,p=e.tickSize("tick"),m=p?p[0]:0,k=p?p[1]/2:0;if(!0===n.enabled){let s,n,d,c;if("top"===a?n=(s=e.top+e.offset)-m:"bottom"===a?s=(n=r.chartHeight-e.bottom+e.offset)+m:(s=e.top+e.len-(e.translate(o?u:f)||0),n=e.top+e.len-(e.translate(o?f:u)||0)),"right"===a?c=(d=r.chartWidth-e.right+e.offset)+m:"left"===a?d=(c=e.left+e.offset)-m:(d=Math.round(e.left+(e.translate(o?u:f)||0))-k,c=Math.min(Math.round(e.left+(e.translate(o?f:u)||0))-k,e.left+e.len)),this.slotWidth=c-d,t.pos.x="left"===l?d:"right"===l?c:d+(c-d)/2,t.pos.y=n+(s-n)/2,i){let e=r.renderer.fontMetrics(i),s=i.getBBox().height;if(h.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&&h.x||0}}function A(t){let{axis:e,value:s}=t;if(e.options.grid&&e.options.grid.enabled){let o;let r=e.tickPositions,n=(e.linkedParent||e).series[0],h=s===r[0],l=s===r[r.length-1],d=n&&a(n.options.data,function(t){return t[e.isXAxis?"x":"y"]===s});d&&n.is("gantt")&&(o=g(d),i.seriesTypes.gantt.prototype.pointClass.setGanttPointAliases(o)),t.isFirst=h,t.isLast=l,t.point=o}}function T(){let t=this.options,i=t.grid||{},e=this.categories,s=this.tickPositions,o=s[0],r=s[1],n=s[s.length-1],h=s[s.length-2],l=this.linkedParent&&this.linkedParent.min,a=this.linkedParent&&this.linkedParent.max,d=l||this.min,g=a||this.max,f=this.tickInterval,u=c(d)&&d>=o+f&&d<r,p=c(d)&&o<d&&o+f>d,m=c(g)&&n>g&&n-f<g,k=c(g)&&g<=n-f&&g>h;!0===i.enabled&&!e&&(this.isXAxis||this.isLinked)&&((p||u)&&!t.startOnTick&&(s[0]=d),(m||k)&&!t.endOnTick&&(s[s.length-1]=g))}function E(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)))}(o=s||(s={}))[o.top=0]="top",o[o.right=1]="right",o[o.bottom=2]="bottom",o[o.left=3]="left";class z{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||[],o=e?t.linkedParent:t,r=-1,n=0;return 3===t.side&&!i.inverted&&s.length?!t.linkedParent:((i[t.coll]||[]).forEach((i,e)=>{i.side!==t.side||i.options.isInternal||(n=e,i!==o||(r=e))}),n===r&&(!c(e)||s.length===e))}renderBorder(t){let i=this.axis,e=i.chart.renderer,s=i.options,o=e.path(t).addClass("highcharts-axis-line").add(i.axisGroup);return e.styledMode||o.attr({stroke:s.lineColor,"stroke-width":s.lineWidth,zIndex:7}),o}}return r.E=function(t){return this.dateFormat("%a",t,!0).charAt(0)},r.W=function(t){let i=this,e=new this.Date(t);["Hours","Milliseconds","Minutes","Seconds"].forEach(function(t){i.set(t,e,0)});let s=(this.get("Day",e)+6)%7,o=new this.Date(e.valueOf());this.set("Date",o,this.get("Date",e)-s+3);let r=new this.Date(this.get("FullYear",o),0,1);return 4!==this.get("Day",r)&&(this.set("Month",e,0),this.set("Date",e,1+(11-this.get("Day",r))%7)),(1+Math.floor((o.valueOf()-r.valueOf())/6048e5)).toString()},{compose:function(t,i,e){return t.keepProps.includes("grid")||(t.keepProps.push("grid"),t.prototype.getMaxLabelDimensions=k,p(t.prototype,"unsquish",E),p(t.prototype,"getOffset",x),n(t,"init",C),n(t,"afterGetTitlePosition",b),n(t,"afterInit",P),n(t,"afterRender",y),n(t,"afterSetAxisTranslation",w),n(t,"afterSetOptions",L),n(t,"afterSetOptions",B),n(t,"afterSetScale",v),n(t,"afterTickSize",M),n(t,"trimTicks",T),n(t,"destroy",W),n(i,"afterSetChartSize",O),n(e,"afterGetLabelPosition",S),n(e,"labelFormat",A)),t}}}),e(i,"masters/modules/grid-axis.src.js",[i["Core/Globals.js"],i["Core/Axis/GridAxis.js"]],function(t,i){return i.compose(t.Axis,t.Chart,t.Tick),t})}); |