ErrorBarSeries.js 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229
  1. /* *
  2. *
  3. * (c) 2010-2021 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. var __extends = (this && this.__extends) || (function () {
  12. var extendStatics = function (d, b) {
  13. extendStatics = Object.setPrototypeOf ||
  14. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  15. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  16. return extendStatics(d, b);
  17. };
  18. return function (d, b) {
  19. extendStatics(d, b);
  20. function __() { this.constructor = d; }
  21. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  22. };
  23. })();
  24. import BoxPlotSeries from '../BoxPlot/BoxPlotSeries.js';
  25. import ColumnSeries from '../Column/ColumnSeries.js';
  26. import palette from '../../Core/Color/Palette.js';
  27. import SeriesRegistry from '../../Core/Series/SeriesRegistry.js';
  28. var AreaRangeSeries = SeriesRegistry.seriesTypes.arearange;
  29. import U from '../../Core/Utilities.js';
  30. var merge = U.merge, extend = U.extend;
  31. /**
  32. * Errorbar series type
  33. *
  34. * @private
  35. * @class
  36. * @name Highcharts.seriesTypes.errorbar
  37. *
  38. * @augments Highcharts.Series
  39. *
  40. */
  41. var ErrorBarSeries = /** @class */ (function (_super) {
  42. __extends(ErrorBarSeries, _super);
  43. function ErrorBarSeries() {
  44. /* *
  45. *
  46. * Static properties
  47. *
  48. * */
  49. var _this = _super !== null && _super.apply(this, arguments) || this;
  50. /* *
  51. *
  52. * Properties
  53. *
  54. * */
  55. _this.data = void 0;
  56. _this.options = void 0;
  57. _this.points = void 0;
  58. return _this;
  59. }
  60. /* *
  61. *
  62. * Functions
  63. *
  64. * */
  65. // Get the width and X offset, either on top of the linked series
  66. // column or standalone
  67. ErrorBarSeries.prototype.getColumnMetrics = function () {
  68. return ((this.linkedParent && this.linkedParent.columnMetrics) ||
  69. ColumnSeries.prototype.getColumnMetrics.call(this));
  70. };
  71. ErrorBarSeries.prototype.drawDataLabels = function () {
  72. var valKey = this.pointValKey;
  73. if (AreaRangeSeries) {
  74. AreaRangeSeries.prototype.drawDataLabels.call(this);
  75. // Arearange drawDataLabels does not reset point.y to high,
  76. // but to low after drawing (#4133)
  77. this.data.forEach(function (point) {
  78. point.y = point[valKey];
  79. });
  80. }
  81. };
  82. // return a plain array for speedy calculation
  83. ErrorBarSeries.prototype.toYData = function (point) {
  84. return [point.low, point.high];
  85. };
  86. /**
  87. * Error bars are a graphical representation of the variability of data and
  88. * are used on graphs to indicate the error, or uncertainty in a reported
  89. * measurement.
  90. *
  91. * @sample highcharts/demo/error-bar/
  92. * Error bars on a column series
  93. * @sample highcharts/series-errorbar/on-scatter/
  94. * Error bars on a scatter series
  95. *
  96. * @extends plotOptions.boxplot
  97. * @excluding boostBlending, boostThreshold
  98. * @product highcharts highstock
  99. * @requires highcharts-more
  100. * @optionparent plotOptions.errorbar
  101. */
  102. ErrorBarSeries.defaultOptions = merge(BoxPlotSeries.defaultOptions, {
  103. /**
  104. * The main color of the bars. This can be overridden by
  105. * [stemColor](#plotOptions.errorbar.stemColor) and
  106. * [whiskerColor](#plotOptions.errorbar.whiskerColor) individually.
  107. *
  108. * @sample {highcharts} highcharts/plotoptions/error-bar-styling/
  109. * Error bar styling
  110. *
  111. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  112. * @default #000000
  113. * @since 3.0
  114. * @product highcharts
  115. */
  116. color: palette.neutralColor100,
  117. grouping: false,
  118. /**
  119. * The parent series of the error bar. The default value links it to
  120. * the previous series. Otherwise, use the id of the parent series.
  121. *
  122. * @since 3.0
  123. * @product highcharts
  124. */
  125. linkedTo: ':previous',
  126. tooltip: {
  127. pointFormat: '<span style="color:{point.color}">\u25CF</span> {series.name}: <b>{point.low}</b> - <b>{point.high}</b><br/>'
  128. },
  129. /**
  130. * The line width of the whiskers, the horizontal lines marking
  131. * low and high values. When `null`, the general
  132. * [lineWidth](#plotOptions.errorbar.lineWidth) applies.
  133. *
  134. * @sample {highcharts} highcharts/plotoptions/error-bar-styling/
  135. * Error bar styling
  136. *
  137. * @type {number}
  138. * @since 3.0
  139. * @product highcharts
  140. */
  141. whiskerWidth: null
  142. });
  143. return ErrorBarSeries;
  144. }(BoxPlotSeries));
  145. extend(ErrorBarSeries.prototype, {
  146. // array point configs are mapped to this
  147. pointArrayMap: ['low', 'high'],
  148. pointValKey: 'high',
  149. doQuartiles: false
  150. });
  151. SeriesRegistry.registerSeriesType('errorbar', ErrorBarSeries);
  152. /* *
  153. *
  154. * Default export
  155. *
  156. * */
  157. export default ErrorBarSeries;
  158. /* *
  159. *
  160. * API options
  161. *
  162. * */
  163. /**
  164. * A `errorbar` series. If the [type](#series.errorbar.type) option
  165. * is not specified, it is inherited from [chart.type](#chart.type).
  166. *
  167. * @extends series,plotOptions.errorbar
  168. * @excluding dataParser, dataURL, stack, stacking, boostThreshold,
  169. * boostBlending
  170. * @product highcharts
  171. * @requires highcharts-more
  172. * @apioption series.errorbar
  173. */
  174. /**
  175. * An array of data points for the series. For the `errorbar` series
  176. * type, points can be given in the following ways:
  177. *
  178. * 1. An array of arrays with 3 or 2 values. In this case, the values correspond
  179. * to `x,low,high`. If the first value is a string, it is applied as the name
  180. * of the point, and the `x` value is inferred. The `x` value can also be
  181. * omitted, in which case the inner arrays should be of length 2\. Then the
  182. * `x` value is automatically calculated, either starting at 0 and
  183. * incremented by 1, or from `pointStart` and `pointInterval` given in the
  184. * series options.
  185. * ```js
  186. * data: [
  187. * [0, 10, 2],
  188. * [1, 1, 8],
  189. * [2, 4, 5]
  190. * ]
  191. * ```
  192. *
  193. * 2. An array of objects with named values. The following snippet shows only a
  194. * few settings, see the complete options set below. If the total number of
  195. * data points exceeds the series'
  196. * [turboThreshold](#series.errorbar.turboThreshold), this option is not
  197. * available.
  198. * ```js
  199. * data: [{
  200. * x: 1,
  201. * low: 0,
  202. * high: 0,
  203. * name: "Point2",
  204. * color: "#00FF00"
  205. * }, {
  206. * x: 1,
  207. * low: 5,
  208. * high: 5,
  209. * name: "Point1",
  210. * color: "#FF00FF"
  211. * }]
  212. * ```
  213. *
  214. * @sample {highcharts} highcharts/series/data-array-of-arrays/
  215. * Arrays of numeric x and y
  216. * @sample {highcharts} highcharts/series/data-array-of-arrays-datetime/
  217. * Arrays of datetime x and y
  218. * @sample {highcharts} highcharts/series/data-array-of-name-value/
  219. * Arrays of point.name and y
  220. * @sample {highcharts} highcharts/series/data-array-of-objects/
  221. * Config objects
  222. *
  223. * @type {Array<Array<(number|string),number>|Array<(number|string),number,number>|*>}
  224. * @extends series.arearange.data
  225. * @excluding dataLabels, drilldown, marker, states
  226. * @product highcharts
  227. * @apioption series.errorbar.data
  228. */
  229. ''; // adds doclets above to transpiled file