tr.graphing.Radar = function (size, radar) {
var self, fib, svg;
- svg = d3.select("body").append("svg");
fib = new tr.util.Fib();
self = {};
- self.svg = svg;
+ self.svg = function () {
+ return svg;
+ }
function center () {
return Math.round(size/2);
};
function triangle(x, y, cssClass) {
- return svg.append('path')
- .attr('d', 'M412.201,311.406c0.021,0,0.042,0,0.063,0c0.067,0,0.135,0,0.201,0c4.052,0,6.106-0.051,8.168-0.102c2.053-0.051,4.115-0.102,8.176-0.102h0.103c6.976-0.183,10.227-5.306,6.306-11.53c-3.988-6.121-4.97-5.407-8.598-11.224c-1.631-3.008-3.872-4.577-6.179-4.577c-2.276,0-4.613,1.528-6.48,4.699c-3.578,6.077-3.26,6.014-7.306,11.723C402.598,306.067,405.426,311.406,412.201,311.406')
- .attr('transform', 'translate(' + ((-421 * .73) + x) + ',' + ((-299 * 0.73) + y) + ') scale(0.73) ')
- .attr('class', cssClass)
- .attr('stroke-width', 2);
+ var tsize, top, left, right, bottom, points;
- var tsize = 7
+ tsize = 13
+ top = y - tsize;
+ left = (x - tsize + 1);
+ right = (x + tsize + 1);
+ bottom = (y + tsize - tsize / 2.5);
- var top = y - tsize + 2;
- var left = (x - tsize);
- var right = (x + tsize);
- var bottom = (y + tsize);
+ points = x + 1 + ',' + top + ' ' + left + ',' + bottom + ' ' + right + ',' + bottom;
- var points = x + ',' + top + ' ' + left + ',' + bottom + ' ' + right + ',' + bottom;
+ return svg.append('polygon')
+ .attr('points', points)
+ .attr('class', cssClass)
+ .attr('stroke-width', 1.5);
}
function circle(x, y, cssClass) {
}
function plotBlips(cycles, quadrant, adjustX, adjustY) {
- var blips, number;
+ var blips;
blips = quadrant.blips();
- number = 0;
cycles.forEach(function (cycle, i) {
var maxRadius, minRadius, cycleBlips;
var split = blip.name().split('');
var sum = split.reduce(function (p, c) { return p + c.charCodeAt(0); }, 0);
- chance = new Chance(sum * cycle.name().length * number);
+ chance = new Chance(sum * cycle.name().length * blip.number());
angleInRad = Math.PI * chance.integer({ min: 13, max: 85 }) / 180;
radius = chance.floating({ min: minRadius + 25, max: maxRadius - 10 });
.attr('y', y + 4)
.attr('class', 'blip-text')
.attr('text-anchor', 'middle')
- .text(++number)
+ .text(blip.number())
});
});
};
plotName(quadrants.IV.name(), 'end', size -10, size - 10)
}
+ self.init = function (selector) {
+ svg = d3.select(selector || 'body').append("svg");
+ return self;
+ };
+
self.plot = function () {
var cycles, quadrants;