PolygonSeries.js 4.3 KB

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