added the plot of circles to to the radar
[tech-radar.git] / src / graphing / radar.js
1 tr.graphing.Radar = function (svg, size, radar) {
2 var self = {};
3
4 svg.attr('width', size).attr('height', size);
5
6 function plotLines() {
7 var center = Math.round(size / 2);
8
9 svg.append('line')
10 .attr('x1', center)
11 .attr('y1', 0)
12 .attr('x2', center)
13 .attr('y2', size)
14 .attr('stroke-width', 5);
15
16 svg.append('line')
17 .attr('x1', 0)
18 .attr('y1', center)
19 .attr('x2', size)
20 .attr('y2', center)
21 .attr('stroke-width', 5);
22 };
23
24 function plotCircles() {
25 var center, cycles, increment;
26
27 center = Math.round(size / 2);
28 cycles = radar.cycles();
29 increment = Math.round(center / cycles.length);
30
31 cycles.forEach(function (cycle, i) {
32 svg.append('circle')
33 .attr('cx', center)
34 .attr('cy', center)
35 .attr('r', (i + 1) * increment);
36 });
37 }
38
39 self.plot = function () {
40 plotLines();
41 plotCircles();
42 };
43
44 return self;
45 };