-
Notifications
You must be signed in to change notification settings - Fork 66
/
Copy pathgetGDX.html
76 lines (68 loc) · 1.57 KB
/
getGDX.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
<!DOCTYPE html>
<html>
<head>
<style type="text/css">
.pathline {
stroke-width: 3;
fill: none;
}
#open {
stroke: red;
}
#high {
stroke: blue;
}
#low {
stroke: green;
}
#close {
stroke: black;
}
</style>
<script src="https://d3js.org/d3.v4.min.js"></script>
</head>
<body>
<script type="text/javascript">
var width = 1024;
var height = 800;
d3.csv("./table.csv", function(data) {
console.log(data);
data.forEach(function(d) {
console.log(d.Open);
});
var hshift = -100;
var maxy = d3.max(data, function(d) { return d.Open; });
var ln = data.length;
var ctrl = d3.select("body").append("svg").attr("width", width).attr("height", height);
linesO = d3.line().
x(function(d,i){ return i * (width/ln); }).
y(function(d){ return d.Open * (height/maxy) + hshift; });
linesH = d3.line().
x(function(d,i){ return i * (width/ln); }).
y(function(d){ return d.High * (height/maxy) + hshift; });
linesL = d3.line().
x(function(d,i){ return i * (width/ln); }).
y(function(d){ return d.Low * (height/maxy) + hshift; });
linesC = d3.line().
x(function(d,i){ return i * (width/ln); }).
y(function(d){ return d.Close * (height/maxy) + hshift; });
ctrl.append("path").data([data]).
attr("class", "pathline").
attr("id", "open").
attr("d", linesO);
ctrl.append("path").data([data]).
attr("class", "pathline").
attr("id", "high").
attr("d", linesH);
ctrl.append("path").data([data]).
attr("class", "pathline").
attr("id", "low").
attr("d", linesL);
ctrl.append("path").data([data]).
attr("class", "pathline").
attr("id", "close").
attr("d", linesC);
});
</script>
</body>
</html>