natr.src.js 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158
  1. /**
  2. * @license Highstock JS v9.1.1 (2021-06-04)
  3. *
  4. * Indicator series type for Highcharts Stock
  5. *
  6. * (c) 2010-2021 Paweł Dalek
  7. *
  8. * License: www.highcharts.com/license
  9. */
  10. 'use strict';
  11. (function (factory) {
  12. if (typeof module === 'object' && module.exports) {
  13. factory['default'] = factory;
  14. module.exports = factory;
  15. } else if (typeof define === 'function' && define.amd) {
  16. define('highcharts/indicators/natr', ['highcharts', 'highcharts/modules/stock'], function (Highcharts) {
  17. factory(Highcharts);
  18. factory.Highcharts = Highcharts;
  19. return factory;
  20. });
  21. } else {
  22. factory(typeof Highcharts !== 'undefined' ? Highcharts : undefined);
  23. }
  24. }(function (Highcharts) {
  25. var _modules = Highcharts ? Highcharts._modules : {};
  26. function _registerModule(obj, path, args, fn) {
  27. if (!obj.hasOwnProperty(path)) {
  28. obj[path] = fn.apply(null, args);
  29. }
  30. }
  31. _registerModule(_modules, 'Stock/Indicators/NATR/NATRIndicator.js', [_modules['Core/Series/SeriesRegistry.js'], _modules['Core/Utilities.js']], function (SeriesRegistry, U) {
  32. /* *
  33. *
  34. * License: www.highcharts.com/license
  35. *
  36. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  37. *
  38. * */
  39. var __extends = (this && this.__extends) || (function () {
  40. var extendStatics = function (d,
  41. b) {
  42. extendStatics = Object.setPrototypeOf ||
  43. ({ __proto__: [] } instanceof Array && function (d,
  44. b) { d.__proto__ = b; }) ||
  45. function (d,
  46. b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  47. return extendStatics(d, b);
  48. };
  49. return function (d, b) {
  50. extendStatics(d, b);
  51. function __() { this.constructor = d; }
  52. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  53. };
  54. })();
  55. var ATRIndicator = SeriesRegistry.seriesTypes.atr;
  56. var merge = U.merge,
  57. extend = U.extend;
  58. /**
  59. * The NATR series type.
  60. *
  61. * @private
  62. * @class
  63. * @name Highcharts.seriesTypes.natr
  64. *
  65. * @augments Highcharts.Series
  66. */
  67. var NATRIndicator = /** @class */ (function (_super) {
  68. __extends(NATRIndicator, _super);
  69. function NATRIndicator() {
  70. var _this = _super !== null && _super.apply(this,
  71. arguments) || this;
  72. /**
  73. * @lends Highcharts.Series#
  74. */
  75. /* *
  76. *
  77. * Properties
  78. *
  79. * */
  80. _this.data = void 0;
  81. _this.points = void 0;
  82. _this.options = void 0;
  83. return _this;
  84. }
  85. /* *
  86. *
  87. * Functions
  88. *
  89. * */
  90. NATRIndicator.prototype.getValues = function (series, params) {
  91. var atrData = (ATRIndicator.prototype.getValues.apply(this,
  92. arguments)),
  93. atrLength = atrData.values.length,
  94. period = params.period - 1,
  95. yVal = series.yData,
  96. i = 0;
  97. if (!atrData) {
  98. return;
  99. }
  100. for (; i < atrLength; i++) {
  101. atrData.yData[i] = (atrData.values[i][1] / yVal[period][3] * 100);
  102. atrData.values[i][1] = atrData.yData[i];
  103. period++;
  104. }
  105. return atrData;
  106. };
  107. /**
  108. * Normalized average true range indicator (NATR). This series requires
  109. * `linkedTo` option to be set and should be loaded after the
  110. * `stock/indicators/indicators.js` and `stock/indicators/atr.js`.
  111. *
  112. * @sample {highstock} stock/indicators/natr
  113. * NATR indicator
  114. *
  115. * @extends plotOptions.atr
  116. * @since 7.0.0
  117. * @product highstock
  118. * @requires stock/indicators/indicators
  119. * @requires stock/indicators/natr
  120. * @optionparent plotOptions.natr
  121. */
  122. NATRIndicator.defaultOptions = merge(ATRIndicator.defaultOptions, {
  123. tooltip: {
  124. valueSuffix: '%'
  125. }
  126. });
  127. return NATRIndicator;
  128. }(ATRIndicator));
  129. extend(NATRIndicator.prototype, {
  130. requiredIndicators: ['atr']
  131. });
  132. SeriesRegistry.registerSeriesType('natr', NATRIndicator);
  133. /* *
  134. *
  135. * Default Export
  136. *
  137. * */
  138. /**
  139. * A `NATR` series. If the [type](#series.natr.type) option is not specified, it
  140. * is inherited from [chart.type](#chart.type).
  141. *
  142. * @extends series,plotOptions.natr
  143. * @since 7.0.0
  144. * @product highstock
  145. * @excluding dataParser, dataURL
  146. * @requires stock/indicators/indicators
  147. * @requires stock/indicators/natr
  148. * @apioption series.natr
  149. */
  150. ''; // to include the above in the js output'
  151. return NATRIndicator;
  152. });
  153. _registerModule(_modules, 'masters/indicators/natr.src.js', [], function () {
  154. });
  155. }));