streamgraph.src.js 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  1. /* *
  2. * Streamgraph module
  3. *
  4. * (c) 2010-2019 Torstein Honsi
  5. *
  6. * License: www.highcharts.com/license
  7. */
  8. 'use strict';
  9. import H from '../parts/Globals.js';
  10. import '../parts/AreaSeries.js';
  11. var seriesType = H.seriesType;
  12. /**
  13. * @private
  14. * @class
  15. * @name Highcharts.seriesTypes.streamgraph
  16. *
  17. * @augments Highcharts.Series
  18. */
  19. seriesType('streamgraph', 'areaspline'
  20. /**
  21. * A streamgraph is a type of stacked area graph which is displaced around a
  22. * central axis, resulting in a flowing, organic shape.
  23. *
  24. * @sample {highcharts|highstock} highcharts/demo/streamgraph/
  25. * Streamgraph
  26. *
  27. * @extends plotOptions.areaspline
  28. * @since 6.0.0
  29. * @product highcharts highstock
  30. * @optionparent plotOptions.streamgraph
  31. */
  32. , {
  33. fillOpacity: 1,
  34. lineWidth: 0,
  35. marker: {
  36. enabled: false
  37. },
  38. stacking: 'stream'
  39. // Prototype functions
  40. }, {
  41. negStacks: false,
  42. // Modifier function for stream stacks. It simply moves the point up or
  43. // down in order to center the full stack vertically.
  44. streamStacker: function (pointExtremes, stack, i) {
  45. // Y bottom value
  46. pointExtremes[0] -= stack.total / 2;
  47. // Y value
  48. pointExtremes[1] -= stack.total / 2;
  49. // Record the Y data for use when getting axis extremes
  50. this.stackedYData[i] = pointExtremes;
  51. }
  52. });
  53. /**
  54. * A `streamgraph` series. If the [type](#series.streamgraph.type) option is not
  55. * specified, it is inherited from [chart.type](#chart.type).
  56. *
  57. * @extends series,plotOptions.streamgraph
  58. * @excluding dataParser, dataURL
  59. * @product highcharts highstock
  60. * @apioption series.streamgraph
  61. */
  62. /**
  63. * An array of data points for the series. For the `streamgraph` series type,
  64. * points can be given in the following ways:
  65. *
  66. * 1. An array of numerical values. In this case, the numerical values
  67. * will be interpreted as `y` options. The `x` values will be automatically
  68. * calculated, either starting at 0 and incremented by 1, or from `pointStart`
  69. * and `pointInterval` given in the series options. If the axis has
  70. * categories, these will be used. Example:
  71. *
  72. * ```js
  73. * data: [0, 5, 3, 5]
  74. * ```
  75. *
  76. * 2. An array of arrays with 2 values. In this case, the values correspond
  77. * to `x,y`. If the first value is a string, it is applied as the name
  78. * of the point, and the `x` value is inferred.
  79. *
  80. * ```js
  81. * data: [
  82. * [0, 9],
  83. * [1, 7],
  84. * [2, 6]
  85. * ]
  86. * ```
  87. *
  88. * 3. An array of objects with named values. The following snippet shows only a
  89. * few settings, see the complete options set below. If the total number of data
  90. * points exceeds the series' [turboThreshold](#series.area.turboThreshold),
  91. * this option is not available.
  92. *
  93. * ```js
  94. * data: [{
  95. * x: 1,
  96. * y: 9,
  97. * name: "Point2",
  98. * color: "#00FF00"
  99. * }, {
  100. * x: 1,
  101. * y: 6,
  102. * name: "Point1",
  103. * color: "#FF00FF"
  104. * }]
  105. * ```
  106. *
  107. * @sample {highcharts} highcharts/chart/reflow-true/
  108. * Numerical values
  109. * @sample {highcharts} highcharts/series/data-array-of-arrays/
  110. * Arrays of numeric x and y
  111. * @sample {highcharts} highcharts/series/data-array-of-arrays-datetime/
  112. * Arrays of datetime x and y
  113. * @sample {highcharts} highcharts/series/data-array-of-name-value/
  114. * Arrays of point.name and y
  115. * @sample {highcharts} highcharts/series/data-array-of-objects/
  116. * Config objects
  117. *
  118. * @type {Array<number|Array<(number|string),number>|*>}
  119. * @extends series.line.data
  120. * @product highcharts highstock
  121. * @apioption series.streamgraph.data
  122. */