-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.jade
86 lines (73 loc) · 2.18 KB
/
index.jade
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
h1 good user
h4 calories
#calories-good.graph.cal-graph
//- h4 exercise
//- #exercise-good.graph
h4 articles
#articles-good.graph
h1 bad user
h4 calories
#calories-bad.graph.cal-graph
//- h4 exercise
//- #exercise-bad.graph
h4 articles
#articles-bad.graph
h1 mixed user
h4 calories
#calories-mixed.graph.cal-graph
//- h4 exercise
//- #exercise-mixed.graph
h4 articles
#articles-mixed.graph
h1 spotty user
h4 calories
#calories-spotty.graph.cal-graph
//- h4 exercise
//- #exercise-spotty.graph
h4 articles
#articles-spotty.graph
h1 badData user
h4 calories
#calories-badData.graph.cal-graph
//- h4 exercise
//- #exercise-badData.graph
h4 articles
#articles-badData.graph
script.
var initChart = function(file, element) {
var array = [];
//grab text file and convert to arrays
d3.text(file, function(data) {
c = d3.csv.parseRows(data);
for (i = 0; i < c.length; i++) {
var isSolid = 1;
if (c[i].length > 2) {
isSolid = parseInt(c[i][2])
}
array.push([ c[i][0], parseFloat(c[i][1]), isSolid ] )
}
//call columnChart() on the chart container elements
d3.select(element)
.datum(array)
.call(columnChart()
.width(600)
.height(100)
.x(function(d, i) { return d[0]; })
.y(function(d, i) { return d[1]; }));
});
};
initChart("data/calories_good.csv", "#calories-good")
initChart("data/exercise_good.csv", "#exercise-good")
initChart("data/articles_good.csv", "#articles-good")
initChart("data/calories_bad.csv", "#calories-bad")
initChart("data/exercise_bad.csv", "#exercise-bad")
initChart("data/articles_bad.csv", "#articles-bad")
initChart("data/calories_mixed.csv", "#calories-mixed")
initChart("data/exercise_mixed.csv", "#exercise-mixed")
initChart("data/articles_mixed.csv", "#articles-mixed")
initChart("data/calories_spotty.csv", "#calories-spotty")
initChart("data/exercise_spotty.csv", "#exercise-spotty")
initChart("data/articles_spotty.csv", "#articles-spotty")
initChart("data/calories_badData.csv", "#calories-badData")
initChart("data/exercise_badData.csv", "#exercise-badData")
initChart("data/articles_badData.csv", "#articles-badData")