highcharts
Version:
JavaScript charting framework
13 lines • 7.52 kB
JavaScript
/**
* Highcharts JS v13.0.1 (2026-08-17)
* @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";let e={};e.n=t=>{let i=t&&t.__esModule?()=>t.default:()=>t;return e.d(i,{a:i}),i},e.d=(t,i)=>{if(Array.isArray(i))for(var s=0;s<i.length;){var n=i[s++],a=i[s++];e.o(t,n)?0===a&&s++:0===a?Object.defineProperty(t,n,{enumerable:!0,value:i[s++]}):Object.defineProperty(t,n,{enumerable:!0,get:a})}else 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 s=e.n(i);let n=t.default.SeriesRegistry;var a=e.n(n);let r=t.default.Point;var o=e.n(r);let{line:{prototype:{pointClass:l}},pie:{prototype:{pointClass:h}}}=a().seriesTypes,d=class extends l{alignConnector(){let t=this.series,e=this.dataLabel,s=e.connector,n=e.options||{},a=n.connectorWidth||0,r=this.series.chart,o=s.getBBox(),l={x:o.x+(e.translateX||0),y:o.y+(e.translateY||0)};r.inverted?l.y-=a/2:l.x+=a/2,s[r.isInsidePlot(l.x,l.y)?"animate":"attr"]({d:this.getConnectorPath()}),s.addClass("highcharts-color-"+this.colorIndex),t.chart.styledMode||s.attr({stroke:n.connectorColor||this.color,"stroke-width":n.connectorWidth,opacity:e[(0,i.defined)(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:s,dataLabel:n}=this,a=s.chart,r=s.xAxis.len,o=a.inverted,l=o?"x2":"y2";if(n){let h=n.targetPosition,d=(n.alignAttr||n)[l[0]]<s.yAxis.len/2,p={x1:t,y1:e,x2:t,y2:(0,i.isNumber)(h.y)?h.y:n.y};return o&&(p={x1:e,y1:r-t,x2:h.x||n.x,y2:r-t}),d&&(p[l]+=n[o?"width":"height"]||0),(0,i.objectEach)(p,(t,e)=>{p[e]-=(n.alignAttr||n)[e[0]]}),a.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}setState(){let t=super.setState;(!this.isNull||this.series.options.nullInteraction)&&t.apply(this,arguments)}setVisible(t,e){let s=this.series;e=(0,i.pick)(e,s.options.ignoreHiddenPoint),h.prototype.setVisible.call(this,t,!1),s.processData(),e&&s.chart.redraw()}applyOptions(t,e,s){let n=this.series;e||t?.x||((0,i.isNumber)(this.x)?e=this.x:(0,i.isNumber)(n?.xIncrement)&&(e=n.xIncrement||0,n.autoIncrement())),t=o().prototype.optionsToObject.call(this,t);let a=super.applyOptions(t,e,s);return s||(this.userDLOptions=(0,i.merge)(this.userDLOptions,t.dataLabels)),a}},{column:p,line:c}=a().seriesTypes;class u extends c{alignDataLabel(t,e,s,n){let a,r,o,l=this.chart.inverted,h=this.visibilityMap.filter(t=>!!t),d=this.visiblePointsCount||0,p=h.indexOf(t),c=this.options.dataLabels,u=t.userDLOptions||{},y=c.alternate?p&&p!==d-1?2:1.5:1,b=Math.floor(this.xAxis.len/d),g=e.padding;t.visible&&(a=Math.abs(u.x||t.options.dataLabels.x),l?(r=(a-g)*2-(t.itemHeight||0)/2,o={width:(0,i.pick)(c.style?.width,`${.4*this.yAxis.len}px`),textOverflow:(e.width||0)/r*(e.height||0)/2>b*y?"ellipsis":"none"}):o={width:(u.width||c.width||b*y-2*g)+"px"},e.css(o),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,s=1;if(t){let n=(0,i.pick)(t.distance,e?20:100);for(let a of this.points){let r={[e?"x":"y"]:t.alternate&&s%2?-n:n};e&&(r.align=t.alternate&&s%2?"right":"left"),a.options.dataLabels=(0,i.merge)(r,a.userDLOptions,{zIndex:void 0}),delete a.options.dataLabels.zIndex,s++}}}generatePoints(){super.generatePoints();let t=this.points,e=t.length,i=this.getColumn("x");for(let s=0;s<e;++s)t[s].x=i[s]}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,s=t.filter((t,i)=>e.points[i].isValid()&&e.points[i].visible);return{min:(0,i.arrayMin)(s),max:(0,i.arrayMax)(s)}}init(){let t=this;super.init.apply(t,arguments),t.eventsToUnbind.push((0,i.addEvent)(t,"afterTranslate",function(){let e,s=Number.MAX_VALUE;for(let n of t.points)n.isInside=n.isInside&&n.visible,n.visible&&(!n.isNull||t.options.nullInteraction)&&((0,i.defined)(e)&&(s=Math.min(s,Math.abs(n.plotX-e))),e=n.plotX);t.closestPointRangePx=s})),t.eventsToUnbind.push((0,i.addEvent)(t,"drawDataLabels",function(){t.distributeDL()})),t.eventsToUnbind.push((0,i.addEvent)(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((0,i.addEvent)(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,s=t.marker||{},n=s.symbol||i?.symbol,a=s.width??i?.width??(this.closestPointRangePx||0),r=s.height??(i?.height||0),o,l,h=0;if(this.xAxis.dateTime)return super.markerAttribs(t,e);e&&(o=i?.states?.[e],l=s.states?.[e],h=l?.radius??o?.radius??h+(o?.radiusPlus||0)),t.hasImage=!!(n&&0===n.indexOf("url"));let d={x:Math.floor(t.plotX)-a/2-h/2,y:t.plotY-r/2-h/2,width:a+h,height:r+h};return this.chart.inverted?{y:d.x&&d.width&&this.xAxis.len-d.x-d.width,x:d.y,width:d.height,height:d.width}:d}}u.defaultOptions=(0,i.merge)(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:"var(--highcharts-background-color)",borderWidth:1,borderColor:"var(--highcharts-neutral-color-40)",borderRadius:3,color:"var(--highcharts-neutral-color-80)",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||"")},padding:5,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"}),(0,i.addEvent)(u,"afterProcessData",function(){let t=this.getColumn("y"),e=0;for(let t of(this.visibilityMap=this.getVisibilityMap(),this.visibilityMap))t&&e++;this.visiblePointsCount=e,t.length=this.dataTable.rowCount;for(let e=0;e<t.length;++e)t[e]=null===t[e]?null:1;this.dataTable.setColumn("y",t)}),(0,i.extend)(u.prototype,{drawTracker:p.prototype.drawTracker,pointClass:d,trackerGroups:["markerGroup","dataLabelsGroup"]}),a().registerSeriesType("timeline",u);let y=s();export{y as default};