LollipopSeries.js 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209
  1. /* *
  2. *
  3. * (c) 2010-2021 Sebastian Bochan, Rafal Sebestjanski
  4. *
  5. * License: www.highcharts.com/license
  6. *
  7. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  8. *
  9. * */
  10. 'use strict';
  11. var __extends = (this && this.__extends) || (function () {
  12. var extendStatics = function (d, b) {
  13. extendStatics = Object.setPrototypeOf ||
  14. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  15. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  16. return extendStatics(d, b);
  17. };
  18. return function (d, b) {
  19. extendStatics(d, b);
  20. function __() { this.constructor = d; }
  21. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  22. };
  23. })();
  24. import LollipopPoint from './LollipopPoint.js';
  25. import SeriesRegistry from '../../Core/Series/SeriesRegistry.js';
  26. var _a = SeriesRegistry.seriesTypes, areaProto = _a.area.prototype, colProto = _a.column.prototype, DumbbellSeries = _a.dumbbell;
  27. import U from '../../Core/Utilities.js';
  28. var pick = U.pick, merge = U.merge, extend = U.extend;
  29. /* *
  30. *
  31. * Class
  32. *
  33. * */
  34. /**
  35. * lollipop series type
  36. *
  37. * @private
  38. * @class
  39. * @name Highcharts.seriesTypes.lollipop
  40. *
  41. * @augments Highcharts.Series
  42. *
  43. */
  44. var LollipopSeries = /** @class */ (function (_super) {
  45. __extends(LollipopSeries, _super);
  46. function LollipopSeries() {
  47. /* *
  48. *
  49. * Static properties
  50. *
  51. * */
  52. var _this = _super !== null && _super.apply(this, arguments) || this;
  53. /* *
  54. *
  55. * Properties
  56. *
  57. * */
  58. _this.data = void 0;
  59. _this.options = void 0;
  60. _this.points = void 0;
  61. return _this;
  62. }
  63. LollipopSeries.prototype.toYData = function (point) {
  64. return [pick(point.y, point.low)];
  65. };
  66. /**
  67. * The lollipop series is a carteseian series with a line anchored from
  68. * the x axis and a dot at the end to mark the value.
  69. * Requires `highcharts-more.js`, `modules/dumbbell.js` and
  70. * `modules/lollipop.js`.
  71. *
  72. * @sample {highcharts} highcharts/demo/lollipop/
  73. * Lollipop chart
  74. * @sample {highcharts} highcharts/series-dumbbell/styled-mode-dumbbell/
  75. * Styled mode
  76. *
  77. * @extends plotOptions.dumbbell
  78. * @product highcharts highstock
  79. * @excluding fillColor, fillOpacity, lineWidth, stack, stacking,
  80. * lowColor, stickyTracking, trackByArea
  81. * @since 8.0.0
  82. * @optionparent plotOptions.lollipop
  83. */
  84. LollipopSeries.defaultOptions = merge(DumbbellSeries.defaultOptions, {
  85. /** @ignore-option */
  86. lowColor: void 0,
  87. /** @ignore-option */
  88. threshold: 0,
  89. /** @ignore-option */
  90. connectorWidth: 1,
  91. /** @ignore-option */
  92. groupPadding: 0.2,
  93. /** @ignore-option */
  94. pointPadding: 0.1,
  95. /** @ignore-option */
  96. states: {
  97. hover: {
  98. /** @ignore-option */
  99. lineWidthPlus: 0,
  100. /** @ignore-option */
  101. connectorWidthPlus: 1,
  102. /** @ignore-option */
  103. halo: false
  104. }
  105. },
  106. tooltip: {
  107. pointFormat: '<span style="color:{series.color}">●</span> {series.name}: <b>{point.y}</b><br/>'
  108. }
  109. });
  110. return LollipopSeries;
  111. }(DumbbellSeries));
  112. extend(LollipopSeries.prototype, {
  113. pointArrayMap: ['y'],
  114. pointValKey: 'y',
  115. translatePoint: areaProto.translate,
  116. drawPoint: areaProto.drawPoints,
  117. drawDataLabels: colProto.drawDataLabels,
  118. setShapeArgs: colProto.translate,
  119. pointClass: LollipopPoint
  120. });
  121. SeriesRegistry.registerSeriesType('lollipop', LollipopSeries);
  122. /* *
  123. *
  124. * Default export
  125. *
  126. * */
  127. export default LollipopSeries;
  128. /**
  129. * The `lollipop` series. If the [type](#series.lollipop.type) option is
  130. * not specified, it is inherited from [chart.type](#chart.type).
  131. *
  132. * @extends series,plotOptions.lollipop,
  133. * @excluding boostThreshold, boostBlending
  134. * @product highcharts highstock
  135. * @requires highcharts-more
  136. * @requires modules/dumbbell
  137. * @requires modules/lollipop
  138. * @apioption series.lollipop
  139. */
  140. /**
  141. * An array of data points for the series. For the `lollipop` series type,
  142. * points can be given in the following ways:
  143. *
  144. * 1. An array of numerical values. In this case, the numerical values will be
  145. * interpreted as `y` options. The `x` values will be automatically
  146. * calculated, either starting at 0 and incremented by 1, or from
  147. * `pointStart` and `pointInterval` given in the series options. If the axis
  148. * has categories, these will be used. Example:
  149. * ```js
  150. * data: [0, 5, 3, 5]
  151. * ```
  152. *
  153. * 2. An array of arrays with 2 values. In this case, the values correspond to
  154. * `x,y`. If the first value is a string, it is applied as the name of the
  155. * point, and the `x` value is inferred.
  156. * ```js
  157. * data: [
  158. * [0, 6],
  159. * [1, 2],
  160. * [2, 6]
  161. * ]
  162. * ```
  163. *
  164. * 3. An array of objects with named values. The following snippet shows only a
  165. * few settings, see the complete options set below. If the total number of
  166. * data points exceeds the series'
  167. * [turboThreshold](#series.lollipop.turboThreshold), this option is not
  168. * available.
  169. * ```js
  170. * data: [{
  171. * x: 1,
  172. * y: 9,
  173. * name: "Point2",
  174. * color: "#00FF00",
  175. * connectorWidth: 3,
  176. * connectorColor: "#FF00FF"
  177. * }, {
  178. * x: 1,
  179. * y: 6,
  180. * name: "Point1",
  181. * color: "#FF00FF"
  182. * }]
  183. * ```
  184. *
  185. * @sample {highcharts} highcharts/chart/reflow-true/
  186. * Numerical values
  187. * @sample {highcharts} highcharts/series/data-array-of-arrays/
  188. * Arrays of numeric x and y
  189. * @sample {highcharts} highcharts/series/data-array-of-arrays-datetime/
  190. * Arrays of datetime x and y
  191. * @sample {highcharts} highcharts/series/data-array-of-name-value/
  192. * Arrays of point.name and y
  193. * @sample {highcharts} highcharts/series/data-array-of-objects/
  194. * Config objects
  195. *
  196. * @type {Array<number|Array<(number|string),(number|null)>|null|*>}
  197. * @extends series.dumbbell.data
  198. * @excluding high, low, lowColor
  199. * @product highcharts highstock
  200. * @apioption series.lollipop.data
  201. */
  202. /**
  203. * The y value of the point.
  204. *
  205. * @type {number|null}
  206. * @product highcharts highstock
  207. * @apioption series.line.data.y
  208. */
  209. ''; // adds doclets above to transpiled file