LollipopSeries.js 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164
  1. /* *
  2. *
  3. * (c) 2010-2020 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. import Point from '../Core/Series/Point.js';
  11. import BaseSeries from '../Core/Series/Series.js';
  12. import H from '../Core/Globals.js';
  13. import './AreaSeries.js';
  14. import './ColumnSeries.js';
  15. import './DumbbellSeries.js';
  16. import U from '../Core/Utilities.js';
  17. var isObject = U.isObject, pick = U.pick;
  18. var seriesTypes = BaseSeries.seriesTypes, areaProto = seriesTypes.area.prototype, colProto = seriesTypes.column.prototype;
  19. /**
  20. * The lollipop series is a carteseian series with a line anchored from
  21. * the x axis and a dot at the end to mark the value.
  22. * Requires `highcharts-more.js`, `modules/dumbbell.js` and
  23. * `modules/lollipop.js`.
  24. *
  25. * @sample {highcharts} highcharts/demo/lollipop/
  26. * Lollipop chart
  27. * @sample {highcharts} highcharts/series-dumbbell/styled-mode-dumbbell/
  28. * Styled mode
  29. *
  30. * @extends plotOptions.dumbbell
  31. * @product highcharts highstock
  32. * @excluding fillColor, fillOpacity, lineWidth, stack, stacking, lowColor,
  33. * stickyTracking, trackByArea
  34. * @since 8.0.0
  35. * @optionparent plotOptions.lollipop
  36. */
  37. BaseSeries.seriesType('lollipop', 'dumbbell', {
  38. /** @ignore-option */
  39. lowColor: void 0,
  40. /** @ignore-option */
  41. threshold: 0,
  42. /** @ignore-option */
  43. connectorWidth: 1,
  44. /** @ignore-option */
  45. groupPadding: 0.2,
  46. /** @ignore-option */
  47. pointPadding: 0.1,
  48. /** @ignore-option */
  49. states: {
  50. hover: {
  51. /** @ignore-option */
  52. lineWidthPlus: 0,
  53. /** @ignore-option */
  54. connectorWidthPlus: 1,
  55. /** @ignore-option */
  56. halo: false
  57. }
  58. },
  59. tooltip: {
  60. pointFormat: '<span style="color:{series.color}">●</span> {series.name}: <b>{point.y}</b><br/>'
  61. }
  62. }, {
  63. pointArrayMap: ['y'],
  64. pointValKey: 'y',
  65. toYData: function (point) {
  66. return [pick(point.y, point.low)];
  67. },
  68. translatePoint: areaProto.translate,
  69. drawPoint: areaProto.drawPoints,
  70. drawDataLabels: colProto.drawDataLabels,
  71. setShapeArgs: colProto.translate
  72. }, {
  73. pointSetState: areaProto.pointClass.prototype.setState,
  74. setState: H.seriesTypes.dumbbell.prototype.pointClass.prototype.setState,
  75. init: function (series, options, x) {
  76. if (isObject(options) && 'low' in options) {
  77. options.y = options.low;
  78. delete options.low;
  79. }
  80. return Point.prototype.init.apply(this, arguments);
  81. }
  82. });
  83. /**
  84. * The `lollipop` series. If the [type](#series.lollipop.type) option is
  85. * not specified, it is inherited from [chart.type](#chart.type).
  86. *
  87. * @extends series,plotOptions.lollipop,
  88. * @excluding boostThreshold, boostBlending
  89. * @product highcharts highstock
  90. * @requires highcharts-more
  91. * @requires modules/dumbbell
  92. * @requires modules/lollipop
  93. * @apioption series.lollipop
  94. */
  95. /**
  96. * An array of data points for the series. For the `lollipop` series type,
  97. * points can be given in the following ways:
  98. *
  99. * 1. An array of numerical values. In this case, the numerical values will be
  100. * interpreted as `y` options. The `x` values will be automatically
  101. * calculated, either starting at 0 and incremented by 1, or from
  102. * `pointStart` and `pointInterval` given in the series options. If the axis
  103. * has categories, these will be used. Example:
  104. * ```js
  105. * data: [0, 5, 3, 5]
  106. * ```
  107. *
  108. * 2. An array of arrays with 2 values. In this case, the values correspond to
  109. * `x,y`. If the first value is a string, it is applied as the name of the
  110. * point, and the `x` value is inferred.
  111. * ```js
  112. * data: [
  113. * [0, 6],
  114. * [1, 2],
  115. * [2, 6]
  116. * ]
  117. * ```
  118. *
  119. * 3. An array of objects with named values. The following snippet shows only a
  120. * few settings, see the complete options set below. If the total number of
  121. * data points exceeds the series'
  122. * [turboThreshold](#series.lollipop.turboThreshold), this option is not
  123. * available.
  124. * ```js
  125. * data: [{
  126. * x: 1,
  127. * y: 9,
  128. * name: "Point2",
  129. * color: "#00FF00",
  130. * connectorWidth: 3,
  131. * connectorColor: "#FF00FF"
  132. * }, {
  133. * x: 1,
  134. * y: 6,
  135. * name: "Point1",
  136. * color: "#FF00FF"
  137. * }]
  138. * ```
  139. *
  140. * @sample {highcharts} highcharts/chart/reflow-true/
  141. * Numerical values
  142. * @sample {highcharts} highcharts/series/data-array-of-arrays/
  143. * Arrays of numeric x and y
  144. * @sample {highcharts} highcharts/series/data-array-of-arrays-datetime/
  145. * Arrays of datetime x and y
  146. * @sample {highcharts} highcharts/series/data-array-of-name-value/
  147. * Arrays of point.name and y
  148. * @sample {highcharts} highcharts/series/data-array-of-objects/
  149. * Config objects
  150. *
  151. * @type {Array<number|Array<(number|string),(number|null)>|null|*>}
  152. * @extends series.dumbbell.data
  153. * @excluding high, low, lowColor
  154. * @product highcharts highstock
  155. * @apioption series.lollipop.data
  156. */
  157. /**
  158. * The y value of the point.
  159. *
  160. * @type {number|null}
  161. * @product highcharts highstock
  162. * @apioption series.line.data.y
  163. */
  164. ''; // adds doclets above to transpiled file