highcharts
Version:
JavaScript charting framework
13 lines • 9.05 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
*/import*as t from"../highcharts.js";var e={};e.n=t=>{var i=t&&t.__esModule?()=>t.default:()=>t;return e.d(i,{a:i}),i},e.d=(t,i)=>{for(var n in i)e.o(i,n)&&!e.o(t,n)&&Object.defineProperty(t,n,{enumerable:!0,get:i[n]})},e.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e);let i=t.default;var n=e.n(i);let s=t.default.SeriesRegistry;var o=e.n(s);let r=t.default.Point;var a=e.n(r);let{doc:l,win:h}=n();function p(t,e,i,s={}){let o="function"==typeof t&&t.prototype||t;Object.hasOwnProperty.call(o,"hcEvents")||(o.hcEvents={});let r=o.hcEvents;n().Point&&t instanceof n().Point&&t.series&&t.series.chart&&(t.series.chart.runTrackerClick=!0);let a=t.addEventListener;a&&a.call(t,e,i,!!n().supportsPassiveEvents&&{passive:void 0===s.passive?-1!==e.indexOf("touch"):s.passive,capture:!1}),r[e]||(r[e]=[]);let l={fn:i,order:"number"==typeof s.order?s.order:1/0};return r[e].push(l),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,o;t.nodeName&&(e?(s={})[e]=!0:s=i,y(s,function(t,e){if(i[e])for(o=i[e].length;o--;)n(e,i[e][o].fn)}))}let o="function"==typeof t&&t.prototype||t;if(Object.hasOwnProperty.call(o,"hcEvents")){let t=o.hcEvents;if(e){let o=t[e]||[];i?(t[e]=o.filter(function(t){return i!==t.fn}),n(e,i)):(s(t),t[e]=[])}else s(t),delete o.hcEvents}}(t,e,i)}}function c(t){return u(t)&&"number"==typeof t.nodeType}function d(t){return"number"==typeof t&&!isNaN(t)&&t<1/0&&t>-1/0}function u(t,e){let i;return!!t&&"object"==typeof t&&(!e||"[object Array]"!==(i=Object.prototype.toString.call(t))&&"[object Array Iterator]"!==i)}function f(t,...e){let i,n=[t,...e],s={},o=function(t,e){return"object"!=typeof t&&(t={}),y(e,function(i,n){if("__proto__"!==n&&"constructor"!==n){let s;!u(i,!0)||(s=i?.constructor,u(i,!0)&&!c(i)&&s?.name&&"Object"!==s.name)||c(i)?t[n]=e[n]:t[n]=o(t[n]||{},i)}}),t};!0===t&&(s=n[1],n=Array.prototype.slice.call(n,2));let r=n.length;for(i=0;i<r;i++)s=o(s,n[i]);return s}function y(t,e,i){for(let n in t)Object.hasOwnProperty.call(t,n)&&e.call(i||t[n],t[n],n,t)}function b(){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:g}},pie:{prototype:{pointClass:x}}}=o().seriesTypes,m=class extends g{alignConnector(){let t=this.series,e=this.dataLabel,i=e.connector,n=e.options||{},s=n.connectorWidth||0,o=this.series.chart,r=i.getBBox(),a={x:r.x+(e.translateX||0),y:r.y+(e.translateY||0)};o.inverted?a.y-=s/2:a.x+=s/2,i[o.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,o=i.xAxis.len,r=s.inverted,a=r?"x2":"y2";if(n){let l=n.targetPosition,h=(n.alignAttr||n)[a[0]]<i.yAxis.len/2,p={x1:t,y1:e,x2:t,y2:d(l.y)?l.y:n.y};return r&&(p={x1:e,y1:o-t,x2:l.x||n.x,y2:o-t}),h&&(p[a]+=n[r?"width":"height"]||0),y(p,(t,e)=>{p[e]-=(n.alignAttr||n)[e[0]]}),s.renderer.crispLine([["M",p.x1,p.y1],["L",p.x2,p.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=b(e,i.options.ignoreHiddenPoint),x.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||(d(this.x)?e=this.x:d(n?.xIncrement)&&(e=n.xIncrement||0,n.autoIncrement())),t=a().prototype.optionsToObject.call(this,t??(n.options.nullInteraction&&{y:0}||null));let s=super.applyOptions(t,e);return this.userDLOptions=f(this.userDLOptions,t.dataLabels),s.isNull=i,s}},{column:v,line:w}=o().seriesTypes;class O extends w{alignDataLabel(t,e,i,n){let s,o,r,a=this.chart.inverted,l=this.visibilityMap.filter(t=>!!t),h=this.visiblePointsCount||0,p=l.indexOf(t),c=this.options.dataLabels,d=t.userDLOptions||{},u=c.alternate?p&&p!==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?(o=(s-y)*2-(t.itemHeight||0)/2,r={width:b(c.style?.width,`${.4*this.yAxis.len}px`),textOverflow:(e.width||0)/o*(e.height||0)/2>f*u?"ellipsis":"none"}):r={width:(d.width||c.width||f*u-2*y)+"px"},e.css(r),this.chart.styledMode||e.shadow(c.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=b(t.distance,e?20:100);for(let s of this.points){let o={[e?"x":"y"]:t.alternate&&i%2?-n:n};e&&(o.align=t.alternate&&i%2?"right":"left"),s.options.dataLabels=f(o,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(p(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(p(t,"drawDataLabels",function(){t.distributeDL()})),t.eventsToUnbind.push(p(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(p(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,o=b(n.width,i?.width,this.closestPointRangePx),r=b(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=b(l?.radius,a?.radius,h+(a?.radiusPlus||0))),t.hasImage=!!(s&&0===s.indexOf("url"));let p={x:Math.floor(t.plotX)-o/2-h/2,y:t.plotY-r/2-h/2,width:o+h,height:r+h};return this.chart.inverted?{y:p.x&&p.width&&this.xAxis.len-p.x-p.width,x:p.y&&p.y,width:p.height,height:p.width}:p}}O.defaultOptions=f(w.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"}),p(O,"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]}(O.prototype,{drawTracker:v.prototype.drawTracker,pointClass:m,trackerGroups:["markerGroup","dataLabelsGroup"]}),o().registerSeriesType("timeline",O);let P=n();export{P as default};