ErrorBarSeries.js 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166
  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. import BaseSeries from '../Core/Series/Series.js';
  11. import H from '../Core/Globals.js';
  12. import '../Core/Options.js';
  13. import './BoxPlotSeries.js';
  14. var noop = H.noop, seriesTypes = BaseSeries.seriesTypes;
  15. /**
  16. * Error bars are a graphical representation of the variability of data and are
  17. * used on graphs to indicate the error, or uncertainty in a reported
  18. * measurement.
  19. *
  20. * @sample highcharts/demo/error-bar/
  21. * Error bars on a column series
  22. * @sample highcharts/series-errorbar/on-scatter/
  23. * Error bars on a scatter series
  24. *
  25. * @extends plotOptions.boxplot
  26. * @excluding boostBlending, boostThreshold
  27. * @product highcharts highstock
  28. * @requires highcharts-more
  29. * @optionparent plotOptions.errorbar
  30. */
  31. BaseSeries.seriesType('errorbar', 'boxplot', {
  32. /**
  33. * The main color of the bars. This can be overridden by
  34. * [stemColor](#plotOptions.errorbar.stemColor) and
  35. * [whiskerColor](#plotOptions.errorbar.whiskerColor) individually.
  36. *
  37. * @sample {highcharts} highcharts/plotoptions/error-bar-styling/
  38. * Error bar styling
  39. *
  40. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  41. * @default #000000
  42. * @since 3.0
  43. * @product highcharts
  44. */
  45. color: '#000000',
  46. grouping: false,
  47. /**
  48. * The parent series of the error bar. The default value links it to
  49. * the previous series. Otherwise, use the id of the parent series.
  50. *
  51. * @since 3.0
  52. * @product highcharts
  53. */
  54. linkedTo: ':previous',
  55. tooltip: {
  56. pointFormat: '<span style="color:{point.color}">\u25CF</span> {series.name}: <b>{point.low}</b> - <b>{point.high}</b><br/>'
  57. },
  58. /**
  59. * The line width of the whiskers, the horizontal lines marking low
  60. * and high values. When `null`, the general
  61. * [lineWidth](#plotOptions.errorbar.lineWidth) applies.
  62. *
  63. * @sample {highcharts} highcharts/plotoptions/error-bar-styling/
  64. * Error bar styling
  65. *
  66. * @type {number}
  67. * @since 3.0
  68. * @product highcharts
  69. */
  70. whiskerWidth: null
  71. // Prototype members
  72. }, {
  73. type: 'errorbar',
  74. // array point configs are mapped to this
  75. pointArrayMap: ['low', 'high'],
  76. // return a plain array for speedy calculation
  77. toYData: function (point) {
  78. return [point.low, point.high];
  79. },
  80. pointValKey: 'high',
  81. doQuartiles: false,
  82. drawDataLabels: seriesTypes.arearange ?
  83. function () {
  84. var valKey = this.pointValKey;
  85. seriesTypes.arearange.prototype.drawDataLabels.call(this);
  86. // Arearange drawDataLabels does not reset point.y to high,
  87. // but to low after drawing (#4133)
  88. this.data.forEach(function (point) {
  89. point.y = point[valKey];
  90. });
  91. } :
  92. noop,
  93. // Get the width and X offset, either on top of the linked series column or
  94. // standalone
  95. getColumnMetrics: function () {
  96. return ((this.linkedParent && this.linkedParent.columnMetrics) ||
  97. seriesTypes.column.prototype.getColumnMetrics.call(this));
  98. }
  99. });
  100. /**
  101. * A `errorbar` series. If the [type](#series.errorbar.type) option
  102. * is not specified, it is inherited from [chart.type](#chart.type).
  103. *
  104. * @extends series,plotOptions.errorbar
  105. * @excluding dataParser, dataURL, stack, stacking, boostThreshold,
  106. * boostBlending
  107. * @product highcharts
  108. * @requires highcharts-more
  109. * @apioption series.errorbar
  110. */
  111. /**
  112. * An array of data points for the series. For the `errorbar` series
  113. * type, points can be given in the following ways:
  114. *
  115. * 1. An array of arrays with 3 or 2 values. In this case, the values correspond
  116. * to `x,low,high`. If the first value is a string, it is applied as the name
  117. * of the point, and the `x` value is inferred. The `x` value can also be
  118. * omitted, in which case the inner arrays should be of length 2\. Then the
  119. * `x` value is automatically calculated, either starting at 0 and
  120. * incremented by 1, or from `pointStart` and `pointInterval` given in the
  121. * series options.
  122. * ```js
  123. * data: [
  124. * [0, 10, 2],
  125. * [1, 1, 8],
  126. * [2, 4, 5]
  127. * ]
  128. * ```
  129. *
  130. * 2. An array of objects with named values. The following snippet shows only a
  131. * few settings, see the complete options set below. If the total number of
  132. * data points exceeds the series'
  133. * [turboThreshold](#series.errorbar.turboThreshold), this option is not
  134. * available.
  135. * ```js
  136. * data: [{
  137. * x: 1,
  138. * low: 0,
  139. * high: 0,
  140. * name: "Point2",
  141. * color: "#00FF00"
  142. * }, {
  143. * x: 1,
  144. * low: 5,
  145. * high: 5,
  146. * name: "Point1",
  147. * color: "#FF00FF"
  148. * }]
  149. * ```
  150. *
  151. * @sample {highcharts} highcharts/series/data-array-of-arrays/
  152. * Arrays of numeric x and y
  153. * @sample {highcharts} highcharts/series/data-array-of-arrays-datetime/
  154. * Arrays of datetime x and y
  155. * @sample {highcharts} highcharts/series/data-array-of-name-value/
  156. * Arrays of point.name and y
  157. * @sample {highcharts} highcharts/series/data-array-of-objects/
  158. * Config objects
  159. *
  160. * @type {Array<Array<(number|string),number>|Array<(number|string),number,number>|*>}
  161. * @extends series.arearange.data
  162. * @excluding dataLabels, drilldown, marker, states
  163. * @product highcharts
  164. * @apioption series.errorbar.data
  165. */
  166. ''; // adds doclets above to transpiled file