forked from RootKuo/Test
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathUSdata.html
More file actions
28 lines (28 loc) · 1015 Bytes
/
USdata.html
File metadata and controls
28 lines (28 loc) · 1015 Bytes
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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<script src="https://d3js.org/d3.v4.min.js"></script>
<title>Document</title>
</head>
<body>
<script type="text/javascript">
var width = 800;
var height = 500;
var ctrl = d3.select("body").append("svg").attr("width", width).attr("height", height);
d3.csv("./USDATA.csv",
function(data)
{
var ln = data.length;
console.log(data);
var maxy = d3.max(data, function(d){ return d.SOLD; });
var miny = d3.min(data, function(d){ return d.BUY; });
var lines = d3.line().x(function(d,i){return (ln-i)*(width/ln);}).y(function(d){return height-(d.SOLD-miny)*(height/(maxy-miny))});
var lines2 = d3.line().x(function(d,i){return (ln-i)*(width/ln);}).y(function(d){return height-(d.BUY-miny)*(height/(maxy-miny))});
ctrl.append("path").data([data]).attr("d", lines).attr("stroke", "red").attr("fill", "none");
ctrl.append("path").data([data]).attr("d", lines2).attr("stroke", "blue").attr("fill", "none");
}
);
</script>
</body>
</html>