-tr.graphing.Radar = function (size, radar) {
- var self, fib, svg;
+tr.graphing.Radar = function (size, radar, toolTipDescription) {
+ var self, fib, svg, texts;
+ texts = [];
fib = new tr.util.Fib();
self = {};
});
};
- function triangle(x, y, cssClass) {
+ function triangle(x, y, cssClass, group) {
var tsize, top, left, right, bottom, points;
tsize = 13
points = x + 1 + ',' + top + ' ' + left + ',' + bottom + ' ' + right + ',' + bottom;
- return svg.append('polygon')
+ return (group || svg).append('polygon')
.attr('points', points)
.attr('class', cssClass)
.attr('stroke-width', 1.5);
}
- function circle(x, y, cssClass) {
- svg.append('circle')
+ function circle(x, y, cssClass, group) {
+ return (group || svg).append('circle')
.attr('cx', x)
.attr('cy', y)
.attr('class', cssClass)
.attr('r', 10);
}
- function plotBlips(cycles, quadrant, adjustX, adjustY) {
+ function plotBlips(cycles, quadrant, adjustX, adjustY, cssClass) {
var blips;
blips = quadrant.blips();
cycles.forEach(function (cycle, i) {
var x = center() + radius * Math.cos(angleInRad) * adjustX;
var y = center() + radius * Math.sin(angleInRad) * adjustY;
+ var group = svg.append('g').attr('class', 'blip-group');
+
if (blip.isNew()) {
- triangle(x, y, cssClassFor(quadrant.name()));
+ triangle(x, y, cssClass, group);
} else {
- circle(x, y, cssClassFor(quadrant.name()));
+ circle(x, y, cssClass, group);
}
- svg.append('text')
+ texts.push(function () {
+ var name;
+
+ name = svg.append('text')
+ .attr('x', x + 15)
+ .attr('y', y + 4)
+ .attr('class', 'blip-name')
+ .attr('text-anchor', 'left')
+ .text(blip.name())
+
+ group
+ .on('mouseover', function () { name.style('display', 'block'); })
+ .on('mouseout', function () { name.style('display', 'none'); });
+ });
+
+ group.append('text')
.attr('x', x)
.attr('y', y + 4)
.attr('class', 'blip-text')
.attr('text-anchor', 'middle')
.text(blip.number())
+ .append("svg:title")
+ .text(blip.name() + ((toolTipDescription && blip.description())
+ ? ': ' + blip.description().replace(/(<([^>]+)>)/ig, '')
+ : '' ))
});
});
};
- function cssClassFor(string) {
- return string.toLowerCase().replace(/\s\&/g, '').replace(/\s/g, '-');
- }
-
function plotQuadrantNames(quadrants) {
- function plotName(name, anchor, x, y) {
+ function plotName(name, anchor, x, y, cssClass) {
svg.append('text')
.attr('x', x)
.attr('y', y)
- .attr('class', cssClassFor(name))
+ .attr('class', cssClass)
.attr('text-anchor', anchor)
.text(name);
}
- plotName(quadrants.I.name(), 'end', size - 10, 10)
- plotName(quadrants.II.name(), 'start', 10, 10)
- plotName(quadrants.III.name(), 'start', 10, size - 10)
- plotName(quadrants.IV.name(), 'end', size -10, size - 10)
+ plotName(quadrants.I.name(), 'end', size - 10, 10, 'first')
+ plotName(quadrants.II.name(), 'start', 10, 10, 'second')
+ plotName(quadrants.III.name(), 'start', 10, size - 10, 'third')
+ plotName(quadrants.IV.name(), 'end', size -10, size - 10, 'fourth')
}
self.init = function (selector) {
if (radar.hasQuadrants()) {
plotQuadrantNames(quadrants);
- plotBlips(cycles, quadrants.I, 1, -1);
- plotBlips(cycles, quadrants.II, -1, -1);
- plotBlips(cycles, quadrants.III, -1, 1);
- plotBlips(cycles, quadrants.IV, 1, 1);
+ plotBlips(cycles, quadrants.I, 1, -1, 'first');
+ plotBlips(cycles, quadrants.II, -1, -1, 'second');
+ plotBlips(cycles, quadrants.III, -1, 1, 'third');
+ plotBlips(cycles, quadrants.IV, 1, 1, 'fourth');
}
+
+ texts.forEach(function (fn) {
+ fn();
+ });
};
return self;