StreamgraphSeries.js 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213
  1. /* *
  2. *
  3. * Streamgraph module
  4. *
  5. * (c) 2010-2021 Torstein Honsi
  6. *
  7. * License: www.highcharts.com/license
  8. *
  9. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  10. *
  11. * */
  12. 'use strict';
  13. var __extends = (this && this.__extends) || (function () {
  14. var extendStatics = function (d, b) {
  15. extendStatics = Object.setPrototypeOf ||
  16. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  17. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  18. return extendStatics(d, b);
  19. };
  20. return function (d, b) {
  21. extendStatics(d, b);
  22. function __() { this.constructor = d; }
  23. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  24. };
  25. })();
  26. import SeriesRegistry from '../../Core/Series/SeriesRegistry.js';
  27. var AreaSplineSeries = SeriesRegistry.seriesTypes.areaspline;
  28. import U from '../../Core/Utilities.js';
  29. var merge = U.merge, extend = U.extend;
  30. /**
  31. * Streamgraph series type
  32. *
  33. * @private
  34. * @class
  35. * @name Highcharts.seriesTypes.streamgraph
  36. *
  37. * @augments Highcharts.Series
  38. */
  39. var StreamgraphSeries = /** @class */ (function (_super) {
  40. __extends(StreamgraphSeries, _super);
  41. function StreamgraphSeries() {
  42. var _this = _super !== null && _super.apply(this, arguments) || this;
  43. /* *
  44. *
  45. * Properties
  46. *
  47. * */
  48. _this.data = void 0;
  49. _this.points = void 0;
  50. _this.options = void 0;
  51. return _this;
  52. }
  53. /* *
  54. *
  55. * Functions
  56. *
  57. * */
  58. // Modifier function for stream stacks. It simply moves the point up or
  59. // down in order to center the full stack vertically.
  60. StreamgraphSeries.prototype.streamStacker = function (pointExtremes, stack, i) {
  61. // Y bottom value
  62. pointExtremes[0] -= stack.total / 2;
  63. // Y value
  64. pointExtremes[1] -= stack.total / 2;
  65. // Record the Y data for use when getting axis extremes
  66. this.stackedYData[i] = pointExtremes;
  67. };
  68. /**
  69. * A streamgraph is a type of stacked area graph which is displaced around a
  70. * central axis, resulting in a flowing, organic shape.
  71. *
  72. * @sample {highcharts|highstock} highcharts/demo/streamgraph/
  73. * Streamgraph
  74. *
  75. * @extends plotOptions.areaspline
  76. * @since 6.0.0
  77. * @product highcharts highstock
  78. * @requires modules/streamgraph
  79. * @optionparent plotOptions.streamgraph
  80. */
  81. StreamgraphSeries.defaultOptions = merge(AreaSplineSeries.defaultOptions, {
  82. /**
  83. * @see [fillColor](#plotOptions.streamgraph.fillColor)
  84. * @see [fillOpacity](#plotOptions.streamgraph.fillOpacity)
  85. *
  86. * @apioption plotOptions.streamgraph.color
  87. */
  88. /**
  89. * @see [color](#plotOptions.streamgraph.color)
  90. * @see [fillOpacity](#plotOptions.streamgraph.fillOpacity)
  91. *
  92. * @apioption plotOptions.streamgraph.fillColor
  93. */
  94. /**
  95. * @see [color](#plotOptions.streamgraph.color)
  96. * @see [fillColor](#plotOptions.streamgraph.fillColor)
  97. *
  98. * @apioption plotOptions.streamgraph.fillOpacity
  99. */
  100. fillOpacity: 1,
  101. lineWidth: 0,
  102. marker: {
  103. enabled: false
  104. },
  105. stacking: 'stream'
  106. });
  107. return StreamgraphSeries;
  108. }(AreaSplineSeries));
  109. extend(StreamgraphSeries.prototype, {
  110. negStacks: false
  111. });
  112. SeriesRegistry.registerSeriesType('streamgraph', StreamgraphSeries);
  113. /* *
  114. *
  115. * Default export
  116. *
  117. * */
  118. export default StreamgraphSeries;
  119. /* *
  120. *
  121. * API options
  122. *
  123. * */
  124. /**
  125. * A `streamgraph` series. If the [type](#series.streamgraph.type) option is not
  126. * specified, it is inherited from [chart.type](#chart.type).
  127. *
  128. * @extends series,plotOptions.streamgraph
  129. * @excluding dataParser, dataURL, step, boostThreshold, boostBlending
  130. * @product highcharts highstock
  131. * @requires modules/streamgraph
  132. * @apioption series.streamgraph
  133. */
  134. /**
  135. * @see [fillColor](#series.streamgraph.fillColor)
  136. * @see [fillOpacity](#series.streamgraph.fillOpacity)
  137. *
  138. * @apioption series.streamgraph.color
  139. */
  140. /**
  141. * An array of data points for the series. For the `streamgraph` series type,
  142. * points can be given in the following ways:
  143. *
  144. * 1. An array of numerical values. In this case, the numerical values will be
  145. * interpreted as `y` options. The `x` values will be automatically
  146. * calculated, either starting at 0 and incremented by 1, or from
  147. * `pointStart` and `pointInterval` given in the series options. If the axis
  148. * has categories, these will be used. Example:
  149. * ```js
  150. * data: [0, 5, 3, 5]
  151. * ```
  152. *
  153. * 2. An array of arrays with 2 values. In this case, the values correspond to
  154. * `x,y`. If the first value is a string, it is applied as the name of the
  155. * point, and the `x` value is inferred.
  156. * ```js
  157. * data: [
  158. * [0, 9],
  159. * [1, 7],
  160. * [2, 6]
  161. * ]
  162. * ```
  163. *
  164. * 3. An array of objects with named values. The following snippet shows only a
  165. * few settings, see the complete options set below. If the total number of
  166. * data points exceeds the series'
  167. * [turboThreshold](#series.area.turboThreshold),
  168. * this option is not available.
  169. * ```js
  170. * data: [{
  171. * x: 1,
  172. * y: 9,
  173. * name: "Point2",
  174. * color: "#00FF00"
  175. * }, {
  176. * x: 1,
  177. * y: 6,
  178. * name: "Point1",
  179. * color: "#FF00FF"
  180. * }]
  181. * ```
  182. *
  183. * @sample {highcharts} highcharts/chart/reflow-true/
  184. * Numerical values
  185. * @sample {highcharts} highcharts/series/data-array-of-arrays/
  186. * Arrays of numeric x and y
  187. * @sample {highcharts} highcharts/series/data-array-of-arrays-datetime/
  188. * Arrays of datetime x and y
  189. * @sample {highcharts} highcharts/series/data-array-of-name-value/
  190. * Arrays of point.name and y
  191. * @sample {highcharts} highcharts/series/data-array-of-objects/
  192. * Config objects
  193. *
  194. * @type {Array<number|Array<(number|string),(number|null)>|null|*>}
  195. * @extends series.line.data
  196. * @product highcharts highstock
  197. * @apioption series.streamgraph.data
  198. */
  199. /**
  200. * @see [color](#series.streamgraph.color)
  201. * @see [fillOpacity](#series.streamgraph.fillOpacity)
  202. *
  203. * @apioption series.streamgraph.fillColor
  204. */
  205. /**
  206. * @see [color](#series.streamgraph.color)
  207. * @see [fillColor](#series.streamgraph.fillColor)
  208. *
  209. * @type {number}
  210. * @default 1
  211. * @apioption series.streamgraph.fillOpacity
  212. */
  213. ''; // adds doclets above to transpiled file