LollipopSeries.js 5.0 KB

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