-
Notifications
You must be signed in to change notification settings - Fork 1
/
index_v4.html
127 lines (127 loc) · 3.36 KB
/
index_v4.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
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
<!DOCTYPE html>
<head>
<meta charset="utf-8" name="viewport" content="width=device-width, initial-scale=1">
<script src="http://d3js.org/d3.v4.min.js"></script>
<script src="../../dev/lexiconRainbow.d3v4.dev.js"></script>
<style type ="text/css">
</style>
</head>
<body>
<div id="containerDiv" style="margin:auto;"></div>
<script type="text/javascript">
!function(){
////////////////////////////////////////////////////////////////////
//////////////////DAYS OF 2016 BUNDLED INTO WEEKS///////////////////
////////////////////////////////////////////////////////////////////
var interval = 24*60*60*1000;
var start = (new Date(2016,0,1)).getTime();
var days = [],
weeks = [[]],
hours = Array.apply(null,Array(24)).map(function(){return 1});
for (var i = 0,D,d,W = weeks[weeks.length-1];i<=365;++i){//2016 leap day
D = new Date(start+i*interval);
d = D.toDateString();
days.push(d);
D.getDay() === 1 && W.length ? (weeks.push([]),W = weeks[weeks.length-1]) : void(0);
W.push(d);
}
////////////////////////////////////////////////////////////////////
/////////////////////////MAIN DATA STRUCTURE////////////////////////
////////////////////////////////////////////////////////////////////
var output = {
ordinal:[],
linear:[
{
axis:"lightgray",
name: "Days",
mode: "stack",
gMode: "justify",
domain: [0,24],
glyph: "./server.png",
categories:{}
}
]
};
(function(ordinal,linearCategories){
weeks.forEach(function(d,i){
ordinal[i] = {
name: getDayName(d[0])+"-"+getDayName(d[d.length-1]),
mode: "stackEqual",
categories:(function(){
return Object.defineProperties(
{},
d.reduce(function(ac,dd,ii){
ac[getDayName(dd)] = {
value: ii,
configurable: true,
writable: true,
enumerable: true
}
return ac;
},{})
)
})(),
colors: (function(){
return Object.defineProperties(
{},
d.reduce(function(ac,dd,ii){
var strokeNFill = ii & 1 ? ["Gray"] : ["Black"];
ac[getDayName(dd)] = {
value: Array.prototype.concat.apply(
strokeNFill,
[hours.map(function(){return Math.random()<0.25 ? "Crimson" : "Lime"}),strokeNFill]
),
configurable: true,
writable: true,
enumerable: true
}
return ac;
},{})
)
})()
}
})
days.forEach(function(d,i){
Object.defineProperty(
linearCategories,
getDayName(d),
{
value: {intervals: hours.slice()},
configurable: true,
writable: true,
enumerable: true
}
)
})
function getDayName (dateString){
return dateString.split(" ").slice(0,-1).join(" ");
}
})(output.ordinal,output.linear[0].categories);
/////////////////////////////////////////////////////////////////////////////
//3 INSTANCES ON THE SAME DATA, 1 w/ GUI, 1 w/o GUI and 1 w/ CUSTOM VIEWBOX//
/////////////////////////////////////////////////////////////////////////////
Array.apply(null,Array(3)).forEach(function(d,i){
(new LexiconRainbow)
.container("#containerDiv")
.forceStyle()
.GUI(
i % 3 ? false : true,
[undefined,undefined,{x:-20,w:20,h:-120}][i]
)
.w(600)
.h(200)
.sW("1000px")
.sH("auto")
.position("relative")
.sTop("0px")
.sLeft("0px")
.sMargin("0px auto 0px auto")
.lexID("lexiconRainbow"+i)
.input(output)
.append(true)
.render();
})
}()
</script>
</body>
</html>