natr.src.js 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. /**
  2. * @license Highstock JS v8.1.2 (2020-06-16)
  3. *
  4. * Indicator series type for Highstock
  5. *
  6. * (c) 2010-2019 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, 'indicators/natr.src.js', [_modules['parts/Globals.js'], _modules['parts/Utilities.js']], function (H, U) {
  32. /* *
  33. *
  34. * License: www.highcharts.com/license
  35. *
  36. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  37. *
  38. * */
  39. var seriesType = U.seriesType;
  40. var ATR = H.seriesTypes.atr;
  41. /**
  42. * The NATR series type.
  43. *
  44. * @private
  45. * @class
  46. * @name Highcharts.seriesTypes.natr
  47. *
  48. * @augments Highcharts.Series
  49. */
  50. seriesType('natr', 'sma',
  51. /**
  52. * Normalized average true range indicator (NATR). This series requires
  53. * `linkedTo` option to be set and should be loaded after the
  54. * `stock/indicators/indicators.js` and `stock/indicators/atr.js`.
  55. *
  56. * @sample {highstock} stock/indicators/natr
  57. * NATR indicator
  58. *
  59. * @extends plotOptions.atr
  60. * @since 7.0.0
  61. * @product highstock
  62. * @requires stock/indicators/indicators
  63. * @requires stock/indicators/natr
  64. * @optionparent plotOptions.natr
  65. */
  66. {
  67. tooltip: {
  68. valueSuffix: '%'
  69. }
  70. },
  71. /**
  72. * @lends Highcharts.Series#
  73. */
  74. {
  75. requiredIndicators: ['atr'],
  76. getValues: function (series, params) {
  77. var atrData = (ATR.prototype.getValues.apply(this, arguments)), atrLength = atrData.values.length, period = params.period - 1, yVal = series.yData, i = 0;
  78. if (!atrData) {
  79. return;
  80. }
  81. for (; i < atrLength; i++) {
  82. atrData.yData[i] = (atrData.values[i][1] / yVal[period][3] * 100);
  83. atrData.values[i][1] = atrData.yData[i];
  84. period++;
  85. }
  86. return atrData;
  87. }
  88. });
  89. /**
  90. * A `NATR` series. If the [type](#series.natr.type) option is not specified, it
  91. * is inherited from [chart.type](#chart.type).
  92. *
  93. * @extends series,plotOptions.natr
  94. * @since 7.0.0
  95. * @product highstock
  96. * @excluding dataParser, dataURL
  97. * @requires stock/indicators/indicators
  98. * @requires stock/indicators/natr
  99. * @apioption series.natr
  100. */
  101. ''; // to include the above in the js output'
  102. });
  103. _registerModule(_modules, 'masters/indicators/natr.src.js', [], function () {
  104. });
  105. }));