-
Notifications
You must be signed in to change notification settings - Fork 117
Expand file tree
/
Copy pathchartmaker.js
More file actions
59 lines (48 loc) · 1.04 KB
/
Copy pathchartmaker.js
File metadata and controls
59 lines (48 loc) · 1.04 KB
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
// Chart Helper
var ChartMaker =
{
render: function(analysis)
{
// options
var options = {
w: 300,
h: 280,
margin: {top: 60, right: 100, bottom: 50, left: 135},
maxValue: 1,
levels: 5,
dotRadius: 10,
roundStrokes: true,
color: d3.scale.ordinal().range(ChartMaker.getEnabledColors(analysis))
};
// data
var data = ChartMaker.getDataFromAnalysis(analysis);
// do it!
RadarChart("#chart", data, options);
},
getEnabledColors: function(analysis)
{
var colors = [];
_.each(analysis, function(product, index) {
if (product.disabled != true) // because it could be null
{
colors.push(AmazonMiner.colors[index % AmazonMiner.colors.length]);
}
});
return colors;
},
getDataFromAnalysis: function(analysis)
{
var data = [];
_.each(analysis, function(product) {
if (product.disabled != true)
{
var part = [];
_.each(product.features, function(feature) {
part.push({axis: feature.name, value: feature.avg_score});
});
data.push(part);
}
});
return data;
}
}