xrange.src.js 37 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958
  1. /**
  2. * @license Highcharts JS v9.1.1 (2021-06-04)
  3. *
  4. * X-range series
  5. *
  6. * (c) 2010-2021 Torstein Honsi, Lars A. V. Cabrera
  7. *
  8. * License: www.highcharts.com/license
  9. */
  10. 'use strict';
  11. (function (factory) {
  12. if (typeof module === 'object' && module.exports) {
  13. factory['default'] = factory;
  14. module.exports = factory;
  15. } else if (typeof define === 'function' && define.amd) {
  16. define('highcharts/modules/xrange', ['highcharts'], function (Highcharts) {
  17. factory(Highcharts);
  18. factory.Highcharts = Highcharts;
  19. return factory;
  20. });
  21. } else {
  22. factory(typeof Highcharts !== 'undefined' ? Highcharts : undefined);
  23. }
  24. }(function (Highcharts) {
  25. var _modules = Highcharts ? Highcharts._modules : {};
  26. function _registerModule(obj, path, args, fn) {
  27. if (!obj.hasOwnProperty(path)) {
  28. obj[path] = fn.apply(null, args);
  29. }
  30. }
  31. _registerModule(_modules, 'Series/XRange/XRangePoint.js', [_modules['Core/Series/Point.js'], _modules['Core/Series/SeriesRegistry.js'], _modules['Core/Utilities.js']], function (Point, SeriesRegistry, U) {
  32. /* *
  33. *
  34. * X-range series module
  35. *
  36. * (c) 2010-2021 Torstein Honsi, Lars A. V. Cabrera
  37. *
  38. * License: www.highcharts.com/license
  39. *
  40. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  41. *
  42. * */
  43. var __extends = (this && this.__extends) || (function () {
  44. var extendStatics = function (d,
  45. b) {
  46. extendStatics = Object.setPrototypeOf ||
  47. ({ __proto__: [] } instanceof Array && function (d,
  48. b) { d.__proto__ = b; }) ||
  49. function (d,
  50. b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  51. return extendStatics(d, b);
  52. };
  53. return function (d, b) {
  54. extendStatics(d, b);
  55. function __() { this.constructor = d; }
  56. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  57. };
  58. })();
  59. var ColumnSeries = SeriesRegistry.seriesTypes.column;
  60. var extend = U.extend;
  61. /* *
  62. *
  63. * Class
  64. *
  65. * */
  66. var XRangePoint = /** @class */ (function (_super) {
  67. __extends(XRangePoint, _super);
  68. function XRangePoint() {
  69. var _this = _super !== null && _super.apply(this,
  70. arguments) || this;
  71. /* *
  72. *
  73. * Properties
  74. *
  75. * */
  76. _this.options = void 0;
  77. _this.series = void 0;
  78. return _this;
  79. /* eslint-enable valid-jsdoc */
  80. }
  81. /* *
  82. *
  83. * Static properties
  84. *
  85. * */
  86. /**
  87. * Return color of a point based on its category.
  88. *
  89. * @private
  90. * @function getColorByCategory
  91. *
  92. * @param {object} series
  93. * The series which the point belongs to.
  94. *
  95. * @param {object} point
  96. * The point to calculate its color for.
  97. *
  98. * @return {object}
  99. * Returns an object containing the properties color and colorIndex.
  100. */
  101. XRangePoint.getColorByCategory = function (series, point) {
  102. var colors = series.options.colors || series.chart.options.colors,
  103. colorCount = colors ?
  104. colors.length :
  105. series.chart.options.chart.colorCount,
  106. colorIndex = point.y % colorCount,
  107. color = colors && colors[colorIndex];
  108. return {
  109. colorIndex: colorIndex,
  110. color: color
  111. };
  112. };
  113. /* *
  114. *
  115. * Functions
  116. *
  117. * */
  118. /**
  119. * The ending X value of the range point.
  120. * @name Highcharts.Point#x2
  121. * @type {number|undefined}
  122. * @requires modules/xrange
  123. */
  124. /**
  125. * Extend applyOptions so that `colorByPoint` for x-range means that one
  126. * color is applied per Y axis category.
  127. *
  128. * @private
  129. * @function Highcharts.Point#applyOptions
  130. *
  131. * @return {Highcharts.Series}
  132. */
  133. /* eslint-disable valid-jsdoc */
  134. /**
  135. * @private
  136. */
  137. XRangePoint.prototype.resolveColor = function () {
  138. var series = this.series,
  139. colorByPoint;
  140. if (series.options.colorByPoint && !this.options.color) {
  141. colorByPoint = XRangePoint.getColorByCategory(series, this);
  142. if (!series.chart.styledMode) {
  143. this.color = colorByPoint.color;
  144. }
  145. if (!this.options.colorIndex) {
  146. this.colorIndex = colorByPoint.colorIndex;
  147. }
  148. }
  149. else if (!this.color) {
  150. this.color = series.color;
  151. }
  152. };
  153. /**
  154. * Extend init to have y default to 0.
  155. *
  156. * @private
  157. * @function Highcharts.Point#init
  158. *
  159. * @return {Highcharts.Point}
  160. */
  161. XRangePoint.prototype.init = function () {
  162. Point.prototype.init.apply(this, arguments);
  163. if (!this.y) {
  164. this.y = 0;
  165. }
  166. return this;
  167. };
  168. /**
  169. * @private
  170. * @function Highcharts.Point#setState
  171. */
  172. XRangePoint.prototype.setState = function () {
  173. Point.prototype.setState.apply(this, arguments);
  174. this.series.drawPoint(this, this.series.getAnimationVerb());
  175. };
  176. /**
  177. * @private
  178. * @function Highcharts.Point#getLabelConfig
  179. *
  180. * @return {Highcharts.PointLabelObject}
  181. */
  182. // Add x2 and yCategory to the available properties for tooltip formats
  183. XRangePoint.prototype.getLabelConfig = function () {
  184. var point = this,
  185. cfg = Point.prototype.getLabelConfig.call(point),
  186. yCats = point.series.yAxis.categories;
  187. cfg.x2 = point.x2;
  188. cfg.yCategory = point.yCategory = yCats && yCats[point.y];
  189. return cfg;
  190. };
  191. /**
  192. * @private
  193. * @function Highcharts.Point#isValid
  194. *
  195. * @return {boolean}
  196. */
  197. XRangePoint.prototype.isValid = function () {
  198. return typeof this.x === 'number' &&
  199. typeof this.x2 === 'number';
  200. };
  201. return XRangePoint;
  202. }(ColumnSeries.prototype.pointClass));
  203. extend(XRangePoint.prototype, {
  204. tooltipDateKeys: ['x', 'x2']
  205. });
  206. /* *
  207. *
  208. * Default Export
  209. *
  210. * */
  211. return XRangePoint;
  212. });
  213. _registerModule(_modules, 'Series/XRange/XRangeComposition.js', [_modules['Core/Axis/Axis.js'], _modules['Core/Utilities.js']], function (Axis, U) {
  214. /* *
  215. *
  216. * X-range series module
  217. *
  218. * (c) 2010-2021 Torstein Honsi, Lars A. V. Cabrera
  219. *
  220. * License: www.highcharts.com/license
  221. *
  222. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  223. *
  224. * */
  225. /* *
  226. *
  227. * Imports
  228. *
  229. * */
  230. /* *
  231. *
  232. * Imports
  233. *
  234. * */
  235. var addEvent = U.addEvent,
  236. pick = U.pick;
  237. /**
  238. * Max x2 should be considered in xAxis extremes
  239. */
  240. addEvent(Axis, 'afterGetSeriesExtremes', function () {
  241. var axis = this, // eslint-disable-line no-invalid-this
  242. axisSeries = axis.series,
  243. dataMax,
  244. modMax;
  245. if (axis.isXAxis) {
  246. dataMax = pick(axis.dataMax, -Number.MAX_VALUE);
  247. axisSeries.forEach(function (series) {
  248. if (series.x2Data) {
  249. series.x2Data
  250. .forEach(function (val) {
  251. if (val > dataMax) {
  252. dataMax = val;
  253. modMax = true;
  254. }
  255. });
  256. }
  257. });
  258. if (modMax) {
  259. axis.dataMax = dataMax;
  260. }
  261. }
  262. });
  263. });
  264. _registerModule(_modules, 'Series/XRange/XRangeSeries.js', [_modules['Core/Globals.js'], _modules['Core/Color/Color.js'], _modules['Core/Series/SeriesRegistry.js'], _modules['Core/Utilities.js'], _modules['Series/XRange/XRangePoint.js']], function (H, Color, SeriesRegistry, U, XRangePoint) {
  265. /* *
  266. *
  267. * X-range series module
  268. *
  269. * (c) 2010-2021 Torstein Honsi, Lars A. V. Cabrera
  270. *
  271. * License: www.highcharts.com/license
  272. *
  273. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  274. *
  275. * */
  276. var __extends = (this && this.__extends) || (function () {
  277. var extendStatics = function (d,
  278. b) {
  279. extendStatics = Object.setPrototypeOf ||
  280. ({ __proto__: [] } instanceof Array && function (d,
  281. b) { d.__proto__ = b; }) ||
  282. function (d,
  283. b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  284. return extendStatics(d, b);
  285. };
  286. return function (d, b) {
  287. extendStatics(d, b);
  288. function __() { this.constructor = d; }
  289. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  290. };
  291. })();
  292. var color = Color.parse;
  293. var Series = SeriesRegistry.series,
  294. ColumnSeries = SeriesRegistry.seriesTypes.column;
  295. var columnProto = ColumnSeries.prototype;
  296. var clamp = U.clamp,
  297. correctFloat = U.correctFloat,
  298. defined = U.defined,
  299. extend = U.extend,
  300. find = U.find,
  301. isNumber = U.isNumber,
  302. isObject = U.isObject,
  303. merge = U.merge,
  304. pick = U.pick;
  305. /* *
  306. * @interface Highcharts.PointOptionsObject in parts/Point.ts
  307. */ /**
  308. * The ending X value of the range point.
  309. * @name Highcharts.PointOptionsObject#x2
  310. * @type {number|undefined}
  311. * @requires modules/xrange
  312. */
  313. /**
  314. * @private
  315. * @class
  316. * @name Highcharts.seriesTypes.xrange
  317. *
  318. * @augments Highcharts.Series
  319. */
  320. var XRangeSeries = /** @class */ (function (_super) {
  321. __extends(XRangeSeries, _super);
  322. function XRangeSeries() {
  323. var _this = _super !== null && _super.apply(this,
  324. arguments) || this;
  325. /* *
  326. *
  327. * Properties
  328. *
  329. * */
  330. _this.data = void 0;
  331. _this.options = void 0;
  332. _this.points = void 0;
  333. return _this;
  334. /*
  335. // Override to remove stroke from points. For partial fill.
  336. pointAttribs: function () {
  337. let series = this,
  338. retVal = columnType.prototype.pointAttribs
  339. .apply(series, arguments);
  340. //retVal['stroke-width'] = 0;
  341. return retVal;
  342. }
  343. //*/
  344. /* eslint-enable valid-jsdoc */
  345. }
  346. /* *
  347. *
  348. * Functions
  349. *
  350. * */
  351. /* eslint-disable valid-jsdoc */
  352. /**
  353. * @private
  354. * @function Highcarts.seriesTypes.xrange#init
  355. * @return {void}
  356. */
  357. XRangeSeries.prototype.init = function () {
  358. ColumnSeries.prototype.init.apply(this, arguments);
  359. this.options.stacking = void 0; // #13161
  360. };
  361. /**
  362. * Borrow the column series metrics, but with swapped axes. This gives
  363. * free access to features like groupPadding, grouping, pointWidth etc.
  364. *
  365. * @private
  366. * @function Highcharts.Series#getColumnMetrics
  367. *
  368. * @return {Highcharts.ColumnMetricsObject}
  369. */
  370. XRangeSeries.prototype.getColumnMetrics = function () {
  371. var metrics,
  372. chart = this.chart;
  373. /**
  374. * @private
  375. */
  376. function swapAxes() {
  377. chart.series.forEach(function (s) {
  378. var xAxis = s.xAxis;
  379. s.xAxis = s.yAxis;
  380. s.yAxis = xAxis;
  381. });
  382. }
  383. swapAxes();
  384. metrics = columnProto.getColumnMetrics.call(this);
  385. swapAxes();
  386. return metrics;
  387. };
  388. /**
  389. * Override cropData to show a point where x or x2 is outside visible
  390. * range, but one of them is inside.
  391. *
  392. * @private
  393. * @function Highcharts.Series#cropData
  394. *
  395. * @param {Array<number>} xData
  396. *
  397. * @param {Array<number>} yData
  398. *
  399. * @param {number} min
  400. *
  401. * @param {number} max
  402. *
  403. * @param {number} [cropShoulder]
  404. *
  405. * @return {*}
  406. */
  407. XRangeSeries.prototype.cropData = function (xData, yData, min, max) {
  408. // Replace xData with x2Data to find the appropriate cropStart
  409. var cropData = Series.prototype.cropData,
  410. crop = cropData.call(this,
  411. this.x2Data,
  412. yData,
  413. min,
  414. max);
  415. // Re-insert the cropped xData
  416. crop.xData = xData.slice(crop.start, crop.end);
  417. return crop;
  418. };
  419. /**
  420. * Finds the index of an existing point that matches the given point
  421. * options.
  422. *
  423. * @private
  424. * @function Highcharts.Series#findPointIndex
  425. * @param {object} options The options of the point.
  426. * @returns {number|undefined} Returns index of a matching point,
  427. * returns undefined if no match is found.
  428. */
  429. XRangeSeries.prototype.findPointIndex = function (options) {
  430. var _a = this,
  431. cropped = _a.cropped,
  432. cropStart = _a.cropStart,
  433. points = _a.points;
  434. var id = options.id;
  435. var pointIndex;
  436. if (id) {
  437. var point = find(points,
  438. function (point) {
  439. return point.id === id;
  440. });
  441. pointIndex = point ? point.index : void 0;
  442. }
  443. if (typeof pointIndex === 'undefined') {
  444. var point = find(points,
  445. function (point) {
  446. return (point.x === options.x &&
  447. point.x2 === options.x2 &&
  448. !point.touched);
  449. });
  450. pointIndex = point ? point.index : void 0;
  451. }
  452. // Reduce pointIndex if data is cropped
  453. if (cropped &&
  454. isNumber(pointIndex) &&
  455. isNumber(cropStart) &&
  456. pointIndex >= cropStart) {
  457. pointIndex -= cropStart;
  458. }
  459. return pointIndex;
  460. };
  461. /**
  462. * @private
  463. * @function Highcharts.Series#translatePoint
  464. *
  465. * @param {Highcharts.Point} point
  466. */
  467. XRangeSeries.prototype.translatePoint = function (point) {
  468. var series = this,
  469. xAxis = series.xAxis,
  470. yAxis = series.yAxis,
  471. metrics = series.columnMetrics,
  472. options = series.options,
  473. minPointLength = options.minPointLength || 0,
  474. oldColWidth = (point.shapeArgs && point.shapeArgs.width || 0) / 2,
  475. seriesXOffset = series.pointXOffset = metrics.offset,
  476. plotX = point.plotX,
  477. posX = pick(point.x2,
  478. point.x + (point.len || 0)),
  479. plotX2 = xAxis.translate(posX, 0, 0, 0, 1),
  480. length = Math.abs(plotX2 - plotX),
  481. widthDifference,
  482. partialFill,
  483. inverted = this.chart.inverted,
  484. borderWidth = pick(options.borderWidth, 1),
  485. crisper = borderWidth % 2 / 2,
  486. yOffset = metrics.offset,
  487. pointHeight = Math.round(metrics.width),
  488. dlLeft,
  489. dlRight,
  490. dlWidth,
  491. clipRectWidth,
  492. tooltipYOffset;
  493. if (minPointLength) {
  494. widthDifference = minPointLength - length;
  495. if (widthDifference < 0) {
  496. widthDifference = 0;
  497. }
  498. plotX -= widthDifference / 2;
  499. plotX2 += widthDifference / 2;
  500. }
  501. plotX = Math.max(plotX, -10);
  502. plotX2 = clamp(plotX2, -10, xAxis.len + 10);
  503. // Handle individual pointWidth
  504. if (defined(point.options.pointWidth)) {
  505. yOffset -= ((Math.ceil(point.options.pointWidth) - pointHeight) / 2);
  506. pointHeight = Math.ceil(point.options.pointWidth);
  507. }
  508. // Apply pointPlacement to the Y axis
  509. if (options.pointPlacement &&
  510. isNumber(point.plotY) &&
  511. yAxis.categories) {
  512. point.plotY = yAxis.translate(point.y, 0, 1, 0, 1, options.pointPlacement);
  513. }
  514. var shapeArgs = {
  515. x: Math.floor(Math.min(plotX,
  516. plotX2)) + crisper,
  517. y: Math.floor(point.plotY + yOffset) + crisper,
  518. width: Math.round(Math.abs(plotX2 - plotX)),
  519. height: pointHeight,
  520. r: series.options.borderRadius
  521. };
  522. point.shapeArgs = shapeArgs;
  523. // Move tooltip to default position
  524. if (!inverted) {
  525. point.tooltipPos[0] -= oldColWidth +
  526. seriesXOffset -
  527. shapeArgs.width / 2;
  528. }
  529. else {
  530. point.tooltipPos[1] += seriesXOffset +
  531. oldColWidth;
  532. }
  533. // Align data labels inside the shape and inside the plot area
  534. dlLeft = shapeArgs.x;
  535. dlRight = dlLeft + shapeArgs.width;
  536. if (dlLeft < 0 || dlRight > xAxis.len) {
  537. dlLeft = clamp(dlLeft, 0, xAxis.len);
  538. dlRight = clamp(dlRight, 0, xAxis.len);
  539. dlWidth = dlRight - dlLeft;
  540. point.dlBox = merge(shapeArgs, {
  541. x: dlLeft,
  542. width: dlRight - dlLeft,
  543. centerX: dlWidth ? dlWidth / 2 : null
  544. });
  545. }
  546. else {
  547. point.dlBox = null;
  548. }
  549. // Tooltip position
  550. var tooltipPos = point.tooltipPos;
  551. var xIndex = !inverted ? 0 : 1;
  552. var yIndex = !inverted ? 1 : 0;
  553. tooltipYOffset = series.columnMetrics ?
  554. series.columnMetrics.offset : -metrics.width / 2;
  555. // Centering tooltip position (#14147)
  556. if (!inverted) {
  557. tooltipPos[xIndex] += (xAxis.reversed ? -1 : 0) * shapeArgs.width;
  558. }
  559. else {
  560. tooltipPos[xIndex] += shapeArgs.width / 2;
  561. }
  562. tooltipPos[yIndex] = clamp(tooltipPos[yIndex] + ((inverted ? -1 : 1) * tooltipYOffset), 0, yAxis.len - 1);
  563. // Add a partShapeArgs to the point, based on the shapeArgs property
  564. partialFill = point.partialFill;
  565. if (partialFill) {
  566. // Get the partial fill amount
  567. if (isObject(partialFill)) {
  568. partialFill = partialFill.amount;
  569. }
  570. // If it was not a number, assume 0
  571. if (!isNumber(partialFill)) {
  572. partialFill = 0;
  573. }
  574. point.partShapeArgs = merge(shapeArgs, {
  575. r: series.options.borderRadius
  576. });
  577. clipRectWidth = Math.max(Math.round(length * partialFill + point.plotX -
  578. plotX), 0);
  579. point.clipRectArgs = {
  580. x: xAxis.reversed ? // #10717
  581. shapeArgs.x + length - clipRectWidth :
  582. shapeArgs.x,
  583. y: shapeArgs.y,
  584. width: clipRectWidth,
  585. height: shapeArgs.height
  586. };
  587. }
  588. };
  589. /**
  590. * @private
  591. * @function Highcharts.Series#translate
  592. */
  593. XRangeSeries.prototype.translate = function () {
  594. columnProto.translate.apply(this, arguments);
  595. this.points.forEach(function (point) {
  596. this.translatePoint(point);
  597. }, this);
  598. };
  599. /**
  600. * Draws a single point in the series. Needed for partial fill.
  601. *
  602. * This override turns point.graphic into a group containing the
  603. * original graphic and an overlay displaying the partial fill.
  604. *
  605. * @private
  606. * @function Highcharts.Series#drawPoint
  607. *
  608. * @param {Highcharts.Point} point
  609. * An instance of Point in the series.
  610. *
  611. * @param {"animate"|"attr"} verb
  612. * 'animate' (animates changes) or 'attr' (sets options)
  613. */
  614. XRangeSeries.prototype.drawPoint = function (point, verb) {
  615. var series = this,
  616. seriesOpts = series.options,
  617. renderer = series.chart.renderer,
  618. graphic = point.graphic,
  619. type = point.shapeType,
  620. shapeArgs = point.shapeArgs,
  621. partShapeArgs = point.partShapeArgs,
  622. clipRectArgs = point.clipRectArgs,
  623. pfOptions = point.partialFill,
  624. cutOff = seriesOpts.stacking && !seriesOpts.borderRadius,
  625. pointState = point.state,
  626. stateOpts = (seriesOpts.states[pointState || 'normal'] ||
  627. {}),
  628. pointStateVerb = typeof pointState === 'undefined' ?
  629. 'attr' : verb,
  630. pointAttr = series.pointAttribs(point,
  631. pointState),
  632. animation = pick(series.chart.options.chart.animation,
  633. stateOpts.animation),
  634. fill;
  635. if (!point.isNull && point.visible !== false) {
  636. // Original graphic
  637. if (graphic) { // update
  638. graphic.rect[verb](shapeArgs);
  639. }
  640. else {
  641. point.graphic = graphic = renderer.g('point')
  642. .addClass(point.getClassName())
  643. .add(point.group || series.group);
  644. graphic.rect = renderer[type](merge(shapeArgs))
  645. .addClass(point.getClassName())
  646. .addClass('highcharts-partfill-original')
  647. .add(graphic);
  648. }
  649. // Partial fill graphic
  650. if (partShapeArgs) {
  651. if (graphic.partRect) {
  652. graphic.partRect[verb](merge(partShapeArgs));
  653. graphic.partialClipRect[verb](merge(clipRectArgs));
  654. }
  655. else {
  656. graphic.partialClipRect = renderer.clipRect(clipRectArgs.x, clipRectArgs.y, clipRectArgs.width, clipRectArgs.height);
  657. graphic.partRect =
  658. renderer[type](partShapeArgs)
  659. .addClass('highcharts-partfill-overlay')
  660. .add(graphic)
  661. .clip(graphic.partialClipRect);
  662. }
  663. }
  664. // Presentational
  665. if (!series.chart.styledMode) {
  666. graphic
  667. .rect[verb](pointAttr, animation)
  668. .shadow(seriesOpts.shadow, null, cutOff);
  669. if (partShapeArgs) {
  670. // Ensure pfOptions is an object
  671. if (!isObject(pfOptions)) {
  672. pfOptions = {};
  673. }
  674. if (isObject(seriesOpts.partialFill)) {
  675. pfOptions = merge(seriesOpts.partialFill, pfOptions);
  676. }
  677. fill = (pfOptions.fill ||
  678. color(pointAttr.fill).brighten(-0.3).get() ||
  679. color(point.color || series.color)
  680. .brighten(-0.3).get());
  681. pointAttr.fill = fill;
  682. graphic
  683. .partRect[pointStateVerb](pointAttr, animation)
  684. .shadow(seriesOpts.shadow, null, cutOff);
  685. }
  686. }
  687. }
  688. else if (graphic) {
  689. point.graphic = graphic.destroy(); // #1269
  690. }
  691. };
  692. /**
  693. * @private
  694. * @function Highcharts.Series#drawPoints
  695. */
  696. XRangeSeries.prototype.drawPoints = function () {
  697. var series = this,
  698. verb = series.getAnimationVerb();
  699. // Draw the columns
  700. series.points.forEach(function (point) {
  701. series.drawPoint(point, verb);
  702. });
  703. };
  704. /**
  705. * Returns "animate", or "attr" if the number of points is above the
  706. * animation limit.
  707. *
  708. * @private
  709. * @function Highcharts.Series#getAnimationVerb
  710. *
  711. * @return {string}
  712. */
  713. XRangeSeries.prototype.getAnimationVerb = function () {
  714. return (this.chart.pointCount < (this.options.animationLimit || 250) ?
  715. 'animate' :
  716. 'attr');
  717. };
  718. /**
  719. * @private
  720. * @function Highcharts.XRangeSeries#isPointInside
  721. */
  722. XRangeSeries.prototype.isPointInside = function (point) {
  723. var shapeArgs = point.shapeArgs,
  724. plotX = point.plotX,
  725. plotY = point.plotY;
  726. if (!shapeArgs) {
  727. return _super.prototype.isPointInside.apply(this, arguments);
  728. }
  729. var isInside = typeof plotX !== 'undefined' &&
  730. typeof plotY !== 'undefined' &&
  731. plotY >= 0 &&
  732. plotY <= this.yAxis.len &&
  733. (shapeArgs.x || 0) + (shapeArgs.width || 0) >= 0 &&
  734. plotX <= this.xAxis.len;
  735. return isInside;
  736. };
  737. /* *
  738. *
  739. * Static properties
  740. *
  741. * */
  742. /**
  743. * The X-range series displays ranges on the X axis, typically time
  744. * intervals with a start and end date.
  745. *
  746. * @sample {highcharts} highcharts/demo/x-range/
  747. * X-range
  748. * @sample {highcharts} highcharts/css/x-range/
  749. * Styled mode X-range
  750. * @sample {highcharts} highcharts/chart/inverted-xrange/
  751. * Inverted X-range
  752. *
  753. * @extends plotOptions.column
  754. * @since 6.0.0
  755. * @product highcharts highstock gantt
  756. * @excluding boostThreshold, crisp, cropThreshold, depth, edgeColor,
  757. * edgeWidth, findNearestPointBy, getExtremesFromAll,
  758. * negativeColor, pointInterval, pointIntervalUnit,
  759. * pointPlacement, pointRange, pointStart, softThreshold,
  760. * stacking, threshold, data, dataSorting, boostBlending
  761. * @requires modules/xrange
  762. * @optionparent plotOptions.xrange
  763. */
  764. XRangeSeries.defaultOptions = merge(ColumnSeries.defaultOptions, {
  765. /**
  766. * A partial fill for each point, typically used to visualize how much
  767. * of a task is performed. The partial fill object can be set either on
  768. * series or point level.
  769. *
  770. * @sample {highcharts} highcharts/demo/x-range
  771. * X-range with partial fill
  772. *
  773. * @product highcharts highstock gantt
  774. * @apioption plotOptions.xrange.partialFill
  775. */
  776. /**
  777. * The fill color to be used for partial fills. Defaults to a darker
  778. * shade of the point color.
  779. *
  780. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  781. * @product highcharts highstock gantt
  782. * @apioption plotOptions.xrange.partialFill.fill
  783. */
  784. /**
  785. * A partial fill for each point, typically used to visualize how much
  786. * of a task is performed. See [completed](series.gantt.data.completed).
  787. *
  788. * @sample gantt/demo/progress-indicator
  789. * Gantt with progress indicator
  790. *
  791. * @product gantt
  792. * @apioption plotOptions.gantt.partialFill
  793. */
  794. /**
  795. * In an X-range series, this option makes all points of the same Y-axis
  796. * category the same color.
  797. */
  798. colorByPoint: true,
  799. dataLabels: {
  800. formatter: function () {
  801. var point = this.point,
  802. amount = point.partialFill;
  803. if (isObject(amount)) {
  804. amount = amount.amount;
  805. }
  806. if (isNumber(amount) && amount > 0) {
  807. return correctFloat(amount * 100) + '%';
  808. }
  809. },
  810. inside: true,
  811. verticalAlign: 'middle'
  812. },
  813. tooltip: {
  814. headerFormat: '<span style="font-size: 10px">{point.x} - {point.x2}</span><br/>',
  815. pointFormat: '<span style="color:{point.color}">\u25CF</span> {series.name}: <b>{point.yCategory}</b><br/>'
  816. },
  817. borderRadius: 3,
  818. pointRange: 0
  819. });
  820. return XRangeSeries;
  821. }(ColumnSeries));
  822. extend(XRangeSeries.prototype, {
  823. type: 'xrange',
  824. parallelArrays: ['x', 'x2', 'y'],
  825. requireSorting: false,
  826. animate: Series.prototype.animate,
  827. cropShoulder: 1,
  828. getExtremesFromAll: true,
  829. autoIncrement: H.noop,
  830. buildKDTree: H.noop,
  831. pointClass: XRangePoint
  832. });
  833. SeriesRegistry.registerSeriesType('xrange', XRangeSeries);
  834. /* *
  835. *
  836. * Default Export
  837. *
  838. * */
  839. /* *
  840. *
  841. * API Options
  842. *
  843. * */
  844. /**
  845. * An `xrange` series. If the [type](#series.xrange.type) option is not
  846. * specified, it is inherited from [chart.type](#chart.type).
  847. *
  848. * @extends series,plotOptions.xrange
  849. * @excluding boostThreshold, crisp, cropThreshold, depth, edgeColor, edgeWidth,
  850. * findNearestPointBy, getExtremesFromAll, negativeColor,
  851. * pointInterval, pointIntervalUnit, pointPlacement, pointRange,
  852. * pointStart, softThreshold, stacking, threshold, dataSorting,
  853. * boostBlending
  854. * @product highcharts highstock gantt
  855. * @requires modules/xrange
  856. * @apioption series.xrange
  857. */
  858. /**
  859. * An array of data points for the series. For the `xrange` series type,
  860. * points can be given in the following ways:
  861. *
  862. * 1. An array of objects with named values. The objects are point configuration
  863. * objects as seen below.
  864. * ```js
  865. * data: [{
  866. * x: Date.UTC(2017, 0, 1),
  867. * x2: Date.UTC(2017, 0, 3),
  868. * name: "Test",
  869. * y: 0,
  870. * color: "#00FF00"
  871. * }, {
  872. * x: Date.UTC(2017, 0, 4),
  873. * x2: Date.UTC(2017, 0, 5),
  874. * name: "Deploy",
  875. * y: 1,
  876. * color: "#FF0000"
  877. * }]
  878. * ```
  879. *
  880. * @sample {highcharts} highcharts/series/data-array-of-objects/
  881. * Config objects
  882. *
  883. * @declare Highcharts.XrangePointOptionsObject
  884. * @type {Array<*>}
  885. * @extends series.line.data
  886. * @product highcharts highstock gantt
  887. * @apioption series.xrange.data
  888. */
  889. /**
  890. * The starting X value of the range point.
  891. *
  892. * @sample {highcharts} highcharts/demo/x-range
  893. * X-range
  894. *
  895. * @type {number}
  896. * @product highcharts highstock gantt
  897. * @apioption series.xrange.data.x
  898. */
  899. /**
  900. * The ending X value of the range point.
  901. *
  902. * @sample {highcharts} highcharts/demo/x-range
  903. * X-range
  904. *
  905. * @type {number}
  906. * @product highcharts highstock gantt
  907. * @apioption series.xrange.data.x2
  908. */
  909. /**
  910. * The Y value of the range point.
  911. *
  912. * @sample {highcharts} highcharts/demo/x-range
  913. * X-range
  914. *
  915. * @type {number}
  916. * @product highcharts highstock gantt
  917. * @apioption series.xrange.data.y
  918. */
  919. /**
  920. * A partial fill for each point, typically used to visualize how much of
  921. * a task is performed. The partial fill object can be set either on series
  922. * or point level.
  923. *
  924. * @sample {highcharts} highcharts/demo/x-range
  925. * X-range with partial fill
  926. *
  927. * @declare Highcharts.XrangePointPartialFillOptionsObject
  928. * @product highcharts highstock gantt
  929. * @apioption series.xrange.data.partialFill
  930. */
  931. /**
  932. * The amount of the X-range point to be filled. Values can be 0-1 and are
  933. * converted to percentages in the default data label formatter.
  934. *
  935. * @type {number}
  936. * @product highcharts highstock gantt
  937. * @apioption series.xrange.data.partialFill.amount
  938. */
  939. /**
  940. * The fill color to be used for partial fills. Defaults to a darker shade
  941. * of the point color.
  942. *
  943. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  944. * @product highcharts highstock gantt
  945. * @apioption series.xrange.data.partialFill.fill
  946. */
  947. ''; // adds doclets above to transpiled file
  948. return XRangeSeries;
  949. });
  950. _registerModule(_modules, 'masters/modules/xrange.src.js', [], function () {
  951. });
  952. }));