1 tr
.graphing
.Radar = function (svg
, size
, radar
) {
4 fib
= new tr
.util
.Fib();
6 svg
.attr('width', size
).attr('height', size
);
9 return Math
.round(size
/2);
12 function plotLines() {
18 .attr('stroke-width', 14);
25 .attr('stroke-width', 14);
28 function getRadius(cycles
, i
) {
29 var sequence
= fib
.sequence(cycles
.length
);
30 var total
= fib
.sum(cycles
.length
);
33 return center() - (center() * sum
/ total
);
36 function plotCircles(cycles
) {
39 cycles
.forEach(function (cycle
, i
) {
43 .attr('r', getRadius(cycles
, i
));
47 function plotTexts(cycles
) {
50 increment
= Math
.round(center() / cycles
.length
);
52 cycles
.forEach(function (cycle
, i
) {
54 .attr('y', center() + 4)
55 .attr('x', center() - getRadius(cycles
, i
) + 10)
59 .attr('y', center() + 4)
60 .attr('x', center() + getRadius(cycles
, i
) - 10)
61 .attr('text-anchor', 'end')
66 function random(min
, max
) {
67 return Math
.floor(Math
.random() * (max
- min
+ 1)) + min
;
70 function plotBlips(cycles
, blips
, adjustX
, adjustY
) {
71 cycles
.forEach(function (cycle
, i
) {
72 var maxRadius
, minRadius
, cycleBlips
;
74 maxRadius
= getRadius(cycles
, i
);
75 minRadius
= (i
== cycles
.length
- 1) ? 0: getRadius(cycles
, i
+ 1);
77 var cycleBlips
= blips
.filter(function (blip
) {
78 return blip
.cycle() == cycle
;
81 cycleBlips
.forEach(function (blip
) {
82 var angleInRad
, radius
;
84 angleInRad
= Math
.PI
* random(5, 85) / 180;
85 radius
= random(minRadius
+ 5, maxRadius
- 5);
88 .attr('cx', center() + radius
* Math
.cos(angleInRad
) * adjustX
)
89 .attr('cy', center() + radius
* Math
.sin(angleInRad
) * adjustY
)
91 .append('title').text(blip
.name());
96 self
.plot = function () {
97 var cycles
= radar
.cycles().reverse();
102 plotBlips(cycles
, radar
.quadrants().I
.blips(), 1, -1);
103 plotBlips(cycles
, radar
.quadrants().II
.blips(), -1, -1);
104 plotBlips(cycles
, radar
.quadrants().III
.blips(), -1, 1);
105 plotBlips(cycles
, radar
.quadrants().IV
.blips(), 1, 1);