PolygonSeries.js 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144
  1. /* *
  2. *
  3. * (c) 2010-2020 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. import H from '../Core/Globals.js';
  12. import LegendSymbolMixin from '../Mixins/LegendSymbol.js';
  13. import U from '../Core/Utilities.js';
  14. var seriesType = U.seriesType;
  15. import '../Core/Options.js';
  16. import '../Core/Legend.js';
  17. import '../Series/ScatterSeries.js';
  18. var noop = H.noop, Series = H.Series, seriesTypes = H.seriesTypes;
  19. /**
  20. * A polygon series can be used to draw any freeform shape in the cartesian
  21. * coordinate system. A fill is applied with the `color` option, and
  22. * stroke is applied through `lineWidth` and `lineColor` options.
  23. *
  24. * @sample {highcharts} highcharts/demo/polygon/
  25. * Polygon
  26. * @sample {highstock} highcharts/demo/polygon/
  27. * Polygon
  28. *
  29. * @extends plotOptions.scatter
  30. * @since 4.1.0
  31. * @excluding jitter, softThreshold, threshold, cluster, boostThreshold,
  32. * boostBlending
  33. * @product highcharts highstock
  34. * @requires highcharts-more
  35. * @optionparent plotOptions.polygon
  36. */
  37. seriesType('polygon', 'scatter', {
  38. marker: {
  39. enabled: false,
  40. states: {
  41. hover: {
  42. enabled: false
  43. }
  44. }
  45. },
  46. stickyTracking: false,
  47. tooltip: {
  48. followPointer: true,
  49. pointFormat: ''
  50. },
  51. trackByArea: true
  52. // Prototype members
  53. }, {
  54. type: 'polygon',
  55. getGraphPath: function () {
  56. var graphPath = Series.prototype.getGraphPath.call(this), i = graphPath.length + 1;
  57. // Close all segments
  58. while (i--) {
  59. if ((i === graphPath.length || graphPath[i][0] === 'M') && i > 0) {
  60. graphPath.splice(i, 0, ['Z']);
  61. }
  62. }
  63. this.areaPath = graphPath;
  64. return graphPath;
  65. },
  66. drawGraph: function () {
  67. // Hack into the fill logic in area.drawGraph
  68. this.options.fillColor = this.color;
  69. seriesTypes.area.prototype.drawGraph.call(this);
  70. },
  71. drawLegendSymbol: LegendSymbolMixin.drawRectangle,
  72. drawTracker: Series.prototype.drawTracker,
  73. setStackedPoints: noop // No stacking points on polygons (#5310)
  74. });
  75. /**
  76. * A `polygon` series. If the [type](#series.polygon.type) option is
  77. * not specified, it is inherited from [chart.type](#chart.type).
  78. *
  79. * @extends series,plotOptions.polygon
  80. * @excluding dataParser, dataURL, stack, boostThreshold, boostBlending
  81. * @product highcharts highstock
  82. * @requires highcharts-more
  83. * @apioption series.polygon
  84. */
  85. /**
  86. * An array of data points for the series. For the `polygon` series
  87. * type, points can be given in the following ways:
  88. *
  89. * 1. An array of numerical values. In this case, the numerical values will be
  90. * interpreted as `y` options. The `x` values will be automatically
  91. * calculated, either starting at 0 and incremented by 1, or from
  92. * `pointStart` and `pointInterval` given in the series options. If the axis
  93. * has categories, these will be used. Example:
  94. * ```js
  95. * data: [0, 5, 3, 5]
  96. * ```
  97. *
  98. * 2. An array of arrays with 2 values. In this case, the values correspond to
  99. * `x,y`. If the first value is a string, it is applied as the name of the
  100. * point, and the `x` value is inferred.
  101. * ```js
  102. * data: [
  103. * [0, 10],
  104. * [1, 3],
  105. * [2, 1]
  106. * ]
  107. * ```
  108. *
  109. * 3. An array of objects with named values. The following snippet shows only a
  110. * few settings, see the complete options set below. If the total number of
  111. * data points exceeds the series'
  112. * [turboThreshold](#series.polygon.turboThreshold), this option is not
  113. * available.
  114. * ```js
  115. * data: [{
  116. * x: 1,
  117. * y: 1,
  118. * name: "Point2",
  119. * color: "#00FF00"
  120. * }, {
  121. * x: 1,
  122. * y: 8,
  123. * name: "Point1",
  124. * color: "#FF00FF"
  125. * }]
  126. * ```
  127. *
  128. * @sample {highcharts} highcharts/chart/reflow-true/
  129. * Numerical values
  130. * @sample {highcharts} highcharts/series/data-array-of-arrays/
  131. * Arrays of numeric x and y
  132. * @sample {highcharts} highcharts/series/data-array-of-arrays-datetime/
  133. * Arrays of datetime x and y
  134. * @sample {highcharts} highcharts/series/data-array-of-name-value/
  135. * Arrays of point.name and y
  136. * @sample {highcharts} highcharts/series/data-array-of-objects/
  137. * Config objects
  138. *
  139. * @type {Array<number|Array<(number|string),(number|null)>|null|*>}
  140. * @extends series.line.data
  141. * @product highcharts highstock
  142. * @apioption series.polygon.data
  143. */
  144. ''; // adds doclets above to transpiled file