//Practically all this code comes from https://github.com/alangrafu/radar-chart-d3 //I only made some additions and aesthetic adjustments to make the chart look better //(of course, that is only my point of view) //Such as a better placement of the titles at each line end, //adding numbers that reflect what each circular level stands for //Not placing the last level and slight differences in color // //For a bit of extra information check the blog about it: //http://nbremer.blogspot.nl/2013/09/making-d3-radar-chart-look-bit-better.html var RadarChart = { draw: function(id, d, options){ var cfg = { radius: 5, w: 600, h: 600, factor: 1, factorLegend: .85, levels: 3, maxValue: 0, radians: 2 * Math.PI, opacityArea: 0.5, ToRight: 5, TranslateX: 80, TranslateY: 30, ExtraWidthX: 100, ExtraWidthY: 100, color: d3.scale.category10() }; if('undefined' !== typeof options){ for(var i in options){ if('undefined' !== typeof options[i]){ cfg[i] = options[i]; } } } cfg.maxValue = Math.max(cfg.maxValue, d3.max(d, function(i){return d3.max(i.map(function(o){return o.value;}))})); var allAxis = (d[0].map(function(i, j){return i.axis})); var total = allAxis.length; var radius = cfg.factor*Math.min(cfg.w/2, cfg.h/2); var Format = d3.format('%'); d3.select(id).select("svg").remove(); var g = d3.select(id) .append("svg") .attr("width", cfg.w+cfg.ExtraWidthX) .attr("height", cfg.h+cfg.ExtraWidthY) .append("g") .attr("transform", "translate(" + cfg.TranslateX + "," + cfg.TranslateY + ")"); ; var tooltip; //Circular segments for(var j=0; j