timeline.src.js 35 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818
  1. /**
  2. * @license Highcharts JS v9.1.1 (2021-06-04)
  3. *
  4. * Timeline series
  5. *
  6. * (c) 2010-2021 Highsoft AS
  7. * Author: Daniel Studencki
  8. *
  9. * License: www.highcharts.com/license
  10. */
  11. 'use strict';
  12. (function (factory) {
  13. if (typeof module === 'object' && module.exports) {
  14. factory['default'] = factory;
  15. module.exports = factory;
  16. } else if (typeof define === 'function' && define.amd) {
  17. define('highcharts/modules/timeline', ['highcharts'], function (Highcharts) {
  18. factory(Highcharts);
  19. factory.Highcharts = Highcharts;
  20. return factory;
  21. });
  22. } else {
  23. factory(typeof Highcharts !== 'undefined' ? Highcharts : undefined);
  24. }
  25. }(function (Highcharts) {
  26. var _modules = Highcharts ? Highcharts._modules : {};
  27. function _registerModule(obj, path, args, fn) {
  28. if (!obj.hasOwnProperty(path)) {
  29. obj[path] = fn.apply(null, args);
  30. }
  31. }
  32. _registerModule(_modules, 'Series/Timeline/TimelinePoint.js', [_modules['Core/Series/SeriesRegistry.js'], _modules['Core/Utilities.js']], function (SeriesRegistry, U) {
  33. /* *
  34. *
  35. * Timeline Series.
  36. *
  37. * (c) 2010-2021 Highsoft AS
  38. *
  39. * Author: Daniel Studencki
  40. *
  41. * License: www.highcharts.com/license
  42. *
  43. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  44. *
  45. * */
  46. var __extends = (this && this.__extends) || (function () {
  47. var extendStatics = function (d,
  48. b) {
  49. extendStatics = Object.setPrototypeOf ||
  50. ({ __proto__: [] } instanceof Array && function (d,
  51. b) { d.__proto__ = b; }) ||
  52. function (d,
  53. b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  54. return extendStatics(d, b);
  55. };
  56. return function (d, b) {
  57. extendStatics(d, b);
  58. function __() { this.constructor = d; }
  59. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  60. };
  61. })();
  62. var Series = SeriesRegistry.series,
  63. PiePoint = SeriesRegistry.seriesTypes.pie.prototype.pointClass;
  64. var defined = U.defined,
  65. isNumber = U.isNumber,
  66. merge = U.merge,
  67. objectEach = U.objectEach,
  68. pick = U.pick;
  69. /* *
  70. *
  71. * Class
  72. *
  73. * */
  74. var TimelinePoint = /** @class */ (function (_super) {
  75. __extends(TimelinePoint, _super);
  76. function TimelinePoint() {
  77. /* *
  78. *
  79. * Properties
  80. *
  81. * */
  82. var _this = _super !== null && _super.apply(this,
  83. arguments) || this;
  84. _this.options = void 0;
  85. _this.series = void 0;
  86. return _this;
  87. /* eslint-enable valid-jsdoc */
  88. }
  89. /* *
  90. *
  91. * Functions
  92. *
  93. * */
  94. /* eslint-disable valid-jsdoc */
  95. TimelinePoint.prototype.alignConnector = function () {
  96. var point = this,
  97. series = point.series,
  98. connector = point.connector,
  99. dl = point.dataLabel,
  100. dlOptions = point.dataLabel.options = merge(series.options.dataLabels,
  101. point.options.dataLabels),
  102. chart = point.series.chart,
  103. bBox = connector.getBBox(),
  104. plotPos = {
  105. x: bBox.x + dl.translateX,
  106. y: bBox.y + dl.translateY
  107. },
  108. isVisible;
  109. // Include a half of connector width in order to run animation,
  110. // when connectors are aligned to the plot area edge.
  111. if (chart.inverted) {
  112. plotPos.y -= dl.options.connectorWidth / 2;
  113. }
  114. else {
  115. plotPos.x += dl.options.connectorWidth / 2;
  116. }
  117. isVisible = chart.isInsidePlot(plotPos.x, plotPos.y);
  118. connector[isVisible ? 'animate' : 'attr']({
  119. d: point.getConnectorPath()
  120. });
  121. if (!series.chart.styledMode) {
  122. connector.attr({
  123. stroke: dlOptions.connectorColor || point.color,
  124. 'stroke-width': dlOptions.connectorWidth,
  125. opacity: dl[defined(dl.newOpacity) ? 'newOpacity' : 'opacity']
  126. });
  127. }
  128. };
  129. TimelinePoint.prototype.drawConnector = function () {
  130. var point = this,
  131. series = point.series;
  132. if (!point.connector) {
  133. point.connector = series.chart.renderer
  134. .path(point.getConnectorPath())
  135. .attr({
  136. zIndex: -1
  137. })
  138. .add(point.dataLabel);
  139. }
  140. if (point.series.chart.isInsidePlot(// #10507
  141. point.dataLabel.x, point.dataLabel.y)) {
  142. point.alignConnector();
  143. }
  144. };
  145. TimelinePoint.prototype.getConnectorPath = function () {
  146. var point = this,
  147. chart = point.series.chart,
  148. xAxisLen = point.series.xAxis.len,
  149. inverted = chart.inverted,
  150. direction = inverted ? 'x2' : 'y2',
  151. dl = point.dataLabel,
  152. targetDLPos = dl.targetPosition,
  153. coords = {
  154. x1: point.plotX,
  155. y1: point.plotY,
  156. x2: point.plotX,
  157. y2: isNumber(targetDLPos.y) ? targetDLPos.y : dl.y
  158. },
  159. negativeDistance = ((dl.alignAttr || dl)[direction[0]] <
  160. point.series.yAxis.len / 2),
  161. path;
  162. // Recalculate coords when the chart is inverted.
  163. if (inverted) {
  164. coords = {
  165. x1: point.plotY,
  166. y1: xAxisLen - point.plotX,
  167. x2: targetDLPos.x || dl.x,
  168. y2: xAxisLen - point.plotX
  169. };
  170. }
  171. // Subtract data label width or height from expected coordinate so
  172. // that the connector would start from the appropriate edge.
  173. if (negativeDistance) {
  174. coords[direction] += dl[inverted ? 'width' : 'height'];
  175. }
  176. // Change coordinates so that they will be relative to data label.
  177. objectEach(coords, function (_coord, i) {
  178. coords[i] -= (dl.alignAttr || dl)[i[0]];
  179. });
  180. path = chart.renderer.crispLine([
  181. ['M', coords.x1, coords.y1],
  182. ['L', coords.x2, coords.y2]
  183. ], dl.options.connectorWidth);
  184. return path;
  185. };
  186. TimelinePoint.prototype.init = function () {
  187. var point = _super.prototype.init.apply(this,
  188. arguments);
  189. point.name = pick(point.name, 'Event');
  190. point.y = 1;
  191. return point;
  192. };
  193. TimelinePoint.prototype.isValid = function () {
  194. return this.options.y !== null;
  195. };
  196. TimelinePoint.prototype.setState = function () {
  197. var proceed = _super.prototype.setState;
  198. // Prevent triggering the setState method on null points.
  199. if (!this.isNull) {
  200. proceed.apply(this, arguments);
  201. }
  202. };
  203. TimelinePoint.prototype.setVisible = function (visible, redraw) {
  204. var point = this,
  205. series = point.series;
  206. redraw = pick(redraw, series.options.ignoreHiddenPoint);
  207. PiePoint.prototype.setVisible.call(point, visible, false);
  208. // Process new data
  209. series.processData();
  210. if (redraw) {
  211. series.chart.redraw();
  212. }
  213. };
  214. return TimelinePoint;
  215. }(Series.prototype.pointClass));
  216. /* *
  217. *
  218. * Default Export
  219. *
  220. * */
  221. return TimelinePoint;
  222. });
  223. _registerModule(_modules, 'Series/Timeline/TimelineSeries.js', [_modules['Mixins/LegendSymbol.js'], _modules['Core/Color/Palette.js'], _modules['Core/Series/SeriesRegistry.js'], _modules['Core/Renderer/SVG/SVGElement.js'], _modules['Series/Timeline/TimelinePoint.js'], _modules['Core/Utilities.js']], function (LegendSymbolMixin, palette, SeriesRegistry, SVGElement, TimelinePoint, U) {
  224. /* *
  225. *
  226. * Timeline Series.
  227. *
  228. * (c) 2010-2021 Highsoft AS
  229. *
  230. * Author: Daniel Studencki
  231. *
  232. * License: www.highcharts.com/license
  233. *
  234. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  235. *
  236. * */
  237. var __extends = (this && this.__extends) || (function () {
  238. var extendStatics = function (d,
  239. b) {
  240. extendStatics = Object.setPrototypeOf ||
  241. ({ __proto__: [] } instanceof Array && function (d,
  242. b) { d.__proto__ = b; }) ||
  243. function (d,
  244. b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  245. return extendStatics(d, b);
  246. };
  247. return function (d, b) {
  248. extendStatics(d, b);
  249. function __() { this.constructor = d; }
  250. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  251. };
  252. })();
  253. var _a = SeriesRegistry.seriesTypes,
  254. ColumnSeries = _a.column,
  255. LineSeries = _a.line;
  256. var addEvent = U.addEvent,
  257. arrayMax = U.arrayMax,
  258. arrayMin = U.arrayMin,
  259. defined = U.defined,
  260. extend = U.extend,
  261. merge = U.merge,
  262. pick = U.pick;
  263. /* *
  264. *
  265. * Class
  266. *
  267. * */
  268. /**
  269. * The timeline series type.
  270. *
  271. * @private
  272. * @class
  273. * @name Highcharts.seriesTypes.timeline
  274. *
  275. * @augments Highcharts.Series
  276. */
  277. var TimelineSeries = /** @class */ (function (_super) {
  278. __extends(TimelineSeries, _super);
  279. function TimelineSeries() {
  280. /* *
  281. *
  282. * Static Properties
  283. *
  284. * */
  285. var _this = _super !== null && _super.apply(this,
  286. arguments) || this;
  287. /* *
  288. *
  289. * Properties
  290. *
  291. * */
  292. _this.data = void 0;
  293. _this.options = void 0;
  294. _this.points = void 0;
  295. _this.userOptions = void 0;
  296. _this.visibilityMap = void 0;
  297. return _this;
  298. /* eslint-enable valid-jsdoc */
  299. }
  300. /* *
  301. *
  302. * Functions
  303. *
  304. * */
  305. /* eslint-disable valid-jsdoc */
  306. TimelineSeries.prototype.alignDataLabel = function (point, dataLabel, _options, _alignTo) {
  307. var series = this,
  308. isInverted = series.chart.inverted,
  309. visiblePoints = series.visibilityMap.filter(function (point) {
  310. return point;
  311. }), visiblePointsCount = series.visiblePointsCount, pointIndex = visiblePoints.indexOf(point), isFirstOrLast = (!pointIndex || pointIndex === visiblePointsCount - 1), dataLabelsOptions = series.options.dataLabels, userDLOptions = point.userDLOptions || {},
  312. // Define multiplier which is used to calculate data label
  313. // width. If data labels are alternate, they have two times more
  314. // space to adapt (excepting first and last ones, which has only
  315. // one and half), than in case of placing all data labels side
  316. // by side.
  317. multiplier = dataLabelsOptions.alternate ?
  318. (isFirstOrLast ? 1.5 : 2) :
  319. 1, distance, availableSpace = Math.floor(series.xAxis.len / visiblePointsCount), pad = dataLabel.padding, targetDLWidth, styles;
  320. // Adjust data label width to the currently available space.
  321. if (point.visible) {
  322. distance = Math.abs(userDLOptions.x || point.options.dataLabels.x);
  323. if (isInverted) {
  324. targetDLWidth = ((distance - pad) * 2 - (point.itemHeight / 2));
  325. styles = {
  326. width: targetDLWidth + 'px',
  327. // Apply ellipsis when data label height is exceeded.
  328. textOverflow: dataLabel.width / targetDLWidth *
  329. dataLabel.height / 2 > availableSpace * multiplier ?
  330. 'ellipsis' : 'none'
  331. };
  332. }
  333. else {
  334. styles = {
  335. width: (userDLOptions.width ||
  336. dataLabelsOptions.width ||
  337. availableSpace * multiplier - (pad * 2)) + 'px'
  338. };
  339. }
  340. dataLabel.css(styles);
  341. if (!series.chart.styledMode) {
  342. dataLabel.shadow(dataLabelsOptions.shadow);
  343. }
  344. }
  345. _super.prototype.alignDataLabel.apply(series, arguments);
  346. };
  347. TimelineSeries.prototype.bindAxes = function () {
  348. var series = this;
  349. _super.prototype.bindAxes.call(series);
  350. ['xAxis', 'yAxis'].forEach(function (axis) {
  351. // Initially set the linked xAxis type to category.
  352. if (axis === 'xAxis' && !series[axis].userOptions.type) {
  353. series[axis].categories = series[axis].hasNames = true;
  354. }
  355. });
  356. };
  357. TimelineSeries.prototype.distributeDL = function () {
  358. var series = this,
  359. dataLabelsOptions = series.options.dataLabels,
  360. options,
  361. pointDLOptions,
  362. newOptions = {},
  363. visibilityIndex = 1,
  364. distance = dataLabelsOptions.distance;
  365. series.points.forEach(function (point) {
  366. if (point.visible && !point.isNull) {
  367. options = point.options;
  368. pointDLOptions = point.options.dataLabels;
  369. if (!series.hasRendered) {
  370. point.userDLOptions =
  371. merge({}, pointDLOptions);
  372. }
  373. newOptions[series.chart.inverted ? 'x' : 'y'] =
  374. dataLabelsOptions.alternate && visibilityIndex % 2 ?
  375. -distance : distance;
  376. options.dataLabels = merge(newOptions, point.userDLOptions);
  377. visibilityIndex++;
  378. }
  379. });
  380. };
  381. TimelineSeries.prototype.generatePoints = function () {
  382. var series = this;
  383. _super.prototype.generatePoints.apply(series);
  384. series.points.forEach(function (point, i) {
  385. point.applyOptions({
  386. x: series.xData[i]
  387. }, series.xData[i]);
  388. });
  389. };
  390. TimelineSeries.prototype.getVisibilityMap = function () {
  391. var series = this,
  392. map = (series.data.length ?
  393. series.data : series.userOptions.data).map(function (point) {
  394. return (point &&
  395. point.visible !== false &&
  396. !point.isNull) ? point : false;
  397. });
  398. return map;
  399. };
  400. TimelineSeries.prototype.getXExtremes = function (xData) {
  401. var series = this,
  402. filteredData = xData.filter(function (x,
  403. i) {
  404. return series.points[i].isValid() &&
  405. series.points[i].visible;
  406. });
  407. return {
  408. min: arrayMin(filteredData),
  409. max: arrayMax(filteredData)
  410. };
  411. };
  412. TimelineSeries.prototype.init = function () {
  413. var series = this;
  414. _super.prototype.init.apply(series, arguments);
  415. series.eventsToUnbind.push(addEvent(series, 'afterTranslate', function () {
  416. var lastPlotX,
  417. closestPointRangePx = Number.MAX_VALUE;
  418. series.points.forEach(function (point) {
  419. // Set the isInside parameter basing also on the real point
  420. // visibility, in order to avoid showing hidden points
  421. // in drawPoints method.
  422. point.isInside = point.isInside && point.visible;
  423. // New way of calculating closestPointRangePx value, which
  424. // respects the real point visibility is needed.
  425. if (point.visible && !point.isNull) {
  426. if (defined(lastPlotX)) {
  427. closestPointRangePx = Math.min(closestPointRangePx, Math.abs(point.plotX - lastPlotX));
  428. }
  429. lastPlotX = point.plotX;
  430. }
  431. });
  432. series.closestPointRangePx = closestPointRangePx;
  433. }));
  434. // Distribute data labels before rendering them. Distribution is
  435. // based on the 'dataLabels.distance' and 'dataLabels.alternate'
  436. // property.
  437. series.eventsToUnbind.push(addEvent(series, 'drawDataLabels', function () {
  438. // Distribute data labels basing on defined algorithm.
  439. series.distributeDL(); // @todo use this scope for series
  440. }));
  441. series.eventsToUnbind.push(addEvent(series, 'afterDrawDataLabels', function () {
  442. var dataLabel; // @todo use this scope for series
  443. // Draw or align connector for each point.
  444. series.points.forEach(function (point) {
  445. dataLabel = point.dataLabel;
  446. if (dataLabel) {
  447. // Within this wrap method is necessary to save the
  448. // current animation params, because the data label
  449. // target position (after animation) is needed to align
  450. // connectors.
  451. dataLabel.animate = function (params) {
  452. if (this.targetPosition) {
  453. this.targetPosition = params;
  454. }
  455. return SVGElement.prototype.animate.apply(this, arguments);
  456. };
  457. // Initialize the targetPosition field within data label
  458. // object. It's necessary because there is need to know
  459. // expected position of specific data label, when
  460. // aligning connectors. This field is overrided inside
  461. // of SVGElement.animate() wrapped method.
  462. if (!dataLabel.targetPosition) {
  463. dataLabel.targetPosition = {};
  464. }
  465. return point.drawConnector();
  466. }
  467. });
  468. }));
  469. series.eventsToUnbind.push(addEvent(series.chart, 'afterHideOverlappingLabel', function () {
  470. series.points.forEach(function (p) {
  471. if (p.connector &&
  472. p.dataLabel &&
  473. p.dataLabel.oldOpacity !== p.dataLabel.newOpacity) {
  474. p.alignConnector();
  475. }
  476. });
  477. }));
  478. };
  479. TimelineSeries.prototype.markerAttribs = function (point, state) {
  480. var series = this,
  481. seriesMarkerOptions = series.options.marker,
  482. seriesStateOptions,
  483. pointMarkerOptions = point.marker || {},
  484. symbol = (pointMarkerOptions.symbol || seriesMarkerOptions.symbol),
  485. pointStateOptions,
  486. width = pick(pointMarkerOptions.width,
  487. seriesMarkerOptions.width,
  488. series.closestPointRangePx),
  489. height = pick(pointMarkerOptions.height,
  490. seriesMarkerOptions.height),
  491. radius = 0,
  492. attribs;
  493. // Call default markerAttribs method, when the xAxis type
  494. // is set to datetime.
  495. if (series.xAxis.dateTime) {
  496. return _super.prototype.markerAttribs.call(this, point, state);
  497. }
  498. // Handle hover and select states
  499. if (state) {
  500. seriesStateOptions =
  501. seriesMarkerOptions.states[state] || {};
  502. pointStateOptions = pointMarkerOptions.states &&
  503. pointMarkerOptions.states[state] || {};
  504. radius = pick(pointStateOptions.radius, seriesStateOptions.radius, radius + (seriesStateOptions.radiusPlus || 0));
  505. }
  506. point.hasImage = (symbol && symbol.indexOf('url') === 0);
  507. attribs = {
  508. x: Math.floor(point.plotX) - (width / 2) - (radius / 2),
  509. y: point.plotY - (height / 2) - (radius / 2),
  510. width: width + radius,
  511. height: height + radius
  512. };
  513. return attribs;
  514. };
  515. TimelineSeries.prototype.processData = function () {
  516. var series = this,
  517. visiblePoints = 0,
  518. i;
  519. series.visibilityMap = series.getVisibilityMap();
  520. // Calculate currently visible points.
  521. series.visibilityMap.forEach(function (point) {
  522. if (point) {
  523. visiblePoints++;
  524. }
  525. });
  526. series.visiblePointsCount = visiblePoints;
  527. for (i = 0; i < series.xData.length; i++) {
  528. series.yData[i] = 1;
  529. }
  530. _super.prototype.processData.call(this, arguments);
  531. return;
  532. };
  533. /**
  534. * The timeline series presents given events along a drawn line.
  535. *
  536. * @sample highcharts/series-timeline/alternate-labels
  537. * Timeline series
  538. * @sample highcharts/series-timeline/inverted
  539. * Inverted timeline
  540. * @sample highcharts/series-timeline/datetime-axis
  541. * With true datetime axis
  542. *
  543. * @extends plotOptions.line
  544. * @since 7.0.0
  545. * @product highcharts
  546. * @excluding animationLimit, boostThreshold, connectEnds, connectNulls,
  547. * cropThreshold, dashStyle, findNearestPointBy,
  548. * getExtremesFromAll, lineWidth, negativeColor,
  549. * pointInterval, pointIntervalUnit, pointPlacement,
  550. * pointStart, softThreshold, stacking, step, threshold,
  551. * turboThreshold, zoneAxis, zones, dataSorting,
  552. * boostBlending
  553. * @requires modules/timeline
  554. * @optionparent plotOptions.timeline
  555. */
  556. TimelineSeries.defaultOptions = merge(LineSeries.defaultOptions, {
  557. colorByPoint: true,
  558. stickyTracking: false,
  559. ignoreHiddenPoint: true,
  560. /**
  561. * @ignore
  562. * @private
  563. */
  564. legendType: 'point',
  565. lineWidth: 4,
  566. tooltip: {
  567. headerFormat: '<span style="color:{point.color}">\u25CF</span> ' +
  568. '<span style="font-size: 10px"> {point.key}</span><br/>',
  569. pointFormat: '{point.description}'
  570. },
  571. states: {
  572. hover: {
  573. lineWidthPlus: 0
  574. }
  575. },
  576. /**
  577. * @declare Highcharts.TimelineDataLabelsOptionsObject
  578. *
  579. * @private
  580. */
  581. dataLabels: {
  582. enabled: true,
  583. allowOverlap: true,
  584. /**
  585. * Whether to position data labels alternately. For example, if
  586. * [distance](#plotOptions.timeline.dataLabels.distance)
  587. * is set equal to `100`, then data labels will be positioned
  588. * alternately (on both sides of the point) at a distance of 100px.
  589. *
  590. * @sample {highcharts} highcharts/series-timeline/alternate-disabled
  591. * Alternate disabled
  592. */
  593. alternate: true,
  594. backgroundColor: palette.backgroundColor,
  595. borderWidth: 1,
  596. borderColor: palette.neutralColor40,
  597. borderRadius: 3,
  598. color: palette.neutralColor80,
  599. /**
  600. * The color of the line connecting the data label to the point.
  601. * The default color is the same as the point's color.
  602. *
  603. * In styled mode, the connector stroke is given in the
  604. * `.highcharts-data-label-connector` class.
  605. *
  606. * @sample {highcharts} highcharts/series-timeline/connector-styles
  607. * Custom connector width and color
  608. *
  609. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  610. * @apioption plotOptions.timeline.dataLabels.connectorColor
  611. */
  612. /**
  613. * The width of the line connecting the data label to the point.
  614. *
  615. * In styled mode, the connector stroke width is given in the
  616. * `.highcharts-data-label-connector` class.
  617. *
  618. * @sample {highcharts} highcharts/series-timeline/connector-styles
  619. * Custom connector width and color
  620. */
  621. connectorWidth: 1,
  622. /**
  623. * A pixel value defining the distance between the data label and
  624. * the point. Negative numbers puts the label on top of the point.
  625. */
  626. distance: 100,
  627. // eslint-disable-next-line valid-jsdoc
  628. /**
  629. * @type {Highcharts.TimelineDataLabelsFormatterCallbackFunction}
  630. * @default function () {
  631. * let format;
  632. *
  633. * if (!this.series.chart.styledMode) {
  634. * format = '<span style="color:' + this.point.color +
  635. * '">● </span>';
  636. * } else {
  637. * format = '<span>● </span>';
  638. * }
  639. * format += '<span>' + (this.key || '') + '</span><br/>' +
  640. * (this.point.label || '');
  641. * return format;
  642. * }
  643. */
  644. formatter: function () {
  645. var format;
  646. if (!this.series.chart.styledMode) {
  647. format = '<span style="color:' + this.point.color +
  648. '">● </span>';
  649. }
  650. else {
  651. format = '<span>● </span>';
  652. }
  653. format += '<span class="highcharts-strong">' +
  654. (this.key || '') + '</span><br/>' +
  655. (this.point.label || '');
  656. return format;
  657. },
  658. style: {
  659. /** @internal */
  660. textOutline: 'none',
  661. /** @internal */
  662. fontWeight: 'normal',
  663. /** @internal */
  664. fontSize: '12px'
  665. },
  666. /**
  667. * Shadow options for the data label.
  668. *
  669. * @type {boolean|Highcharts.CSSObject}
  670. */
  671. shadow: false,
  672. /**
  673. * @type {number}
  674. * @apioption plotOptions.timeline.dataLabels.width
  675. */
  676. verticalAlign: 'middle'
  677. },
  678. marker: {
  679. enabledThreshold: 0,
  680. symbol: 'square',
  681. radius: 6,
  682. lineWidth: 2,
  683. height: 15
  684. },
  685. showInLegend: false,
  686. colorKey: 'x'
  687. });
  688. return TimelineSeries;
  689. }(LineSeries));
  690. extend(TimelineSeries.prototype, {
  691. // Use a simple symbol from LegendSymbolMixin
  692. drawLegendSymbol: LegendSymbolMixin.drawRectangle,
  693. // Use a group of trackers from TrackerMixin
  694. drawTracker: ColumnSeries.prototype.drawTracker,
  695. pointClass: TimelinePoint,
  696. trackerGroups: ['markerGroup', 'dataLabelsGroup']
  697. });
  698. SeriesRegistry.registerSeriesType('timeline', TimelineSeries);
  699. /* *
  700. *
  701. * Default Export
  702. *
  703. * */
  704. /* *
  705. *
  706. * API Declarations
  707. *
  708. * */
  709. /**
  710. * Callback JavaScript function to format the data label as a string. Note that
  711. * if a `format` is defined, the format takes precedence and the formatter is
  712. * ignored.
  713. *
  714. * @callback Highcharts.TimelineDataLabelsFormatterCallbackFunction
  715. *
  716. * @param {Highcharts.PointLabelObject|Highcharts.TimelineDataLabelsFormatterContextObject} this
  717. * Data label context to format
  718. *
  719. * @return {number|string|null|undefined}
  720. * Formatted data label text
  721. */
  722. /**
  723. * @interface Highcharts.TimelineDataLabelsFormatterContextObject
  724. * @extends Highcharts.PointLabelObject
  725. */ /**
  726. * @name Highcharts.TimelineDataLabelsFormatterContextObject#key
  727. * @type {string|undefined}
  728. */ /**
  729. * @name Highcharts.TimelineDataLabelsFormatterContextObject#point
  730. * @type {Highcharts.Point}
  731. */ /**
  732. * @name Highcharts.TimelineDataLabelsFormatterContextObject#series
  733. * @type {Highcharts.Series}
  734. */
  735. ''; // dettach doclets above
  736. /* *
  737. *
  738. * API Options
  739. *
  740. * */
  741. /**
  742. * The `timeline` series. If the [type](#series.timeline.type) option is
  743. * not specified, it is inherited from [chart.type](#chart.type).
  744. *
  745. * @extends series,plotOptions.timeline
  746. * @excluding animationLimit, boostThreshold, connectEnds, connectNulls,
  747. * cropThreshold, dashStyle, dataParser, dataURL, findNearestPointBy,
  748. * getExtremesFromAll, lineWidth, negativeColor,
  749. * pointInterval, pointIntervalUnit, pointPlacement, pointStart,
  750. * softThreshold, stacking, stack, step, threshold, turboThreshold,
  751. * zoneAxis, zones, dataSorting, boostBlending
  752. * @product highcharts
  753. * @requires modules/timeline
  754. * @apioption series.timeline
  755. */
  756. /**
  757. * An array of data points for the series. For the `timeline` series type,
  758. * points can be given with three general parameters, `name`, `label`,
  759. * and `description`:
  760. *
  761. * Example:
  762. *
  763. * ```js
  764. * series: [{
  765. * type: 'timeline',
  766. * data: [{
  767. * name: 'Jan 2018',
  768. * label: 'Some event label',
  769. * description: 'Description to show in tooltip'
  770. * }]
  771. * }]
  772. * ```
  773. * If all points additionally have the `x` values, and xAxis type is set to
  774. * `datetime`, then events are laid out on a true time axis, where their
  775. * placement reflects the actual time between them.
  776. *
  777. * @sample {highcharts} highcharts/series-timeline/alternate-labels
  778. * Alternate labels
  779. * @sample {highcharts} highcharts/series-timeline/datetime-axis
  780. * Real time intervals
  781. *
  782. * @type {Array<*>}
  783. * @extends series.line.data
  784. * @excluding marker, y
  785. * @product highcharts
  786. * @apioption series.timeline.data
  787. */
  788. /**
  789. * The name of event.
  790. *
  791. * @type {string}
  792. * @product highcharts
  793. * @apioption series.timeline.data.name
  794. */
  795. /**
  796. * The label of event.
  797. *
  798. * @type {string}
  799. * @product highcharts
  800. * @apioption series.timeline.data.label
  801. */
  802. /**
  803. * The description of event. This description will be shown in tooltip.
  804. *
  805. * @type {string}
  806. * @product highcharts
  807. * @apioption series.timeline.data.description
  808. */
  809. ''; // adds doclets above to transpiled file
  810. return TimelineSeries;
  811. });
  812. _registerModule(_modules, 'masters/modules/timeline.src.js', [], function () {
  813. });
  814. }));