dumbbell.src.js 50 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193
  1. /**
  2. * @license Highcharts JS v8.2.0 (2020-08-20)
  3. *
  4. * (c) 2009-2019 Sebastian Bochan, Rafal Sebestjanski
  5. *
  6. * License: www.highcharts.com/license
  7. */
  8. 'use strict';
  9. (function (factory) {
  10. if (typeof module === 'object' && module.exports) {
  11. factory['default'] = factory;
  12. module.exports = factory;
  13. } else if (typeof define === 'function' && define.amd) {
  14. define('highcharts/modules/dumbbell', ['highcharts'], function (Highcharts) {
  15. factory(Highcharts);
  16. factory.Highcharts = Highcharts;
  17. return factory;
  18. });
  19. } else {
  20. factory(typeof Highcharts !== 'undefined' ? Highcharts : undefined);
  21. }
  22. }(function (Highcharts) {
  23. var _modules = Highcharts ? Highcharts._modules : {};
  24. function _registerModule(obj, path, args, fn) {
  25. if (!obj.hasOwnProperty(path)) {
  26. obj[path] = fn.apply(null, args);
  27. }
  28. }
  29. _registerModule(_modules, 'Series/AreaRangeSeries.js', [_modules['Core/Globals.js'], _modules['Core/Series/Point.js'], _modules['Core/Utilities.js']], function (H, Point, U) {
  30. /* *
  31. *
  32. * (c) 2010-2020 Torstein Honsi
  33. *
  34. * License: www.highcharts.com/license
  35. *
  36. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  37. *
  38. * */
  39. var defined = U.defined,
  40. extend = U.extend,
  41. isArray = U.isArray,
  42. isNumber = U.isNumber,
  43. pick = U.pick,
  44. seriesType = U.seriesType;
  45. var noop = H.noop,
  46. Series = H.Series,
  47. seriesTypes = H.seriesTypes,
  48. seriesProto = Series.prototype,
  49. pointProto = Point.prototype;
  50. /**
  51. * The area range series is a carteseian series with higher and lower values for
  52. * each point along an X axis, where the area between the values is shaded.
  53. *
  54. * @sample {highcharts} highcharts/demo/arearange/
  55. * Area range chart
  56. * @sample {highstock} stock/demo/arearange/
  57. * Area range chart
  58. *
  59. * @extends plotOptions.area
  60. * @product highcharts highstock
  61. * @excluding stack, stacking
  62. * @requires highcharts-more
  63. * @optionparent plotOptions.arearange
  64. */
  65. seriesType('arearange', 'area', {
  66. /**
  67. * Whether to apply a drop shadow to the graph line. Since 2.3 the shadow
  68. * can be an object configuration containing `color`, `offsetX`, `offsetY`,
  69. * `opacity` and `width`.
  70. *
  71. * @type {boolean|Highcharts.ShadowOptionsObject}
  72. * @product highcharts
  73. * @apioption plotOptions.arearange.shadow
  74. */
  75. /**
  76. * @default low
  77. * @apioption plotOptions.arearange.colorKey
  78. */
  79. /**
  80. * Pixel width of the arearange graph line.
  81. *
  82. * @since 2.3.0
  83. *
  84. * @private
  85. */
  86. lineWidth: 1,
  87. threshold: null,
  88. tooltip: {
  89. pointFormat: '<span style="color:{series.color}">\u25CF</span> ' +
  90. '{series.name}: <b>{point.low}</b> - <b>{point.high}</b><br/>'
  91. },
  92. /**
  93. * Whether the whole area or just the line should respond to mouseover
  94. * tooltips and other mouse or touch events.
  95. *
  96. * @since 2.3.0
  97. *
  98. * @private
  99. */
  100. trackByArea: true,
  101. /**
  102. * Extended data labels for range series types. Range series data labels use
  103. * no `x` and `y` options. Instead, they have `xLow`, `xHigh`, `yLow` and
  104. * `yHigh` options to allow the higher and lower data label sets
  105. * individually.
  106. *
  107. * @declare Highcharts.SeriesAreaRangeDataLabelsOptionsObject
  108. * @exclude x, y
  109. * @since 2.3.0
  110. * @product highcharts highstock
  111. *
  112. * @private
  113. */
  114. dataLabels: {
  115. align: void 0,
  116. verticalAlign: void 0,
  117. /**
  118. * X offset of the lower data labels relative to the point value.
  119. *
  120. * @sample highcharts/plotoptions/arearange-datalabels/
  121. * Data labels on range series
  122. * @sample highcharts/plotoptions/arearange-datalabels/
  123. * Data labels on range series
  124. */
  125. xLow: 0,
  126. /**
  127. * X offset of the higher data labels relative to the point value.
  128. *
  129. * @sample highcharts/plotoptions/arearange-datalabels/
  130. * Data labels on range series
  131. */
  132. xHigh: 0,
  133. /**
  134. * Y offset of the lower data labels relative to the point value.
  135. *
  136. * @sample highcharts/plotoptions/arearange-datalabels/
  137. * Data labels on range series
  138. */
  139. yLow: 0,
  140. /**
  141. * Y offset of the higher data labels relative to the point value.
  142. *
  143. * @sample highcharts/plotoptions/arearange-datalabels/
  144. * Data labels on range series
  145. */
  146. yHigh: 0
  147. }
  148. // Prototype members
  149. }, {
  150. pointArrayMap: ['low', 'high'],
  151. pointValKey: 'low',
  152. deferTranslatePolar: true,
  153. /* eslint-disable valid-jsdoc */
  154. /**
  155. * @private
  156. */
  157. toYData: function (point) {
  158. return [point.low, point.high];
  159. },
  160. /**
  161. * Translate a point's plotHigh from the internal angle and radius measures
  162. * to true plotHigh coordinates. This is an addition of the toXY method
  163. * found in Polar.js, because it runs too early for arearanges to be
  164. * considered (#3419).
  165. * @private
  166. */
  167. highToXY: function (point) {
  168. // Find the polar plotX and plotY
  169. var chart = this.chart,
  170. xy = this.xAxis.postTranslate(point.rectPlotX,
  171. this.yAxis.len - point.plotHigh);
  172. point.plotHighX = xy.x - chart.plotLeft;
  173. point.plotHigh = xy.y - chart.plotTop;
  174. point.plotLowX = point.plotX;
  175. },
  176. /**
  177. * Translate data points from raw values x and y to plotX and plotY.
  178. * @private
  179. */
  180. translate: function () {
  181. var series = this,
  182. yAxis = series.yAxis,
  183. hasModifyValue = !!series.modifyValue;
  184. seriesTypes.area.prototype.translate.apply(series);
  185. // Set plotLow and plotHigh
  186. series.points.forEach(function (point) {
  187. var high = point.high,
  188. plotY = point.plotY;
  189. if (point.isNull) {
  190. point.plotY = null;
  191. }
  192. else {
  193. point.plotLow = plotY;
  194. point.plotHigh = yAxis.translate(hasModifyValue ?
  195. series.modifyValue(high, point) :
  196. high, 0, 1, 0, 1);
  197. if (hasModifyValue) {
  198. point.yBottom = point.plotHigh;
  199. }
  200. }
  201. });
  202. // Postprocess plotHigh
  203. if (this.chart.polar) {
  204. this.points.forEach(function (point) {
  205. series.highToXY(point);
  206. point.tooltipPos = [
  207. (point.plotHighX + point.plotLowX) / 2,
  208. (point.plotHigh + point.plotLow) / 2
  209. ];
  210. });
  211. }
  212. },
  213. /**
  214. * Extend the line series' getSegmentPath method by applying the segment
  215. * path to both lower and higher values of the range.
  216. * @private
  217. */
  218. getGraphPath: function (points) {
  219. var highPoints = [],
  220. highAreaPoints = [],
  221. i,
  222. getGraphPath = seriesTypes.area.prototype.getGraphPath,
  223. point,
  224. pointShim,
  225. linePath,
  226. lowerPath,
  227. options = this.options,
  228. polar = this.chart.polar,
  229. connectEnds = polar && options.connectEnds !== false,
  230. connectNulls = options.connectNulls,
  231. step = options.step,
  232. higherPath,
  233. higherAreaPath;
  234. points = points || this.points;
  235. // Create the top line and the top part of the area fill. The area fill
  236. // compensates for null points by drawing down to the lower graph,
  237. // moving across the null gap and starting again at the lower graph.
  238. i = points.length;
  239. while (i--) {
  240. point = points[i];
  241. // Support for polar
  242. var highAreaPoint = polar ? {
  243. plotX: point.rectPlotX,
  244. plotY: point.yBottom,
  245. doCurve: false // #5186, gaps in areasplinerange fill
  246. } : {
  247. plotX: point.plotX,
  248. plotY: point.plotY,
  249. doCurve: false // #5186, gaps in areasplinerange fill
  250. };
  251. if (!point.isNull &&
  252. !connectEnds &&
  253. !connectNulls &&
  254. (!points[i + 1] || points[i + 1].isNull)) {
  255. highAreaPoints.push(highAreaPoint);
  256. }
  257. pointShim = {
  258. polarPlotY: point.polarPlotY,
  259. rectPlotX: point.rectPlotX,
  260. yBottom: point.yBottom,
  261. // plotHighX is for polar charts
  262. plotX: pick(point.plotHighX, point.plotX),
  263. plotY: point.plotHigh,
  264. isNull: point.isNull
  265. };
  266. highAreaPoints.push(pointShim);
  267. highPoints.push(pointShim);
  268. if (!point.isNull &&
  269. !connectEnds &&
  270. !connectNulls &&
  271. (!points[i - 1] || points[i - 1].isNull)) {
  272. highAreaPoints.push(highAreaPoint);
  273. }
  274. }
  275. // Get the paths
  276. lowerPath = getGraphPath.call(this, points);
  277. if (step) {
  278. if (step === true) {
  279. step = 'left';
  280. }
  281. options.step = {
  282. left: 'right',
  283. center: 'center',
  284. right: 'left'
  285. }[step]; // swap for reading in getGraphPath
  286. }
  287. higherPath = getGraphPath.call(this, highPoints);
  288. higherAreaPath = getGraphPath.call(this, highAreaPoints);
  289. options.step = step;
  290. // Create a line on both top and bottom of the range
  291. linePath = []
  292. .concat(lowerPath, higherPath);
  293. // For the area path, we need to change the 'move' statement
  294. // into 'lineTo'
  295. if (!this.chart.polar && higherAreaPath[0] && higherAreaPath[0][0] === 'M') {
  296. // This probably doesn't work for spline
  297. higherAreaPath[0] = ['L', higherAreaPath[0][1], higherAreaPath[0][2]];
  298. }
  299. this.graphPath = linePath;
  300. this.areaPath = lowerPath.concat(higherAreaPath);
  301. // Prepare for sideways animation
  302. linePath.isArea = true;
  303. linePath.xMap = lowerPath.xMap;
  304. this.areaPath.xMap = lowerPath.xMap;
  305. return linePath;
  306. },
  307. /**
  308. * Extend the basic drawDataLabels method by running it for both lower and
  309. * higher values.
  310. * @private
  311. */
  312. drawDataLabels: function () {
  313. var data = this.points,
  314. length = data.length,
  315. i,
  316. originalDataLabels = [],
  317. dataLabelOptions = this.options.dataLabels,
  318. point,
  319. up,
  320. inverted = this.chart.inverted,
  321. upperDataLabelOptions,
  322. lowerDataLabelOptions;
  323. // Split into upper and lower options. If data labels is an array, the
  324. // first element is the upper label, the second is the lower.
  325. //
  326. // TODO: We want to change this and allow multiple labels for both upper
  327. // and lower values in the future - introducing some options for which
  328. // point value to use as Y for the dataLabel, so that this could be
  329. // handled in Series.drawDataLabels. This would also improve performance
  330. // since we now have to loop over all the points multiple times to work
  331. // around the data label logic.
  332. if (isArray(dataLabelOptions)) {
  333. if (dataLabelOptions.length > 1) {
  334. upperDataLabelOptions = dataLabelOptions[0];
  335. lowerDataLabelOptions = dataLabelOptions[1];
  336. }
  337. else {
  338. upperDataLabelOptions = dataLabelOptions[0];
  339. lowerDataLabelOptions = { enabled: false };
  340. }
  341. }
  342. else {
  343. // Make copies
  344. upperDataLabelOptions = extend({}, dataLabelOptions);
  345. upperDataLabelOptions.x = dataLabelOptions.xHigh;
  346. upperDataLabelOptions.y = dataLabelOptions.yHigh;
  347. lowerDataLabelOptions = extend({}, dataLabelOptions);
  348. lowerDataLabelOptions.x = dataLabelOptions.xLow;
  349. lowerDataLabelOptions.y = dataLabelOptions.yLow;
  350. }
  351. // Draw upper labels
  352. if (upperDataLabelOptions.enabled || this._hasPointLabels) {
  353. // Set preliminary values for plotY and dataLabel
  354. // and draw the upper labels
  355. i = length;
  356. while (i--) {
  357. point = data[i];
  358. if (point) {
  359. up = upperDataLabelOptions.inside ?
  360. point.plotHigh < point.plotLow :
  361. point.plotHigh > point.plotLow;
  362. point.y = point.high;
  363. point._plotY = point.plotY;
  364. point.plotY = point.plotHigh;
  365. // Store original data labels and set preliminary label
  366. // objects to be picked up in the uber method
  367. originalDataLabels[i] = point.dataLabel;
  368. point.dataLabel = point.dataLabelUpper;
  369. // Set the default offset
  370. point.below = up;
  371. if (inverted) {
  372. if (!upperDataLabelOptions.align) {
  373. upperDataLabelOptions.align = up ? 'right' : 'left';
  374. }
  375. }
  376. else {
  377. if (!upperDataLabelOptions.verticalAlign) {
  378. upperDataLabelOptions.verticalAlign = up ?
  379. 'top' :
  380. 'bottom';
  381. }
  382. }
  383. }
  384. }
  385. this.options.dataLabels = upperDataLabelOptions;
  386. if (seriesProto.drawDataLabels) {
  387. // #1209:
  388. seriesProto.drawDataLabels.apply(this, arguments);
  389. }
  390. // Reset state after the upper labels were created. Move
  391. // it to point.dataLabelUpper and reassign the originals.
  392. // We do this here to support not drawing a lower label.
  393. i = length;
  394. while (i--) {
  395. point = data[i];
  396. if (point) {
  397. point.dataLabelUpper = point.dataLabel;
  398. point.dataLabel = originalDataLabels[i];
  399. delete point.dataLabels;
  400. point.y = point.low;
  401. point.plotY = point._plotY;
  402. }
  403. }
  404. }
  405. // Draw lower labels
  406. if (lowerDataLabelOptions.enabled || this._hasPointLabels) {
  407. i = length;
  408. while (i--) {
  409. point = data[i];
  410. if (point) {
  411. up = lowerDataLabelOptions.inside ?
  412. point.plotHigh < point.plotLow :
  413. point.plotHigh > point.plotLow;
  414. // Set the default offset
  415. point.below = !up;
  416. if (inverted) {
  417. if (!lowerDataLabelOptions.align) {
  418. lowerDataLabelOptions.align = up ? 'left' : 'right';
  419. }
  420. }
  421. else {
  422. if (!lowerDataLabelOptions.verticalAlign) {
  423. lowerDataLabelOptions.verticalAlign = up ?
  424. 'bottom' :
  425. 'top';
  426. }
  427. }
  428. }
  429. }
  430. this.options.dataLabels = lowerDataLabelOptions;
  431. if (seriesProto.drawDataLabels) {
  432. seriesProto.drawDataLabels.apply(this, arguments);
  433. }
  434. }
  435. // Merge upper and lower into point.dataLabels for later destroying
  436. if (upperDataLabelOptions.enabled) {
  437. i = length;
  438. while (i--) {
  439. point = data[i];
  440. if (point) {
  441. point.dataLabels = [
  442. point.dataLabelUpper,
  443. point.dataLabel
  444. ].filter(function (label) {
  445. return !!label;
  446. });
  447. }
  448. }
  449. }
  450. // Reset options
  451. this.options.dataLabels = dataLabelOptions;
  452. },
  453. alignDataLabel: function () {
  454. seriesTypes.column.prototype.alignDataLabel
  455. .apply(this, arguments);
  456. },
  457. drawPoints: function () {
  458. var series = this,
  459. pointLength = series.points.length,
  460. point,
  461. i;
  462. // Draw bottom points
  463. seriesProto.drawPoints
  464. .apply(series, arguments);
  465. // Prepare drawing top points
  466. i = 0;
  467. while (i < pointLength) {
  468. point = series.points[i];
  469. // Save original props to be overridden by temporary props for top
  470. // points
  471. point.origProps = {
  472. plotY: point.plotY,
  473. plotX: point.plotX,
  474. isInside: point.isInside,
  475. negative: point.negative,
  476. zone: point.zone,
  477. y: point.y
  478. };
  479. point.lowerGraphic = point.graphic;
  480. point.graphic = point.upperGraphic;
  481. point.plotY = point.plotHigh;
  482. if (defined(point.plotHighX)) {
  483. point.plotX = point.plotHighX;
  484. }
  485. point.y = point.high;
  486. point.negative = point.high < (series.options.threshold || 0);
  487. point.zone = (series.zones.length && point.getZone());
  488. if (!series.chart.polar) {
  489. point.isInside = point.isTopInside = (typeof point.plotY !== 'undefined' &&
  490. point.plotY >= 0 &&
  491. point.plotY <= series.yAxis.len && // #3519
  492. point.plotX >= 0 &&
  493. point.plotX <= series.xAxis.len);
  494. }
  495. i++;
  496. }
  497. // Draw top points
  498. seriesProto.drawPoints.apply(series, arguments);
  499. // Reset top points preliminary modifications
  500. i = 0;
  501. while (i < pointLength) {
  502. point = series.points[i];
  503. point.upperGraphic = point.graphic;
  504. point.graphic = point.lowerGraphic;
  505. extend(point, point.origProps);
  506. delete point.origProps;
  507. i++;
  508. }
  509. },
  510. /* eslint-enable valid-jsdoc */
  511. setStackedPoints: noop
  512. }, {
  513. /**
  514. * Range series only. The high or maximum value for each data point.
  515. * @name Highcharts.Point#high
  516. * @type {number|undefined}
  517. */
  518. /**
  519. * Range series only. The low or minimum value for each data point.
  520. * @name Highcharts.Point#low
  521. * @type {number|undefined}
  522. */
  523. /* eslint-disable valid-jsdoc */
  524. /**
  525. * @private
  526. */
  527. setState: function () {
  528. var prevState = this.state,
  529. series = this.series,
  530. isPolar = series.chart.polar;
  531. if (!defined(this.plotHigh)) {
  532. // Boost doesn't calculate plotHigh
  533. this.plotHigh = series.yAxis.toPixels(this.high, true);
  534. }
  535. if (!defined(this.plotLow)) {
  536. // Boost doesn't calculate plotLow
  537. this.plotLow = this.plotY = series.yAxis.toPixels(this.low, true);
  538. }
  539. if (series.stateMarkerGraphic) {
  540. series.lowerStateMarkerGraphic = series.stateMarkerGraphic;
  541. series.stateMarkerGraphic = series.upperStateMarkerGraphic;
  542. }
  543. // Change state also for the top marker
  544. this.graphic = this.upperGraphic;
  545. this.plotY = this.plotHigh;
  546. if (isPolar) {
  547. this.plotX = this.plotHighX;
  548. }
  549. // Top state:
  550. pointProto.setState.apply(this, arguments);
  551. this.state = prevState;
  552. // Now restore defaults
  553. this.plotY = this.plotLow;
  554. this.graphic = this.lowerGraphic;
  555. if (isPolar) {
  556. this.plotX = this.plotLowX;
  557. }
  558. if (series.stateMarkerGraphic) {
  559. series.upperStateMarkerGraphic = series.stateMarkerGraphic;
  560. series.stateMarkerGraphic = series.lowerStateMarkerGraphic;
  561. // Lower marker is stored at stateMarkerGraphic
  562. // to avoid reference duplication (#7021)
  563. series.lowerStateMarkerGraphic = void 0;
  564. }
  565. pointProto.setState.apply(this, arguments);
  566. },
  567. haloPath: function () {
  568. var isPolar = this.series.chart.polar,
  569. path = [];
  570. // Bottom halo
  571. this.plotY = this.plotLow;
  572. if (isPolar) {
  573. this.plotX = this.plotLowX;
  574. }
  575. if (this.isInside) {
  576. path = pointProto.haloPath.apply(this, arguments);
  577. }
  578. // Top halo
  579. this.plotY = this.plotHigh;
  580. if (isPolar) {
  581. this.plotX = this.plotHighX;
  582. }
  583. if (this.isTopInside) {
  584. path = path.concat(pointProto.haloPath.apply(this, arguments));
  585. }
  586. return path;
  587. },
  588. destroyElements: function () {
  589. var graphics = ['lowerGraphic', 'upperGraphic'];
  590. graphics.forEach(function (graphicName) {
  591. if (this[graphicName]) {
  592. this[graphicName] =
  593. this[graphicName].destroy();
  594. }
  595. }, this);
  596. // Clear graphic for states, removed in the above each:
  597. this.graphic = null;
  598. return pointProto.destroyElements.apply(this, arguments);
  599. },
  600. isValid: function () {
  601. return isNumber(this.low) && isNumber(this.high);
  602. }
  603. /* eslint-enable valid-jsdoc */
  604. });
  605. /**
  606. * A `arearange` series. If the [type](#series.arearange.type) option is not
  607. * specified, it is inherited from [chart.type](#chart.type).
  608. *
  609. *
  610. * @extends series,plotOptions.arearange
  611. * @excluding dataParser, dataURL, stack, stacking
  612. * @product highcharts highstock
  613. * @requires highcharts-more
  614. * @apioption series.arearange
  615. */
  616. /**
  617. * An array of data points for the series. For the `arearange` series type,
  618. * points can be given in the following ways:
  619. *
  620. * 1. An array of arrays with 3 or 2 values. In this case, the values
  621. * correspond to `x,low,high`. If the first value is a string, it is
  622. * applied as the name of the point, and the `x` value is inferred.
  623. * The `x` value can also be omitted, in which case the inner arrays
  624. * should be of length 2\. Then the `x` value is automatically calculated,
  625. * either starting at 0 and incremented by 1, or from `pointStart`
  626. * and `pointInterval` given in the series options.
  627. * ```js
  628. * data: [
  629. * [0, 8, 3],
  630. * [1, 1, 1],
  631. * [2, 6, 8]
  632. * ]
  633. * ```
  634. *
  635. * 2. An array of objects with named values. The following snippet shows only a
  636. * few settings, see the complete options set below. If the total number of
  637. * data points exceeds the series'
  638. * [turboThreshold](#series.arearange.turboThreshold),
  639. * this option is not available.
  640. * ```js
  641. * data: [{
  642. * x: 1,
  643. * low: 9,
  644. * high: 0,
  645. * name: "Point2",
  646. * color: "#00FF00"
  647. * }, {
  648. * x: 1,
  649. * low: 3,
  650. * high: 4,
  651. * name: "Point1",
  652. * color: "#FF00FF"
  653. * }]
  654. * ```
  655. *
  656. * @sample {highcharts} highcharts/series/data-array-of-arrays/
  657. * Arrays of numeric x and y
  658. * @sample {highcharts} highcharts/series/data-array-of-arrays-datetime/
  659. * Arrays of datetime x and y
  660. * @sample {highcharts} highcharts/series/data-array-of-name-value/
  661. * Arrays of point.name and y
  662. * @sample {highcharts} highcharts/series/data-array-of-objects/
  663. * Config objects
  664. *
  665. * @type {Array<Array<(number|string),number>|Array<(number|string),number,number>|*>}
  666. * @extends series.line.data
  667. * @excluding marker, y
  668. * @product highcharts highstock
  669. * @apioption series.arearange.data
  670. */
  671. /**
  672. * @extends series.arearange.dataLabels
  673. * @product highcharts highstock
  674. * @apioption series.arearange.data.dataLabels
  675. */
  676. /**
  677. * The high or maximum value for each data point.
  678. *
  679. * @type {number}
  680. * @product highcharts highstock
  681. * @apioption series.arearange.data.high
  682. */
  683. /**
  684. * The low or minimum value for each data point.
  685. *
  686. * @type {number}
  687. * @product highcharts highstock
  688. * @apioption series.arearange.data.low
  689. */
  690. ''; // adds doclets above to tranpiled file
  691. });
  692. _registerModule(_modules, 'Series/DumbbellSeries.js', [_modules['Core/Globals.js'], _modules['Core/Utilities.js']], function (H, U) {
  693. /* *
  694. *
  695. * (c) 2010-2020 Sebastian Bochan, Rafal Sebestjanski
  696. *
  697. * License: www.highcharts.com/license
  698. *
  699. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  700. *
  701. * */
  702. var SVGRenderer = H.SVGRenderer;
  703. var extend = U.extend,
  704. pick = U.pick,
  705. seriesType = U.seriesType;
  706. var seriesTypes = H.seriesTypes,
  707. seriesProto = H.Series.prototype,
  708. areaRangeProto = seriesTypes.arearange.prototype,
  709. columnRangeProto = seriesTypes.columnrange.prototype,
  710. colProto = seriesTypes.column.prototype,
  711. areaRangePointProto = areaRangeProto.pointClass.prototype;
  712. /**
  713. * The dumbbell series is a cartesian series with higher and lower values for
  714. * each point along an X axis, connected with a line between the values.
  715. * Requires `highcharts-more.js` and `modules/dumbbell.js`.
  716. *
  717. * @sample {highcharts} highcharts/demo/dumbbell/
  718. * Dumbbell chart
  719. * @sample {highcharts} highcharts/series-dumbbell/styled-mode-dumbbell/
  720. * Styled mode
  721. *
  722. * @extends plotOptions.arearange
  723. * @product highcharts highstock
  724. * @excluding fillColor, fillOpacity, lineWidth, stack, stacking,
  725. * stickyTracking, trackByArea, boostThreshold, boostBlending
  726. * @since 8.0.0
  727. * @optionparent plotOptions.dumbbell
  728. */
  729. seriesType('dumbbell', 'arearange', {
  730. /** @ignore-option */
  731. trackByArea: false,
  732. /** @ignore-option */
  733. fillColor: 'none',
  734. /** @ignore-option */
  735. lineWidth: 0,
  736. pointRange: 1,
  737. /**
  738. * Pixel width of the line that connects the dumbbell point's values.
  739. *
  740. * @since 8.0.0
  741. * @product highcharts highstock
  742. */
  743. connectorWidth: 1,
  744. /** @ignore-option */
  745. stickyTracking: false,
  746. groupPadding: 0.2,
  747. crisp: false,
  748. pointPadding: 0.1,
  749. /**
  750. * Color of the start markers in a dumbbell graph.
  751. *
  752. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  753. * @since 8.0.0
  754. * @product highcharts highstock
  755. */
  756. lowColor: '#333333',
  757. /**
  758. * Color of the line that connects the dumbbell point's values.
  759. * By default it is the series' color.
  760. *
  761. * @type {string}
  762. * @product highcharts highstock
  763. * @since 8.0.0
  764. * @apioption plotOptions.dumbbell.connectorColor
  765. */
  766. states: {
  767. hover: {
  768. /** @ignore-option */
  769. lineWidthPlus: 0,
  770. /**
  771. * The additional connector line width for a hovered point.
  772. *
  773. * @since 8.0.0
  774. * @product highcharts highstock
  775. */
  776. connectorWidthPlus: 1,
  777. /** @ignore-option */
  778. halo: false
  779. }
  780. }
  781. }, {
  782. trackerGroups: ['group', 'markerGroup', 'dataLabelsGroup'],
  783. drawTracker: H.TrackerMixin.drawTrackerPoint,
  784. drawGraph: H.noop,
  785. crispCol: colProto.crispCol,
  786. /**
  787. * Get connector line path and styles that connects dumbbell point's low and
  788. * high values.
  789. * @private
  790. *
  791. * @param {Highcharts.Series} this The series of points.
  792. * @param {Highcharts.Point} point The point to inspect.
  793. *
  794. * @return {Highcharts.SVGAttributes} attribs The path and styles.
  795. */
  796. getConnectorAttribs: function (point) {
  797. var series = this,
  798. chart = series.chart,
  799. pointOptions = point.options,
  800. seriesOptions = series.options,
  801. xAxis = series.xAxis,
  802. yAxis = series.yAxis,
  803. connectorWidth = pick(pointOptions.connectorWidth,
  804. seriesOptions.connectorWidth),
  805. connectorColor = pick(pointOptions.connectorColor,
  806. seriesOptions.connectorColor,
  807. pointOptions.color,
  808. point.zone ? point.zone.color : void 0,
  809. point.color),
  810. connectorWidthPlus = pick(seriesOptions.states &&
  811. seriesOptions.states.hover &&
  812. seriesOptions.states.hover.connectorWidthPlus, 1),
  813. dashStyle = pick(pointOptions.dashStyle,
  814. seriesOptions.dashStyle),
  815. pointTop = pick(point.plotLow,
  816. point.plotY),
  817. pxThreshold = yAxis.toPixels(seriesOptions.threshold || 0,
  818. true),
  819. pointHeight = chart.inverted ?
  820. yAxis.len - pxThreshold : pxThreshold,
  821. pointBottom = pick(point.plotHigh,
  822. pointHeight),
  823. attribs,
  824. origProps;
  825. if (point.state) {
  826. connectorWidth = connectorWidth + connectorWidthPlus;
  827. }
  828. if (pointTop < 0) {
  829. pointTop = 0;
  830. }
  831. else if (pointTop >= yAxis.len) {
  832. pointTop = yAxis.len;
  833. }
  834. if (pointBottom < 0) {
  835. pointBottom = 0;
  836. }
  837. else if (pointBottom >= yAxis.len) {
  838. pointBottom = yAxis.len;
  839. }
  840. if (point.plotX < 0 || point.plotX > xAxis.len) {
  841. connectorWidth = 0;
  842. }
  843. // Connector should reflect upper marker's zone color
  844. if (point.upperGraphic) {
  845. origProps = {
  846. y: point.y,
  847. zone: point.zone
  848. };
  849. point.y = point.high;
  850. point.zone = point.zone ? point.getZone() : void 0;
  851. connectorColor = pick(pointOptions.connectorColor, seriesOptions.connectorColor, pointOptions.color, point.zone ? point.zone.color : void 0, point.color);
  852. extend(point, origProps);
  853. }
  854. attribs = {
  855. d: SVGRenderer.prototype.crispLine([[
  856. 'M',
  857. point.plotX,
  858. pointTop
  859. ], [
  860. 'L',
  861. point.plotX,
  862. pointBottom
  863. ]], connectorWidth, 'ceil')
  864. };
  865. if (!chart.styledMode) {
  866. attribs.stroke = connectorColor;
  867. attribs['stroke-width'] = connectorWidth;
  868. if (dashStyle) {
  869. attribs.dashstyle = dashStyle;
  870. }
  871. }
  872. return attribs;
  873. },
  874. /**
  875. * Draw connector line that connects dumbbell point's low and high values.
  876. * @private
  877. *
  878. * @param {Highcharts.Series} this The series of points.
  879. * @param {Highcharts.Point} point The point to inspect.
  880. *
  881. * @return {void}
  882. */
  883. drawConnector: function (point) {
  884. var series = this,
  885. animationLimit = pick(series.options.animationLimit, 250),
  886. verb = point.connector && series.chart.pointCount < animationLimit ?
  887. 'animate' : 'attr';
  888. if (!point.connector) {
  889. point.connector = series.chart.renderer.path()
  890. .addClass('highcharts-lollipop-stem')
  891. .attr({
  892. zIndex: -1
  893. })
  894. .add(series.markerGroup);
  895. }
  896. point.connector[verb](this.getConnectorAttribs(point));
  897. },
  898. /**
  899. * Return the width and x offset of the dumbbell adjusted for grouping,
  900. * groupPadding, pointPadding, pointWidth etc.
  901. *
  902. * @private
  903. *
  904. * @function Highcharts.seriesTypes.column#getColumnMetrics
  905. *
  906. * @param {Highcharts.Series} this The series of points.
  907. *
  908. * @return {Highcharts.ColumnMetricsObject} metrics shapeArgs
  909. *
  910. */
  911. getColumnMetrics: function () {
  912. var metrics = colProto.getColumnMetrics.apply(this,
  913. arguments);
  914. metrics.offset += metrics.width / 2;
  915. return metrics;
  916. },
  917. translatePoint: areaRangeProto.translate,
  918. setShapeArgs: columnRangeProto.translate,
  919. /**
  920. * Translate each point to the plot area coordinate system and find
  921. * shape positions
  922. *
  923. * @private
  924. *
  925. * @function Highcharts.seriesTypes.dumbbell#translate
  926. *
  927. * @param {Highcharts.Series} this The series of points.
  928. *
  929. * @return {void}
  930. */
  931. translate: function () {
  932. // Calculate shapeargs
  933. this.setShapeArgs.apply(this);
  934. // Calculate point low / high values
  935. this.translatePoint.apply(this, arguments);
  936. // Correct x position
  937. this.points.forEach(function (point) {
  938. var shapeArgs = point.shapeArgs,
  939. pointWidth = point.pointWidth;
  940. point.plotX = shapeArgs.x;
  941. shapeArgs.x = point.plotX - pointWidth / 2;
  942. point.tooltipPos = null;
  943. });
  944. this.columnMetrics.offset -= this.columnMetrics.width / 2;
  945. },
  946. seriesDrawPoints: areaRangeProto.drawPoints,
  947. /**
  948. * Extend the arearange series' drawPoints method by applying a connector
  949. * and coloring markers.
  950. * @private
  951. *
  952. * @function Highcharts.Series#drawPoints
  953. *
  954. * @param {Highcharts.Series} this The series of points.
  955. *
  956. * @return {void}
  957. */
  958. drawPoints: function () {
  959. var series = this,
  960. chart = series.chart,
  961. pointLength = series.points.length,
  962. seriesLowColor = series.lowColor = series.options.lowColor,
  963. i = 0,
  964. lowerGraphicColor,
  965. point,
  966. zoneColor;
  967. this.seriesDrawPoints.apply(series, arguments);
  968. // Draw connectors and color upper markers
  969. while (i < pointLength) {
  970. point = series.points[i];
  971. series.drawConnector(point);
  972. if (point.upperGraphic) {
  973. point.upperGraphic.element.point = point;
  974. point.upperGraphic.addClass('highcharts-lollipop-high');
  975. }
  976. point.connector.element.point = point;
  977. if (point.lowerGraphic) {
  978. zoneColor = point.zone && point.zone.color;
  979. lowerGraphicColor = pick(point.options.lowColor, seriesLowColor, point.options.color, zoneColor, point.color, series.color);
  980. if (!chart.styledMode) {
  981. point.lowerGraphic.attr({
  982. fill: lowerGraphicColor
  983. });
  984. }
  985. point.lowerGraphic.addClass('highcharts-lollipop-low');
  986. }
  987. i++;
  988. }
  989. },
  990. /**
  991. * Get non-presentational attributes for a point. Used internally for
  992. * both styled mode and classic. Set correct position in link with connector
  993. * line.
  994. *
  995. * @see Series#pointAttribs
  996. *
  997. * @function Highcharts.Series#markerAttribs
  998. *
  999. * @param {Highcharts.Series} this The series of points.
  1000. *
  1001. * @return {Highcharts.SVGAttributes}
  1002. * A hash containing those attributes that are not settable from
  1003. * CSS.
  1004. */
  1005. markerAttribs: function () {
  1006. var ret = areaRangeProto.markerAttribs.apply(this,
  1007. arguments);
  1008. ret.x = Math.floor(ret.x);
  1009. ret.y = Math.floor(ret.y);
  1010. return ret;
  1011. },
  1012. /**
  1013. * Get presentational attributes
  1014. *
  1015. * @private
  1016. * @function Highcharts.seriesTypes.column#pointAttribs
  1017. *
  1018. * @param {Highcharts.Series} this The series of points.
  1019. * @param {Highcharts.Point} point The point to inspect.
  1020. * @param {string} state current state of point (normal, hover, select)
  1021. *
  1022. * @return {Highcharts.SVGAttributes} pointAttribs SVGAttributes
  1023. */
  1024. pointAttribs: function (point, state) {
  1025. var pointAttribs;
  1026. pointAttribs = seriesProto.pointAttribs.apply(this, arguments);
  1027. if (state === 'hover') {
  1028. delete pointAttribs.fill;
  1029. }
  1030. return pointAttribs;
  1031. }
  1032. }, {
  1033. // seriesTypes doesn't inherit from arearange point proto so put below
  1034. // methods rigidly.
  1035. destroyElements: areaRangePointProto.destroyElements,
  1036. isValid: areaRangePointProto.isValid,
  1037. pointSetState: areaRangePointProto.setState,
  1038. /**
  1039. * Set the point's state extended by have influence on the connector
  1040. * (between low and high value).
  1041. *
  1042. * @private
  1043. * @param {Highcharts.Point} this The point to inspect.
  1044. *
  1045. * @return {void}
  1046. */
  1047. setState: function () {
  1048. var point = this,
  1049. series = point.series,
  1050. chart = series.chart,
  1051. seriesLowColor = series.options.lowColor,
  1052. seriesMarker = series.options.marker,
  1053. pointOptions = point.options,
  1054. pointLowColor = pointOptions.lowColor,
  1055. zoneColor = point.zone && point.zone.color,
  1056. lowerGraphicColor = pick(pointLowColor,
  1057. seriesLowColor,
  1058. pointOptions.color,
  1059. zoneColor,
  1060. point.color,
  1061. series.color),
  1062. verb = 'attr',
  1063. upperGraphicColor,
  1064. origProps;
  1065. this.pointSetState.apply(this, arguments);
  1066. if (!point.state) {
  1067. verb = 'animate';
  1068. if (point.lowerGraphic && !chart.styledMode) {
  1069. point.lowerGraphic.attr({
  1070. fill: lowerGraphicColor
  1071. });
  1072. if (point.upperGraphic) {
  1073. origProps = {
  1074. y: point.y,
  1075. zone: point.zone
  1076. };
  1077. point.y = point.high;
  1078. point.zone = point.zone ? point.getZone() : void 0;
  1079. upperGraphicColor = pick(point.marker ? point.marker.fillColor : void 0, seriesMarker ? seriesMarker.fillColor : void 0, pointOptions.color, point.zone ? point.zone.color : void 0, point.color);
  1080. point.upperGraphic.attr({
  1081. fill: upperGraphicColor
  1082. });
  1083. extend(point, origProps);
  1084. }
  1085. }
  1086. }
  1087. point.connector[verb](series.getConnectorAttribs(point));
  1088. }
  1089. });
  1090. /**
  1091. * The `dumbbell` series. If the [type](#series.dumbbell.type) option is
  1092. * not specified, it is inherited from [chart.type](#chart.type).
  1093. *
  1094. * @extends series,plotOptions.dumbbell
  1095. * @excluding boostThreshold, boostBlending
  1096. * @product highcharts highstock
  1097. * @requires highcharts-more
  1098. * @requires modules/dumbbell
  1099. * @apioption series.dumbbell
  1100. */
  1101. /**
  1102. * An array of data points for the series. For the `dumbbell` series
  1103. * type, points can be given in the following ways:
  1104. *
  1105. * 1. An array of arrays with 3 or 2 values. In this case, the values correspond
  1106. * to `x,low,high`. If the first value is a string, it is applied as the name
  1107. * of the point, and the `x` value is inferred. The `x` value can also be
  1108. * omitted, in which case the inner arrays should be of length 2\. Then the
  1109. * `x` value is automatically calculated, either starting at 0 and
  1110. * incremented by 1, or from `pointStart` and `pointInterval` given in the
  1111. * series options.
  1112. * ```js
  1113. * data: [
  1114. * [0, 4, 2],
  1115. * [1, 2, 1],
  1116. * [2, 9, 10]
  1117. * ]
  1118. * ```
  1119. *
  1120. * 2. An array of objects with named values. The following snippet shows only a
  1121. * few settings, see the complete options set below. If the total number of
  1122. * data points exceeds the series'
  1123. * [turboThreshold](#series.dumbbell.turboThreshold), this option is not
  1124. * available.
  1125. * ```js
  1126. * data: [{
  1127. * x: 1,
  1128. * low: 0,
  1129. * high: 4,
  1130. * name: "Point2",
  1131. * color: "#00FF00",
  1132. * lowColor: "#00FFFF",
  1133. * connectorWidth: 3,
  1134. * connectorColor: "#FF00FF"
  1135. * }, {
  1136. * x: 1,
  1137. * low: 5,
  1138. * high: 3,
  1139. * name: "Point1",
  1140. * color: "#FF00FF"
  1141. * }]
  1142. * ```
  1143. *
  1144. * @sample {highcharts} highcharts/series/data-array-of-arrays/
  1145. * Arrays of numeric x and y
  1146. * @sample {highcharts} highcharts/series/data-array-of-arrays-datetime/
  1147. * Arrays of datetime x and y
  1148. * @sample {highcharts} highcharts/series/data-array-of-name-value/
  1149. * Arrays of point.name and y
  1150. * @sample {highcharts} highcharts/series/data-array-of-objects/
  1151. * Config objects
  1152. *
  1153. * @type {Array<Array<(number|string),number>|Array<(number|string),number,number>|*>}
  1154. * @extends series.arearange.data
  1155. * @product highcharts highstock
  1156. * @apioption series.dumbbell.data
  1157. */
  1158. /**
  1159. * Color of the line that connects the dumbbell point's values.
  1160. * By default it is the series' color.
  1161. *
  1162. * @type {string}
  1163. * @since 8.0.0
  1164. * @product highcharts highstock
  1165. * @apioption series.dumbbell.data.connectorColor
  1166. */
  1167. /**
  1168. * Pixel width of the line that connects the dumbbell point's values.
  1169. *
  1170. * @type {number}
  1171. * @since 8.0.0
  1172. * @default 1
  1173. * @product highcharts highstock
  1174. * @apioption series.dumbbell.data.connectorWidth
  1175. */
  1176. /**
  1177. * Color of the start markers in a dumbbell graph.
  1178. *
  1179. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  1180. * @since 8.0.0
  1181. * @default #333333
  1182. * @product highcharts highstock
  1183. * @apioption series.dumbbell.data.lowColor
  1184. */
  1185. ''; // adds doclets above to transpiled file
  1186. });
  1187. _registerModule(_modules, 'masters/modules/dumbbell.src.js', [], function () {
  1188. });
  1189. }));