PolygonSeries.js 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195
  1. /* *
  2. *
  3. * (c) 2010-2021 Torstein Honsi
  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 H from '../../Core/Globals.js';
  25. var noop = H.noop;
  26. import LegendSymbolMixin from '../../Mixins/LegendSymbol.js';
  27. import SeriesRegistry from '../../Core/Series/SeriesRegistry.js';
  28. var Series = SeriesRegistry.series, _a = SeriesRegistry.seriesTypes, AreaSeries = _a.area, LineSeries = _a.line, ScatterSeries = _a.scatter;
  29. import U from '../../Core/Utilities.js';
  30. var extend = U.extend, merge = U.merge;
  31. import '../../Core/Legend.js';
  32. /* *
  33. *
  34. * Class
  35. *
  36. * */
  37. var PolygonSeries = /** @class */ (function (_super) {
  38. __extends(PolygonSeries, _super);
  39. function PolygonSeries() {
  40. /* *
  41. *
  42. * Static properties
  43. *
  44. * */
  45. var _this = _super !== null && _super.apply(this, arguments) || this;
  46. _this.data = void 0;
  47. _this.options = void 0;
  48. _this.points = void 0;
  49. return _this;
  50. }
  51. /* *
  52. *
  53. * Functions
  54. *
  55. * */
  56. PolygonSeries.prototype.getGraphPath = function () {
  57. var graphPath = LineSeries.prototype.getGraphPath.call(this), i = graphPath.length + 1;
  58. // Close all segments
  59. while (i--) {
  60. if ((i === graphPath.length || graphPath[i][0] === 'M') && i > 0) {
  61. graphPath.splice(i, 0, ['Z']);
  62. }
  63. }
  64. this.areaPath = graphPath;
  65. return graphPath;
  66. };
  67. PolygonSeries.prototype.drawGraph = function () {
  68. // Hack into the fill logic in area.drawGraph
  69. this.options.fillColor = this.color;
  70. AreaSeries.prototype.drawGraph.call(this);
  71. };
  72. /**
  73. * A polygon series can be used to draw any freeform shape in the cartesian
  74. * coordinate system. A fill is applied with the `color` option, and
  75. * stroke is applied through `lineWidth` and `lineColor` options.
  76. *
  77. * @sample {highcharts} highcharts/demo/polygon/
  78. * Polygon
  79. * @sample {highstock} highcharts/demo/polygon/
  80. * Polygon
  81. *
  82. * @extends plotOptions.scatter
  83. * @since 4.1.0
  84. * @excluding jitter, softThreshold, threshold, cluster, boostThreshold,
  85. * boostBlending
  86. * @product highcharts highstock
  87. * @requires highcharts-more
  88. * @optionparent plotOptions.polygon
  89. */
  90. PolygonSeries.defaultOptions = merge(ScatterSeries.defaultOptions, {
  91. marker: {
  92. enabled: false,
  93. states: {
  94. hover: {
  95. enabled: false
  96. }
  97. }
  98. },
  99. stickyTracking: false,
  100. tooltip: {
  101. followPointer: true,
  102. pointFormat: ''
  103. },
  104. trackByArea: true
  105. });
  106. return PolygonSeries;
  107. }(ScatterSeries));
  108. extend(PolygonSeries.prototype, {
  109. type: 'polygon',
  110. drawLegendSymbol: LegendSymbolMixin.drawRectangle,
  111. drawTracker: Series.prototype.drawTracker,
  112. setStackedPoints: noop // No stacking points on polygons (#5310)
  113. });
  114. SeriesRegistry.registerSeriesType('polygon', PolygonSeries);
  115. /* *
  116. *
  117. * Export
  118. *
  119. * */
  120. export default PolygonSeries;
  121. /* *
  122. *
  123. * API Options
  124. *
  125. * */
  126. /**
  127. * A `polygon` series. If the [type](#series.polygon.type) option is
  128. * not specified, it is inherited from [chart.type](#chart.type).
  129. *
  130. * @extends series,plotOptions.polygon
  131. * @excluding dataParser, dataURL, stack, boostThreshold, boostBlending
  132. * @product highcharts highstock
  133. * @requires highcharts-more
  134. * @apioption series.polygon
  135. */
  136. /**
  137. * An array of data points for the series. For the `polygon` series
  138. * type, points can be given in the following ways:
  139. *
  140. * 1. An array of numerical values. In this case, the numerical values will be
  141. * interpreted as `y` options. The `x` values will be automatically
  142. * calculated, either starting at 0 and incremented by 1, or from
  143. * `pointStart` and `pointInterval` given in the series options. If the axis
  144. * has categories, these will be used. Example:
  145. * ```js
  146. * data: [0, 5, 3, 5]
  147. * ```
  148. *
  149. * 2. An array of arrays with 2 values. In this case, the values correspond to
  150. * `x,y`. If the first value is a string, it is applied as the name of the
  151. * point, and the `x` value is inferred.
  152. * ```js
  153. * data: [
  154. * [0, 10],
  155. * [1, 3],
  156. * [2, 1]
  157. * ]
  158. * ```
  159. *
  160. * 3. An array of objects with named values. The following snippet shows only a
  161. * few settings, see the complete options set below. If the total number of
  162. * data points exceeds the series'
  163. * [turboThreshold](#series.polygon.turboThreshold), this option is not
  164. * available.
  165. * ```js
  166. * data: [{
  167. * x: 1,
  168. * y: 1,
  169. * name: "Point2",
  170. * color: "#00FF00"
  171. * }, {
  172. * x: 1,
  173. * y: 8,
  174. * name: "Point1",
  175. * color: "#FF00FF"
  176. * }]
  177. * ```
  178. *
  179. * @sample {highcharts} highcharts/chart/reflow-true/
  180. * Numerical values
  181. * @sample {highcharts} highcharts/series/data-array-of-arrays/
  182. * Arrays of numeric x and y
  183. * @sample {highcharts} highcharts/series/data-array-of-arrays-datetime/
  184. * Arrays of datetime x and y
  185. * @sample {highcharts} highcharts/series/data-array-of-name-value/
  186. * Arrays of point.name and y
  187. * @sample {highcharts} highcharts/series/data-array-of-objects/
  188. * Config objects
  189. *
  190. * @type {Array<number|Array<(number|string),(number|null)>|null|*>}
  191. * @extends series.line.data
  192. * @product highcharts highstock
  193. * @apioption series.polygon.data
  194. */
  195. ''; // adds doclets above to transpiled file