forked from binary-com/binary-static
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindicator.js
More file actions
62 lines (58 loc) · 2.03 KB
/
indicator.js
File metadata and controls
62 lines (58 loc) · 2.03 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
58
59
60
61
62
var LiveChartIndicator = {};
LiveChartIndicator['Barrier'] = function(params) {
this.name = params['name'];
this.value = typeof params['value'] !== 'object' ? parseFloat(params['value']) : params['value'];
this.color = params['color'] || 'blue';
this.width = params['width'] || 2;
this.id = 'barrier_' + this.name;
this.is_relative = /^[+-]/.test(params['value']);
this.painted = false;
this.label = params['label'] || '';
this.axis = params['axis'] || 'y';
this.nomargin = params['nomargin'] || false;
};
LiveChartIndicator['Barrier'].prototype = {
remove: function(that) {
if (this.axis == 'y') {
that.chart.yAxis[0].removePlotLine(this.id);
} else {
that.chart.xAxis[0].removePlotLine(this.id);
}
},
repaint: function(that) {
if (this.is_relative || !this.painted) {
this.remove(that);
this.paint(that);
return true;
}
return false;
},
paint: function(that) {
var value = this.value;
if (this.is_relative) {
if (that.spot) {
value = that.spot + value;
} else {
return;
}
}
var plot_option = { value: value, color: this.color, width: this.width, id: this.id };
if (this.label) {
if (this.axis == 'x') {
if(this.nomargin) {
plot_option.label = {text: text.localize(this.label), verticalAlign: 'middle', textAlign: 'center' };
} else {
plot_option.label = {text: text.localize(this.label), verticalAlign: 'middle', x: -10, textAlign: 'center' };
}
} else {
plot_option.label = {text: text.localize(this.label), align: 'center'};
}
}
if (this.axis == 'y') {
that.chart.yAxis[0].addPlotLine(plot_option);
} else {
that.chart.xAxis[0].addPlotLine(plot_option);
}
this.painted = true;
}
};