-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMain.hx
158 lines (155 loc) · 5.9 KB
/
Main.hx
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
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
import lib.*;
using lib.M;
class Main {
public static var JAM:Jam;
public static function main() {
inline function usage(?exitCode:Int = 1) {
Sys.println("usage: neko graph.n <jamFile.json> <outFile.html>");
Sys.exit(exitCode);
}
switch (Sys.args()) {
case ["-?"] | ["-h"] | ["--help"]: usage(0);
case [jamFile, outFile]:
JAM = Jam.json(jamFile);
JAM.stats();
var t = new haxe.Template(sys.io.File.getContent("assets/templ.html"));
sys.io.File.saveContent(outFile, t.execute({graphs: [
Graph.bar({
name: "Category average"
,axisX: ""
,axisY: "games"
,values: cast JAM.categoryRatingAvg
,valueLabels: JAM.categoryRatingAvg.map(M.prec.bind(_, 100))
,ticksX: JAM.categories
})
,Graph.scatter({
name: "Popularity / rating"
,axisX: "ratings received"
,axisY: "rating"
,minX: 10
,maxY: 10
,values: JAM.ratingRes
,ticksX: [ for (i in 10...JAM.maxRatingCount + 1) (i % 5 == 0 || i == JAM.maxRatingCount ? '$i' : null) ]
,axesX: [{pos: 20, label: "10.0"}, {pos: 145, label: "5.0"}]
})
,Graph.scatter({
name: "Popularity / placement"
,axisX: "ratings received"
,axisY: "placement percentile"
,minX: 10
,values: JAM.ratingPlc
,ticksX: [ for (i in 10...JAM.maxRatingCount + 1) (i % 5 == 0 || i == JAM.maxRatingCount ? '$i' : null) ]
,axesX: [{pos: 20, label: "100%"}, {pos: 145, label: "50%"}]
})
,Graph.bar({
name: "Vote spread"
,addType: "axis-x-bottom"
,axisX: "spread"
,axisY: "votes"
,values: cast JAM.spread
,valueLabels: JAM.spread.map(Std.string)
,ticksX: [ for (i in 0...10) '$i' ]
})
,Graph.matrix({
name: "Category correlation"
,axisX: ""
,axisY: ""
,values: JAM.categoryCorrelation
,valueLabels: JAM.categoryCorrelation.map(r -> r.map(M.prec.bind(_, 100)))
,ticksX: JAM.categories
,ticksY: JAM.categories.rev()
})
,Graph.matrix({
name: "Category correlation 2"
,axisX: ""
,axisY: ""
,values: JAM.categoryCorrelationRanking
,valueLabels: JAM.categoryCorrelationRanking.map(r -> r.map(M.prec.bind(_, 100)))
,ticksX: JAM.categories
,ticksY: JAM.categories.rev()
})
,Graph.bar({
name: "Best category by rating"
,axisX: ""
,axisY: "games"
// .slice(1) because 0 games have Overall best / worst rating
,values: cast JAM.bestCategoryRating.slice(1)
,valueLabels: JAM.bestCategoryRating.slice(1).map(Std.string)
,ticksX: JAM.categories.slice(1)
})
,Graph.bar({
name: "Worst category by rating"
,axisX: ""
,axisY: "games"
// .slice(1) because 0 games have Overall best / worst rating
,values: cast JAM.worstCategoryRating.slice(1)
,valueLabels: JAM.worstCategoryRating.slice(1).map(Std.string)
,ticksX: JAM.categories.slice(1)
})
,Graph.bar({
name: "Best category by rank"
,axisX: ""
,axisY: "games"
,values: cast JAM.bestCategoryRanking
,valueLabels: JAM.bestCategoryRanking.map(Std.string)
,ticksX: JAM.categories
})
,Graph.bar({
name: "Worst category by rank"
,axisX: ""
,axisY: "games"
,values: cast JAM.worstCategoryRanking
,valueLabels: JAM.worstCategoryRanking.map(Std.string)
,ticksX: JAM.categories
})
,Graph.scatter({
name: "Comments / rating"
,axisX: "comments received"
,axisY: "rating"
,values: JAM.commentRes
,minX: 5
,maxY: 10
,ticksX: [ for (i in 5...JAM.maxCommentCount + 1) (i % 5 == 0 || i == JAM.maxCommentCount ? '$i' : null) ]
,axesX: [{pos: 20, label: "10.0"}, {pos: 145, label: "5.0"}]
})
,Graph.scatter({
name: "Comments / placement"
,axisX: "comments received"
,axisY: "placement percentile"
,values: JAM.commentPlc
,minX: 5
,ticksX: [ for (i in 5...JAM.maxCommentCount + 1) (i % 5 == 0 || i == JAM.maxCommentCount ? '$i' : null) ]
,axesX: [{pos: 20, label: "100%"}, {pos: 145, label: "50%"}]
})
,Graph.bar({
name: "Average rating given by day"
,addType: "small-nums"
,axisX: "day"
,axisY: "average"
,values: JAM.dayAvg
,valueLabels: JAM.dayAvg.map(M.prec.bind(_, 100))
,ticksX: [ for (i in 1...15) i.ord() ]
})
,Graph.bar({
name: "Day voted"
,addType: "small-nums"
,axisX: "day"
,axisY: "votes"
,values: cast JAM.dayVotes
,valueLabels: JAM.dayVotes.map(Std.string)
,ticksX: [ for (i in 1...15) i.ord() ]
})
,Graph.bar({
name: "Vote values"
,addType: "small-nums"
,axisX: "vote"
,axisY: "frequency"
,values: cast JAM.voteFreq
,valueLabels: JAM.voteFreq.map(Std.string)
,ticksX: [ for (i in 1...11) '$i' ]
})
]}));
case _: usage();
}
}
}