Skip to content

Instantly share code, notes, and snippets.

@erikhazzard
Created January 11, 2012 21:10
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save erikhazzard/1596780 to your computer and use it in GitHub Desktop.
Save erikhazzard/1596780 to your computer and use it in GitHub Desktop.
//Draw lines for each attribute, starting from origin
for(datum in RADAR._data.children){
if(RADAR._data.children.hasOwnProperty(datum)){
//Store x,y so we don't have to recalculate everytime
x = (Math.cos(index*2*Math.PI/6) * radius) + center[0]
y = (Math.sin(index*2*Math.PI/6) * radius) + center[1]
cur_value = RADAR._data.children[datum].value;
//DO STUFF
//-------------------------------
//Add a point to the radar polygon
//-------------------------------
radar_points.push([
//X point
((cur_value / max_radar_value) * (x-center[0])
+ center[0]),
//Y point
((cur_value / max_radar_value) * (y-center[1])
+ center[1])
]);
// MORE STUFF
//Add polygon
radar_polygon_circle_group.append('path')
.attr('id', 'radar_polygon_1')
.attr('class', 'radar_polygon')
.attr('d', function(d,i){
return 'M' + radar_points.join('L') + 'Z';
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment