-
Notifications
You must be signed in to change notification settings - Fork 0
/
cattributes.html
69 lines (59 loc) · 2.5 KB
/
cattributes.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
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
<!DOCTYPE html>
<meta charset="utf-8">
<head>
<!--<link href="https://cdnjs.cloudflare.com/ajax/libs/extjs/6.0.0/classic/theme-crisp/resources/theme-crisp-all.css" rel="stylesheet" />-->
<script src="https://cdnjs.cloudflare.com/ajax/libs/extjs/6.0.0/ext-all.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/d3/4.7.2/d3.min.js"></script>
<script src="scripts/d3pie.js"></script>
<script src="scripts/models.js"></script>
<script src="scripts/piechart.js"></script>
<link rel="stylesheet" type="text/css" href="style/main.css">
<link rel="stylesheet" type="text/css" href="style/ckstyles.css">
</head>
<!-- TODO don't hard code these... generate them... -->
<body>
<div class="inline" id="pieChart-body"></div>
<div class="inline" id="pieChart-coloreyes"></div>
<div class="inline" id="pieChart-colorprimary"></div>
<div class="inline" id="pieChart-colorsecondary"></div>
<div class="inline" id="pieChart-colortertiary"></div>
<div class="inline" id="pieChart-eyes"></div>
<div class="inline" id="pieChart-mouth"></div>
<div class="inline" id="pieChart-pattern"></div>
<div class="inline" id="pieChart-wild"></div>
<div class="inline" id="pieChart-environment"></div>
</body>
<script>
function toUpperCaseFirst(string) {
return string.charAt(0).toUpperCase() + string.slice(1);
}
humanDesc = {
'body': ['Fur', ''],
'eyes': ['Eye', 'Shape'],
'coloreyes': ['Eye', 'Color'],
'colorprimary': ['Base', 'Color'],
'colorsecondary': ['Highlight', 'Color'],
'colortertiary': ['Accent', 'Color']
}
function getHumanDescription(desc) {
return (desc in humanDesc) ? humanDesc[desc] : [toUpperCaseFirst(desc), ''];
}
Ext.onReady(function(){
populationCattributes( () => {
cattributeStore.getGroups().items.forEach( (g) => {
var content = [];
g.items.forEach( (i) => {
// TODO: add color
content.push({label:i.data.description, value:i.data.total});
});
titles = getHumanDescription(g.config.groupKey);
generatePieChart(`pieChart-${g.config.groupKey}`, titles[0], content, {
onClickSegment: function(a) {
window.open(`https://www.cryptokitties.co/marketplace/all?search=${a.data.label}`);
}
}, titles[1]);
});
});
});
</script>
</html>