ErrorBarSeries.js 5.6 KB

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