lollipop.src.js 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159
  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 '../parts/Globals.js';
  12. import U from '../parts/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. * @product highcharts highstock
  85. * @requires highcharts-more
  86. * @requires modules/dumbbell
  87. * @requires modules/lollipop
  88. * @apioption series.lollipop
  89. */
  90. /**
  91. * An array of data points for the series. For the `lollipop` series type,
  92. * points can be given in the following ways:
  93. *
  94. * 1. An array of numerical values. In this case, the numerical values will be
  95. * interpreted as `y` options. The `x` values will be automatically
  96. * calculated, either starting at 0 and incremented by 1, or from
  97. * `pointStart` and `pointInterval` given in the series options. If the axis
  98. * has categories, these will be used. Example:
  99. * ```js
  100. * data: [0, 5, 3, 5]
  101. * ```
  102. *
  103. * 2. An array of arrays with 2 values. In this case, the values correspond to
  104. * `x,y`. If the first value is a string, it is applied as the name of the
  105. * point, and the `x` value is inferred.
  106. * ```js
  107. * data: [
  108. * [0, 6],
  109. * [1, 2],
  110. * [2, 6]
  111. * ]
  112. * ```
  113. *
  114. * 3. An array of objects with named values. The following snippet shows only a
  115. * few settings, see the complete options set below. If the total number of
  116. * data points exceeds the series'
  117. * [turboThreshold](#series.lollipop.turboThreshold), this option is not
  118. * available.
  119. * ```js
  120. * data: [{
  121. * x: 1,
  122. * y: 9,
  123. * name: "Point2",
  124. * color: "#00FF00",
  125. * connectorWidth: 3,
  126. * connectorColor: "#FF00FF"
  127. * }, {
  128. * x: 1,
  129. * y: 6,
  130. * name: "Point1",
  131. * color: "#FF00FF"
  132. * }]
  133. * ```
  134. *
  135. * @sample {highcharts} highcharts/chart/reflow-true/
  136. * Numerical values
  137. * @sample {highcharts} highcharts/series/data-array-of-arrays/
  138. * Arrays of numeric x and y
  139. * @sample {highcharts} highcharts/series/data-array-of-arrays-datetime/
  140. * Arrays of datetime x and y
  141. * @sample {highcharts} highcharts/series/data-array-of-name-value/
  142. * Arrays of point.name and y
  143. * @sample {highcharts} highcharts/series/data-array-of-objects/
  144. * Config objects
  145. *
  146. * @type {Array<number|Array<(number|string),(number|null)>|null|*>}
  147. * @extends series.dumbbell.data
  148. * @excluding high, low, lowColor
  149. * @product highcharts highstock
  150. * @apioption series.lollipop.data
  151. */
  152. /**
  153. * The y value of the point.
  154. *
  155. * @type {number|null}
  156. * @product highcharts highstock
  157. * @apioption series.line.data.y
  158. */
  159. ''; // adds doclets above to transpiled file