forked from dsjoerg/ggtracker
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmacrochart.js
More file actions
120 lines (109 loc) · 3.18 KB
/
macrochart.js
File metadata and controls
120 lines (109 loc) · 3.18 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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
gg.directive('macrochart', [function() {
return {
restrict: 'E',
scope: {
match: '=',
classes: '@'
},
replace: true,
transclude: true,
template: '<div class="chart {{ classes }}"><div ng-transclude></div><div class="canvas"></div></div>',
link: function(scope, element, attrs) {
options = {
chart: {
defaultSeriesType: "columnrange",
renderTo: element.find('.canvas')[0],
backgroundColor: null,
zoomType: "y",
animation: false,
width: 310,
height: 150,
inverted: true
},
plotOptions: {
columnrange: {
animation: false
}
},
legend: {enabled: false},
xAxis: {
title: {
text: null
},
labels: {
style: {
fontFamily: "'Open Sans', verdana, arial, helvetica, sans-serif"
},
enabled: false
},
gridLineWidth: 0,
lineWidth: 0,
tickLength: 0,
endOnTick: false
},
yAxis: {
labels: {
enabled: true,
style: {
fontFamily: "'Open Sans', verdana, arial, helvetica, sans-serif"
}
},
title: {
text: null
},
min: 0,
max: (scope.match.duration_seconds / 60.0),
allowDecimals: false,
lineWidth: 1.0,
tickLength: 5.0,
endOnTick: false
},
tooltip: {
enabled: false,
style: {
fontFamily: "'Open Sans', verdana, arial, helvetica, sans-serif"
}
},
subtitle: {},
title: {text: ""},
credits: {"enabled":false},
};
if (scope.$parent.match.engagements) {
options.yAxis.plotBands = [];
_.each(scope.$parent.match.engagements, function(engagement) {
options.yAxis.plotBands.push({
color: 'rgba(150, 50, 50, 0.1)',
from: engagement[0] / 960.0,
to: engagement[1] / 960.0,
zIndex: 10
});
});
}
scope.chart = new Highcharts.Chart(options);
scope.show = true;
macro = scope.match.macro;
nametoshow = scope.$parent.entity.identity.name;
playertoshow = _.find(macro, function(playerinfo) {return playerinfo[0] == nametoshow;});
if (_.isUndefined(playertoshow)) {
idtoshow = scope.$parent.entity.identity.id;
playertoshow = _.find(macro, function(playerinfo) {return playerinfo[0] == idtoshow;});
}
if (!_.isUndefined(playertoshow)) {
hatches = playertoshow[1];
hatchdata = [];
for (i=0; i<hatches.length; i++) {
times = hatches[i].times;
for (inj=0; inj<times.length; inj++) {
hatchdata.push([i, times[inj] / (16.0 * 60.0), (times[inj] + 16 * 40)/(16.0 * 60.0)])
}
}
scope.chart.addSeries({
name: nametoshow,
data: hatchdata,
color: '#' + scope.$parent.entity.color
});
scope.chart.redraw();
}
}
}
}]);