-
Notifications
You must be signed in to change notification settings - Fork 0
/
rotCurve.html
113 lines (98 loc) · 2.63 KB
/
rotCurve.html
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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
<!DOCTYPE HTML>
<html>
<head>
<title>Rotation Curve Demonstration</title>
<script src="http://d3js.org/d3.v2.min.js?2.10.0"></script>
<script src="xkcd.js"></script>
<style>
@font-face {
font-family: "xkcd";
}
body {
font-family: "xkcd", sans-serif;
font-size: 16px;
color: #333;
text-align: center;
margin-top: 75px;
}
text.title {
font-size: 20px;
}
path {
fill: none;
stroke-width: 2.5px;
stroke-linecap: round;
stroke-linejoin: round;
}
path.axis {
stroke: black;
}
path.bgline {
stroke: white;
stroke-width: 6px;
}
</style>
</head>
<body>
<div id='viz'></div>
<script>
var disk, halo, tot;
var plot = xkcdplot();
d = d3.csv("Dehnen_rotcurve.txt", function(dataset) {
disk = dataset.map(function(d)
{
R = parseFloat(d["R"])
sqrtVC2disk = parseFloat(d["sqrtVC2disk"])
return {"x":R, "y":sqrtVC2disk};
});
halo = dataset.map(function(d)
{
R = parseFloat(d["R"])
sqrtVC2dm = parseFloat(d["sqrtVC2dm"])
return {"x":R, "y":sqrtVC2dm};
});
tot = dataset.map(function(d)
{
R = parseFloat(d["R"])
sqrtVC2tot = parseFloat(d["sqrtVC2tot"])
return {"x":R, "y":sqrtVC2tot};
});
plot('#viz');
plot.plot(disk, {id: 'diskLine', strokeWidth: 0});
plot.plot(halo, {id: 'haloLine', stroke: 'red', strokeWidth: 0});
plot.plot(tot, {id: 'totLine', stroke: 'black', strokeWidth: 0});
plot.xlim([0, 30]).draw();
});
function drawDisk(){
d3.selectAll("svg").selectAll("path.diskLine")
.style('stroke-width', '4px')
d3.selectAll("svg").selectAll("path.diskLine")
.transition()
.duration(2000)
.ease("linear")
.attr("stroke-dashoffset", 0);
};
function drawHalo(){
d3.selectAll("svg").selectAll("path.haloLine")
.style('stroke-width', '4px')
d3.selectAll("svg").selectAll("path.haloLine")
.transition()
.duration(2000)
.ease("linear")
.attr("stroke-dashoffset", 0);
};
function drawTot(){
d3.selectAll("svg").selectAll("path.totLine")
.style('stroke-width', '4px')
d3.selectAll("svg").selectAll("path.totLine")
.transition()
.duration(2000)
.ease("linear")
.attr("stroke-dashoffset", 0);
};
</script>
<button type="button" onclick="drawDisk()">Disk</button>
<button type="button" onclick="drawHalo()">Halo</button>
<button type="button" onclick="drawTot()">Tot</button>
</body>
</html>