indicator-required.js
1.92 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
/**
*
* (c) 2010-2019 Daniel Studencki
*
* License: www.highcharts.com/license
*
* !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
*
* */
'use strict';
import H from '../parts/Globals.js';
import '../parts/Utilities.js';
var error = H.error;
/* eslint-disable no-invalid-this, valid-jsdoc */
var requiredIndicatorMixin = {
/**
* Check whether given indicator is loaded, else throw error.
* @private
* @param {Highcharts.Indicator} indicator
* Indicator constructor function.
* @param {string} requiredIndicator
* Required indicator type.
* @param {string} type
* Type of indicator where function was called (parent).
* @param {Highcharts.IndicatorConstructorFunction} callback
* Callback which is triggered if the given indicator is loaded.
* Takes indicator as an argument.
* @param {string} errMessage
* Error message that will be logged in console.
* @return {boolean}
* Returns false when there is no required indicator loaded.
*/
isParentLoaded: function (indicator, requiredIndicator, type, callback, errMessage) {
if (indicator) {
return callback ? callback(indicator) : true;
}
error(errMessage || this.generateMessage(type, requiredIndicator));
return false;
},
/**
* @private
* @param {string} indicatorType
* Indicator type
* @param {string} required
* Required indicator
* @return {string}
* Error message
*/
generateMessage: function (indicatorType, required) {
return 'Error: "' + indicatorType +
'" indicator type requires "' + required +
'" indicator loaded before. Please read docs: ' +
'https://api.highcharts.com/highstock/plotOptions.' +
indicatorType;
}
};
export default requiredIndicatorMixin;