forked from JustinShenk/normaliz-notebook
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscript.js
26 lines (22 loc) · 1.08 KB
/
script.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
var a2 = Math.atan2(source.y, source.x);
var a1 = Math.atan2(compare.y, compare.x);
var sign = a1 > a2 ? 1 : -1;
var angle = a1 - a2;
var K = -sign * Math.PI * 2;
var angle = (Math.abs(K + angle) < Math.abs(angle))? K + angle : angle;
var jsonCircles = [
{ "x_axis": 30, "y_axis": 30, "radius": 20, "color" : "green" },
{ "x_axis": 70, "y_axis": 70, "radius": 20, "color" : "purple"},
{ "x_axis": 110, "y_axis": 100, "radius": 20, "color" : "red"}];
var svgContainer = d3.select("body").append("svg")
.attr("width", 200)
.attr("height", 200);
var circles = svgContainer.selectAll("circle")
.data(jsonCircles)
.enter()
.append("circle");
var circleAttributes = circles
.attr("cx", function (d) { return d.x_axis; })
.attr("cy", function (d) { return d.y_axis; })
.attr("r", function (d) { return d.radius; })
.style("fill", function(d) { return d.color; });