-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathworkingwithcsv.html
44 lines (36 loc) · 1.1 KB
/
workingwithcsv.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
<!DOCTYPE html>
<html>
<head>
<meta name="description" content="Drawing Basic Shapes - Bars" />
<meta charset="utf-8">
<title>Drawing SVG Shapes with D3</title>
<script src="d3.min.js" charset="utf-8"></script>
</head>
<body>
<script>
var h = 100;
var w = 300;
var ds;
d3.csv("MonthlySales.csv", function(error, data) {
if (error) {
console.log(error);
} else {
console.log(data);
ds = data;
}
var linefun = d3.svg.line()
.x(function(d) {return ((d.month-20130001)/3.25);})
.y(function(d) {return h-d.sales;})
.interpolate("linear");
var svg = d3.select("body").append("svg").attr({width: w, height: h});
var viz = svg.append("path")
.attr({
d: linefun(ds),
"stroke" : "purple",
"stroke-width" : "2",
"fill" : "none"
});
});
</script>
</body>
</html>