highcharts
Version:
JavaScript charting framework
13 lines • 9.75 kB
JavaScript
!/**
* Highcharts JS v12.6.0 (2026-04-13)
* @module highcharts/modules/timeline
* @requires highcharts
*
* Timeline series
*
* (c) 2010-2026 Highsoft AS
* Author: Daniel Studencki
*
* 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.SeriesRegistry,t._Highcharts.Point):"function"==typeof define&&define.amd?define("highcharts/modules/timeline",["highcharts/highcharts"],function(t){return e(t,t.SeriesRegistry,t.Point)}):"object"==typeof exports?exports["highcharts/modules/timeline"]=e(t._Highcharts,t._Highcharts.SeriesRegistry,t._Highcharts.Point):t.Highcharts=e(t.Highcharts,t.Highcharts.SeriesRegistry,t.Highcharts.Point)}("u"<typeof window?this:window,(t,e,i)=>(()=>{"use strict";var n={260:t=>{t.exports=i},512:t=>{t.exports=e},944:e=>{e.exports=t}},s={};function r(t){var e=s[t];if(void 0!==e)return e.exports;var i=s[t]={exports:{}};return n[t](i,i.exports,r),i.exports}r.n=t=>{var e=t&&t.__esModule?()=>t.default:()=>t;return r.d(e,{a:e}),e},r.d=(t,e)=>{for(var i in e)r.o(e,i)&&!r.o(t,i)&&Object.defineProperty(t,i,{enumerable:!0,get:e[i]})},r.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e);var o={};r.d(o,{default:()=>k});var a=r(944),l=r.n(a),h=r(512),c=r.n(h),p=r(260),d=r.n(p);let{doc:u,win:f}=l();function y(t,e,i,n={}){let s="function"==typeof t&&t.prototype||t;Object.hasOwnProperty.call(s,"hcEvents")||(s.hcEvents={});let r=s.hcEvents;l().Point&&t instanceof l().Point&&t.series&&t.series.chart&&(t.series.chart.runTrackerClick=!0);let o=t.addEventListener;o&&o.call(t,e,i,!!l().supportsPassiveEvents&&{passive:void 0===n.passive?-1!==e.indexOf("touch"):n.passive,capture:!1}),r[e]||(r[e]=[]);let a={fn:i,order:"number"==typeof n.order?n.order:1/0};return r[e].push(a),r[e].sort((t,e)=>t.order-e.order),function(){!function(t,e,i){function n(e,i){let n=t.removeEventListener;n&&n.call(t,e,i,!1)}function s(i){let s,r;t.nodeName&&(e?(s={})[e]=!0:s=i,v(s,function(t,e){if(i[e])for(r=i[e].length;r--;)n(e,i[e][r].fn)}))}let r="function"==typeof t&&t.prototype||t;if(Object.hasOwnProperty.call(r,"hcEvents")){let t=r.hcEvents;if(e){let r=t[e]||[];i?(t[e]=r.filter(function(t){return i!==t.fn}),n(e,i)):(s(t),t[e]=[])}else s(t),delete r.hcEvents}}(t,e,i)}}function g(t){return x(t)&&"number"==typeof t.nodeType}function b(t){return"number"==typeof t&&!isNaN(t)&&t<1/0&&t>-1/0}function x(t,e){let i;return!!t&&"object"==typeof t&&(!e||"[object Array]"!==(i=Object.prototype.toString.call(t))&&"[object Array Iterator]"!==i)}function m(t,...e){let i,n=[t,...e],s={},r=function(t,e){return"object"!=typeof t&&(t={}),v(e,function(i,n){if("__proto__"!==n&&"constructor"!==n){let s;!x(i,!0)||(s=i?.constructor,x(i,!0)&&!g(i)&&s?.name&&"Object"!==s.name)||g(i)?t[n]=e[n]:t[n]=r(t[n]||{},i)}}),t};!0===t&&(s=n[1],n=Array.prototype.slice.call(n,2));let o=n.length;for(i=0;i<o;i++)s=r(s,n[i]);return s}function v(t,e,i){for(let n in t)Object.hasOwnProperty.call(t,n)&&e.call(i||t[n],t[n],n,t)}function w(){let t=arguments,e=t.length;for(let i=0;i<e;i++){let e=t[i];if(null!=e)return e}}Array.prototype.find;let{line:{prototype:{pointClass:P}},pie:{prototype:{pointClass:O}}}=c().seriesTypes,L=class extends P{alignConnector(){let t=this.series,e=this.dataLabel,i=e.connector,n=e.options||{},s=n.connectorWidth||0,r=this.series.chart,o=i.getBBox(),a={x:o.x+(e.translateX||0),y:o.y+(e.translateY||0)};r.inverted?a.y-=s/2:a.x+=s/2,i[r.isInsidePlot(a.x,a.y)?"animate":"attr"]({d:this.getConnectorPath()}),i.addClass("highcharts-color-"+this.colorIndex),t.chart.styledMode||i.attr({stroke:n.connectorColor||this.color,"stroke-width":n.connectorWidth,opacity:e[null!=e.newOpacity?"newOpacity":"opacity"]})}drawConnector(){let{dataLabel:t,series:e}=this;t&&(t.connector||(t.connector=e.chart.renderer.path(this.getConnectorPath()).attr({zIndex:-1}).add(t)),this.series.chart.isInsidePlot(t.x||0,t.y||0)&&this.alignConnector())}getConnectorPath(){let{plotX:t=0,plotY:e=0,series:i,dataLabel:n}=this,s=i.chart,r=i.xAxis.len,o=s.inverted,a=o?"x2":"y2";if(n){let l=n.targetPosition,h=(n.alignAttr||n)[a[0]]<i.yAxis.len/2,c={x1:t,y1:e,x2:t,y2:b(l.y)?l.y:n.y};return o&&(c={x1:e,y1:r-t,x2:l.x||n.x,y2:r-t}),h&&(c[a]+=n[o?"width":"height"]||0),v(c,(t,e)=>{c[e]-=(n.alignAttr||n)[e[0]]}),s.renderer.crispLine([["M",c.x1,c.y1],["L",c.x2,c.y2]],n.options?.connectorWidth||0)}return[]}constructor(t,e){super(t,e),this.name??(this.name=(e&&null!==e.y||!t.options.nullInteraction)&&"Event"||"Null"),this.y=1}isValid(){return null!==this.options.y||this.series.options.nullInteraction||!0}setState(){let t=super.setState;(!this.isNull||this.series.options.nullInteraction)&&t.apply(this,arguments)}setVisible(t,e){let i=this.series;e=w(e,i.options.ignoreHiddenPoint),O.prototype.setVisible.call(this,t,!1),i.processData(),e&&i.chart.redraw()}applyOptions(t,e){let i=this.isNull||null===t||null===t.y,n=this.series;e||t?.x||(b(this.x)?e=this.x:b(n?.xIncrement)&&(e=n.xIncrement||0,n.autoIncrement())),t=d().prototype.optionsToObject.call(this,t??(n.options.nullInteraction&&{y:0}||null));let s=super.applyOptions(t,e);return this.userDLOptions=m(this.userDLOptions,t.dataLabels),s.isNull=i,s}},{column:A,line:C}=c().seriesTypes;class I extends C{alignDataLabel(t,e,i,n){let s,r,o,a=this.chart.inverted,l=this.visibilityMap.filter(t=>!!t),h=this.visiblePointsCount||0,c=l.indexOf(t),p=this.options.dataLabels,d=t.userDLOptions||{},u=p.alternate?c&&c!==h-1?2:1.5:1,f=Math.floor(this.xAxis.len/h),y=e.padding;t.visible&&(s=Math.abs(d.x||t.options.dataLabels.x),a?(r=(s-y)*2-(t.itemHeight||0)/2,o={width:w(p.style?.width,`${.4*this.yAxis.len}px`),textOverflow:(e.width||0)/r*(e.height||0)/2>f*u?"ellipsis":"none"}):o={width:(d.width||p.width||f*u-2*y)+"px"},e.css(o),this.chart.styledMode||e.shadow(p.shadow)),super.alignDataLabel.apply(this,arguments)}bindAxes(){super.bindAxes(),this.xAxis.userOptions.type||(this.xAxis.categories=this.xAxis.hasNames=!0)}distributeDL(){let t=this.options.dataLabels,e=this.chart.inverted,i=1;if(t){let n=w(t.distance,e?20:100);for(let s of this.points){let r={[e?"x":"y"]:t.alternate&&i%2?-n:n};e&&(r.align=t.alternate&&i%2?"right":"left"),s.options.dataLabels=m(r,s.userDLOptions,{zIndex:void 0}),i++}}}generatePoints(){super.generatePoints();let t=this.points,e=t.length,i=this.getColumn("x");for(let n=0;n<e;++n){let e=i[n];t[n].applyOptions({x:e},e)}}getVisibilityMap(){let t=this.options.nullInteraction;return((this.data.length?this.data:this.options.data)||[]).map(e=>!!e&&!1!==e.visible&&(!e.isNull||!!t)&&e)}getXExtremes(t){let e=this,i=t.filter((t,i)=>e.points[i].isValid()&&e.points[i].visible);return{min:function(t){let e=t.length,i=t[0];for(;e--;)t[e]<i&&(i=t[e]);return i}(i),max:function(t){let e=t.length,i=t[0];for(;e--;)t[e]>i&&(i=t[e]);return i}(i)}}init(){let t=this;super.init.apply(t,arguments),t.eventsToUnbind.push(y(t,"afterTranslate",function(){let e,i=Number.MAX_VALUE;for(let n of t.points)(n.isInside=n.isInside&&n.visible,n.visible&&(!n.isNull||t.options.nullInteraction))&&(null!=e&&(i=Math.min(i,Math.abs(n.plotX-e))),e=n.plotX);t.closestPointRangePx=i})),t.eventsToUnbind.push(y(t,"drawDataLabels",function(){t.distributeDL()})),t.eventsToUnbind.push(y(t,"afterDrawDataLabels",function(){let e;for(let i of t.points)(e=i.dataLabel)&&(e.animate=function(t){return this.targetPosition&&(this.targetPosition=t),this.renderer.Element.prototype.animate.apply(this,arguments)},e.targetPosition||(e.targetPosition={}),i.drawConnector())})),t.eventsToUnbind.push(y(t.chart,"afterHideOverlappingLabel",function(){for(let e of t.points)e.dataLabel&&e.dataLabel.connector&&e.dataLabel.oldOpacity!==e.dataLabel.newOpacity&&e.alignConnector()}))}markerAttribs(t,e){let i=this.options.marker,n=t.marker||{},s=n.symbol||i?.symbol,r=w(n.width,i?.width,this.closestPointRangePx),o=w(n.height,i?.height),a,l,h=0;if(this.xAxis.dateTime)return super.markerAttribs(t,e);e&&(a=i?.states?.[e],l=n.states?.[e],h=w(l?.radius,a?.radius,h+(a?.radiusPlus||0))),t.hasImage=!!(s&&0===s.indexOf("url"));let c={x:Math.floor(t.plotX)-r/2-h/2,y:t.plotY-o/2-h/2,width:r+h,height:o+h};return this.chart.inverted?{y:c.x&&c.width&&this.xAxis.len-c.x-c.width,x:c.y&&c.y,width:c.height,height:c.width}:c}}I.defaultOptions=m(C.defaultOptions,{colorByPoint:!0,stickyTracking:!1,ignoreHiddenPoint:!0,legendType:"point",lineWidth:4,tooltip:{headerFormat:'<span style="color:{point.color}">●</span> <span style="font-size: 0.8em"> {point.key}</span><br/>',pointFormat:"{point.description}"},states:{hover:{lineWidthPlus:0}},dataLabels:{enabled:!0,allowOverlap:!0,alternate:!0,backgroundColor:"#ffffff",borderWidth:1,borderColor:"#999999",borderRadius:3,color:"#333333",connectorWidth:1,distance:void 0,formatter:function(){return(this.series.chart.styledMode?'<span class="highcharts-color-'+this.point.colorIndex+'">● </span>':'<span style="color:'+this.point.color+'">● </span>')+('<span class="highcharts-strong">'+(this.key||"")+"</span><br/>")+(this.label||"")},style:{textOutline:"none",fontWeight:"normal",fontSize:"0.8em",textAlign:"left"},shadow:!1,verticalAlign:"middle"},marker:{enabledThreshold:0,symbol:"square",radius:6,lineWidth:2,height:15},showInLegend:!1,colorKey:"x",legendSymbol:"rectangle"}),y(I,"afterProcessData",function(){let t=this.getColumn("x"),e=0;for(let t of(this.visibilityMap=this.getVisibilityMap(),this.visibilityMap))t&&e++;this.visiblePointsCount=e,this.dataTable.setColumn("y",Array(t.length).fill(1))}),function(t,e){let i;for(i in t||(t={}),e)t[i]=e[i]}(I.prototype,{drawTracker:A.prototype.drawTracker,pointClass:L,trackerGroups:["markerGroup","dataLabelsGroup"]}),c().registerSeriesType("timeline",I);let k=l();return o.default})());