forked from speced/respec
-
Notifications
You must be signed in to change notification settings - Fork 1
/
auto-time-formatting.htm
186 lines (161 loc) · 4.26 KB
/
auto-time-formatting.htm
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
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
<div class='row trunk-section'>
<div class='col-lg-7 text-center'>
<div class='row'>
<div class='col-lg-12 text-center' id='time1'></div>
<div class='col-lg-12 text-center' id='time2'></div>
<div class='col-lg-12 text-center' id='time3'></div>
<div class='col-lg-12 text-center' id='time4'></div>
</div>
</div>
<div class='col-lg-5'>
<pre><code class='javascript'>function fake_data(length, seconds) {
var d = new Date();
var v = 100000;
var data=[];
for (var i = 0; i < length; i++) {
v += (Math.random() - 0.5) * 10000;
data.push({date: MG.clone(d), value: v});
d = new Date(d.getTime() + seconds * 1000);
}
return data;
}
function fake_days(length) {
var d = new Date();
var v = 100000;
var data = [];
for (var i = 0; i < length; i++) {
v += (Math.random() - 0.5) * 10000;
data.push({date: MG.clone(d), value: v});
d.setDate(d.getDate() + 1);
}
return data;
}
var data1 = fake_data(25, 1);
var data2 = fake_data(25,60 * 20);
var data3 = fake_data(75,60 * 60);
var data4 = fake_days(25);
MG.data_graphic({
title: "Less Than A Minute",
data: data1,
target: '#time1',
width: 600,
height: 200,
right: 40
});
MG.data_graphic({
title: "Less Than A Day",
data: data2,
target: '#time2',
width: 600,
height: 200,
right: 40
});
MG.data_graphic({
title: "A Few Days",
data: data3,
target: '#time3',
width: 600,
height: 200,
right: 40
});
MG.data_graphic({
title: "Over A Large Span of Days",
data: data4,
target: '#time4',
width: 600,
height: 200,
right: 40
});</code></pre>
</div>
</div>
<div class='row trunk-section'>
<div class='col-lg-7 text-center'>
<div class='row'>
<div class='col-lg-12 text-center' id='european'></div>
</div>
</div>
<div class='col-lg-5'>
<pre><code class='javascript'>MG.data_graphic({
title: "European Clock",
description: 'By setting european_clock to true, you can default to European-style time. This is at the moment experimental, and the formatting may change.',
data: data1,
target: '#european',
european_clock: true,
width: 600,
height: 200,
right: 40
});
</code></pre>
</div>
</div>
<script>
MG._hooks = {};
function fake_data(length, seconds) {
var d = new Date();
var v = 100000;
var data=[];
for (var i = 0; i < length; i++) {
v += (Math.random() - 0.5) * 10000;
data.push({date: MG.clone(d), value: v});
d = new Date(d.getTime() + seconds * 1000);
}
return data;
}
function fake_days(length) {
var d = new Date();
var v = 100000;
var data = [];
for (var i = 0; i < length; i++) {
v += (Math.random() - 0.5) * 10000;
data.push({date: MG.clone(d), value: v});
d.setDate(d.getDate() + 1);
}
return data;
}
var data1 = fake_data(25, 1);
var data2 = fake_data(25,60 * 20);
var data3 = fake_data(75,60 * 60);
var data4 = fake_days(25);
MG.data_graphic({
title: "European Clock",
description: 'By setting european_clock to true, you can default to European-style time. This is at the moment experimental, and the formatting may change.',
data: data1,
target: '#european',
european_clock: true,
width: 600,
height: 200,
right: 40
});
MG.data_graphic({
title: "Less Than A Minute",
data: data1,
target: '#time1',
width: 600,
height: 200,
right: 40
});
MG.data_graphic({
title: "Less Than A Day",
data: data2,
target: '#time2',
width: 600,
height: 200,
right: 40
});
MG.data_graphic({
title: "A Few Days",
data: data3,
target: '#time3',
width: 600,
height: 200,
right: 40
});
MG.data_graphic({
title: "Over A Large Span of Days",
data: data4,
target: '#time4',
width: 600,
height: 200,
right: 40
});
</script>