riemann-dash 0.2.4 → 0.2.5
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/riemann/dash/public/clock.js +12 -8
- data/lib/riemann/dash/public/strings.js +8 -2
- data/lib/riemann/dash/public/subs.js +8 -4
- data/lib/riemann/dash/public/util.js +19 -5
- data/lib/riemann/dash/public/vendor/flot/jquery.colorhelpers.js +179 -0
- data/lib/riemann/dash/public/vendor/flot/jquery.colorhelpers.min.js +21 -0
- data/lib/riemann/dash/public/vendor/flot/jquery.flot.canvas.js +345 -0
- data/lib/riemann/dash/public/vendor/flot/jquery.flot.canvas.min.js +28 -0
- data/lib/riemann/dash/public/vendor/flot/jquery.flot.categories.js +190 -0
- data/lib/riemann/dash/public/vendor/flot/jquery.flot.categories.min.js +44 -0
- data/lib/riemann/dash/public/vendor/flot/jquery.flot.crosshair.js +176 -0
- data/lib/riemann/dash/public/vendor/flot/jquery.flot.crosshair.min.js +59 -0
- data/lib/riemann/dash/public/vendor/flot/jquery.flot.errorbars.js +353 -0
- data/lib/riemann/dash/public/vendor/flot/jquery.flot.errorbars.min.js +63 -0
- data/lib/riemann/dash/public/vendor/flot/jquery.flot.fillbetween.js +226 -0
- data/lib/riemann/dash/public/vendor/flot/jquery.flot.fillbetween.min.js +30 -0
- data/lib/riemann/dash/public/vendor/flot/jquery.flot.image.js +241 -0
- data/lib/riemann/dash/public/vendor/flot/jquery.flot.image.min.js +53 -0
- data/lib/riemann/dash/public/vendor/flot/jquery.flot.js +3061 -0
- data/lib/riemann/dash/public/vendor/flot/jquery.flot.min.js +29 -0
- data/lib/riemann/dash/public/vendor/flot/jquery.flot.navigate.js +346 -0
- data/lib/riemann/dash/public/vendor/flot/jquery.flot.navigate.min.js +86 -0
- data/lib/riemann/dash/public/vendor/flot/jquery.flot.pie.js +817 -0
- data/lib/riemann/dash/public/vendor/flot/jquery.flot.pie.min.js +56 -0
- data/lib/riemann/dash/public/vendor/flot/jquery.flot.resize.js +60 -0
- data/lib/riemann/dash/public/vendor/flot/jquery.flot.resize.min.js +19 -0
- data/lib/riemann/dash/public/vendor/flot/jquery.flot.selection.js +360 -0
- data/lib/riemann/dash/public/vendor/flot/jquery.flot.selection.min.js +79 -0
- data/lib/riemann/dash/public/vendor/flot/jquery.flot.stack.js +188 -0
- data/lib/riemann/dash/public/vendor/flot/jquery.flot.stack.min.js +36 -0
- data/lib/riemann/dash/public/vendor/flot/jquery.flot.symbol.js +71 -0
- data/lib/riemann/dash/public/vendor/flot/jquery.flot.symbol.min.js +14 -0
- data/lib/riemann/dash/public/vendor/flot/jquery.flot.threshold.js +142 -0
- data/lib/riemann/dash/public/vendor/flot/jquery.flot.threshold.min.js +43 -0
- data/lib/riemann/dash/public/vendor/flot/jquery.flot.time.js +431 -0
- data/lib/riemann/dash/public/vendor/flot/jquery.flot.time.min.js +9 -0
- data/lib/riemann/dash/public/view.js +11 -7
- data/lib/riemann/dash/public/views/flot.js +248 -0
- data/lib/riemann/dash/public/views/grid.js +1 -5
- data/lib/riemann/dash/version.rb +1 -1
- data/lib/riemann/dash/views/css.scss +24 -0
- data/lib/riemann/dash/views/index.erubis +6 -0
- metadata +35 -2
@@ -0,0 +1,431 @@
|
|
1
|
+
/* Pretty handling of time axes.
|
2
|
+
|
3
|
+
Copyright (c) 2007-2013 IOLA and Ole Laursen.
|
4
|
+
Licensed under the MIT license.
|
5
|
+
|
6
|
+
Set axis.mode to "time" to enable. See the section "Time series data" in
|
7
|
+
API.txt for details.
|
8
|
+
|
9
|
+
*/
|
10
|
+
|
11
|
+
(function($) {
|
12
|
+
|
13
|
+
var options = {
|
14
|
+
xaxis: {
|
15
|
+
timezone: null, // "browser" for local to the client or timezone for timezone-js
|
16
|
+
timeformat: null, // format string to use
|
17
|
+
twelveHourClock: false, // 12 or 24 time in time mode
|
18
|
+
monthNames: null // list of names of months
|
19
|
+
}
|
20
|
+
};
|
21
|
+
|
22
|
+
// round to nearby lower multiple of base
|
23
|
+
|
24
|
+
function floorInBase(n, base) {
|
25
|
+
return base * Math.floor(n / base);
|
26
|
+
}
|
27
|
+
|
28
|
+
// Returns a string with the date d formatted according to fmt.
|
29
|
+
// A subset of the Open Group's strftime format is supported.
|
30
|
+
|
31
|
+
function formatDate(d, fmt, monthNames, dayNames) {
|
32
|
+
|
33
|
+
if (typeof d.strftime == "function") {
|
34
|
+
return d.strftime(fmt);
|
35
|
+
}
|
36
|
+
|
37
|
+
var leftPad = function(n, pad) {
|
38
|
+
n = "" + n;
|
39
|
+
pad = "" + (pad == null ? "0" : pad);
|
40
|
+
return n.length == 1 ? pad + n : n;
|
41
|
+
};
|
42
|
+
|
43
|
+
var r = [];
|
44
|
+
var escape = false;
|
45
|
+
var hours = d.getHours();
|
46
|
+
var isAM = hours < 12;
|
47
|
+
|
48
|
+
if (monthNames == null) {
|
49
|
+
monthNames = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"];
|
50
|
+
}
|
51
|
+
|
52
|
+
if (dayNames == null) {
|
53
|
+
dayNames = ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"];
|
54
|
+
}
|
55
|
+
|
56
|
+
var hours12;
|
57
|
+
|
58
|
+
if (hours > 12) {
|
59
|
+
hours12 = hours - 12;
|
60
|
+
} else if (hours == 0) {
|
61
|
+
hours12 = 12;
|
62
|
+
} else {
|
63
|
+
hours12 = hours;
|
64
|
+
}
|
65
|
+
|
66
|
+
for (var i = 0; i < fmt.length; ++i) {
|
67
|
+
|
68
|
+
var c = fmt.charAt(i);
|
69
|
+
|
70
|
+
if (escape) {
|
71
|
+
switch (c) {
|
72
|
+
case 'a': c = "" + dayNames[d.getDay()]; break;
|
73
|
+
case 'b': c = "" + monthNames[d.getMonth()]; break;
|
74
|
+
case 'd': c = leftPad(d.getDate()); break;
|
75
|
+
case 'e': c = leftPad(d.getDate(), " "); break;
|
76
|
+
case 'h': // For back-compat with 0.7; remove in 1.0
|
77
|
+
case 'H': c = leftPad(hours); break;
|
78
|
+
case 'I': c = leftPad(hours12); break;
|
79
|
+
case 'l': c = leftPad(hours12, " "); break;
|
80
|
+
case 'm': c = leftPad(d.getMonth() + 1); break;
|
81
|
+
case 'M': c = leftPad(d.getMinutes()); break;
|
82
|
+
// quarters not in Open Group's strftime specification
|
83
|
+
case 'q':
|
84
|
+
c = "" + (Math.floor(d.getMonth() / 3) + 1); break;
|
85
|
+
case 'S': c = leftPad(d.getSeconds()); break;
|
86
|
+
case 'y': c = leftPad(d.getFullYear() % 100); break;
|
87
|
+
case 'Y': c = "" + d.getFullYear(); break;
|
88
|
+
case 'p': c = (isAM) ? ("" + "am") : ("" + "pm"); break;
|
89
|
+
case 'P': c = (isAM) ? ("" + "AM") : ("" + "PM"); break;
|
90
|
+
case 'w': c = "" + d.getDay(); break;
|
91
|
+
}
|
92
|
+
r.push(c);
|
93
|
+
escape = false;
|
94
|
+
} else {
|
95
|
+
if (c == "%") {
|
96
|
+
escape = true;
|
97
|
+
} else {
|
98
|
+
r.push(c);
|
99
|
+
}
|
100
|
+
}
|
101
|
+
}
|
102
|
+
|
103
|
+
return r.join("");
|
104
|
+
}
|
105
|
+
|
106
|
+
// To have a consistent view of time-based data independent of which time
|
107
|
+
// zone the client happens to be in we need a date-like object independent
|
108
|
+
// of time zones. This is done through a wrapper that only calls the UTC
|
109
|
+
// versions of the accessor methods.
|
110
|
+
|
111
|
+
function makeUtcWrapper(d) {
|
112
|
+
|
113
|
+
function addProxyMethod(sourceObj, sourceMethod, targetObj, targetMethod) {
|
114
|
+
sourceObj[sourceMethod] = function() {
|
115
|
+
return targetObj[targetMethod].apply(targetObj, arguments);
|
116
|
+
};
|
117
|
+
};
|
118
|
+
|
119
|
+
var utc = {
|
120
|
+
date: d
|
121
|
+
};
|
122
|
+
|
123
|
+
// support strftime, if found
|
124
|
+
|
125
|
+
if (d.strftime != undefined) {
|
126
|
+
addProxyMethod(utc, "strftime", d, "strftime");
|
127
|
+
}
|
128
|
+
|
129
|
+
addProxyMethod(utc, "getTime", d, "getTime");
|
130
|
+
addProxyMethod(utc, "setTime", d, "setTime");
|
131
|
+
|
132
|
+
var props = ["Date", "Day", "FullYear", "Hours", "Milliseconds", "Minutes", "Month", "Seconds"];
|
133
|
+
|
134
|
+
for (var p = 0; p < props.length; p++) {
|
135
|
+
addProxyMethod(utc, "get" + props[p], d, "getUTC" + props[p]);
|
136
|
+
addProxyMethod(utc, "set" + props[p], d, "setUTC" + props[p]);
|
137
|
+
}
|
138
|
+
|
139
|
+
return utc;
|
140
|
+
};
|
141
|
+
|
142
|
+
// select time zone strategy. This returns a date-like object tied to the
|
143
|
+
// desired timezone
|
144
|
+
|
145
|
+
function dateGenerator(ts, opts) {
|
146
|
+
if (opts.timezone == "browser") {
|
147
|
+
return new Date(ts);
|
148
|
+
} else if (!opts.timezone || opts.timezone == "utc") {
|
149
|
+
return makeUtcWrapper(new Date(ts));
|
150
|
+
} else if (typeof timezoneJS != "undefined" && typeof timezoneJS.Date != "undefined") {
|
151
|
+
var d = new timezoneJS.Date();
|
152
|
+
// timezone-js is fickle, so be sure to set the time zone before
|
153
|
+
// setting the time.
|
154
|
+
d.setTimezone(opts.timezone);
|
155
|
+
d.setTime(ts);
|
156
|
+
return d;
|
157
|
+
} else {
|
158
|
+
return makeUtcWrapper(new Date(ts));
|
159
|
+
}
|
160
|
+
}
|
161
|
+
|
162
|
+
// map of app. size of time units in milliseconds
|
163
|
+
|
164
|
+
var timeUnitSize = {
|
165
|
+
"second": 1000,
|
166
|
+
"minute": 60 * 1000,
|
167
|
+
"hour": 60 * 60 * 1000,
|
168
|
+
"day": 24 * 60 * 60 * 1000,
|
169
|
+
"month": 30 * 24 * 60 * 60 * 1000,
|
170
|
+
"quarter": 3 * 30 * 24 * 60 * 60 * 1000,
|
171
|
+
"year": 365.2425 * 24 * 60 * 60 * 1000
|
172
|
+
};
|
173
|
+
|
174
|
+
// the allowed tick sizes, after 1 year we use
|
175
|
+
// an integer algorithm
|
176
|
+
|
177
|
+
var baseSpec = [
|
178
|
+
[1, "second"], [2, "second"], [5, "second"], [10, "second"],
|
179
|
+
[30, "second"],
|
180
|
+
[1, "minute"], [2, "minute"], [5, "minute"], [10, "minute"],
|
181
|
+
[30, "minute"],
|
182
|
+
[1, "hour"], [2, "hour"], [4, "hour"],
|
183
|
+
[8, "hour"], [12, "hour"],
|
184
|
+
[1, "day"], [2, "day"], [3, "day"],
|
185
|
+
[0.25, "month"], [0.5, "month"], [1, "month"],
|
186
|
+
[2, "month"]
|
187
|
+
];
|
188
|
+
|
189
|
+
// we don't know which variant(s) we'll need yet, but generating both is
|
190
|
+
// cheap
|
191
|
+
|
192
|
+
var specMonths = baseSpec.concat([[3, "month"], [6, "month"],
|
193
|
+
[1, "year"]]);
|
194
|
+
var specQuarters = baseSpec.concat([[1, "quarter"], [2, "quarter"],
|
195
|
+
[1, "year"]]);
|
196
|
+
|
197
|
+
function init(plot) {
|
198
|
+
plot.hooks.processOptions.push(function (plot, options) {
|
199
|
+
$.each(plot.getAxes(), function(axisName, axis) {
|
200
|
+
|
201
|
+
var opts = axis.options;
|
202
|
+
|
203
|
+
if (opts.mode == "time") {
|
204
|
+
axis.tickGenerator = function(axis) {
|
205
|
+
|
206
|
+
var ticks = [];
|
207
|
+
var d = dateGenerator(axis.min, opts);
|
208
|
+
var minSize = 0;
|
209
|
+
|
210
|
+
// make quarter use a possibility if quarters are
|
211
|
+
// mentioned in either of these options
|
212
|
+
|
213
|
+
var spec = (opts.tickSize && opts.tickSize[1] ===
|
214
|
+
"quarter") ||
|
215
|
+
(opts.minTickSize && opts.minTickSize[1] ===
|
216
|
+
"quarter") ? specQuarters : specMonths;
|
217
|
+
|
218
|
+
if (opts.minTickSize != null) {
|
219
|
+
if (typeof opts.tickSize == "number") {
|
220
|
+
minSize = opts.tickSize;
|
221
|
+
} else {
|
222
|
+
minSize = opts.minTickSize[0] * timeUnitSize[opts.minTickSize[1]];
|
223
|
+
}
|
224
|
+
}
|
225
|
+
|
226
|
+
for (var i = 0; i < spec.length - 1; ++i) {
|
227
|
+
if (axis.delta < (spec[i][0] * timeUnitSize[spec[i][1]]
|
228
|
+
+ spec[i + 1][0] * timeUnitSize[spec[i + 1][1]]) / 2
|
229
|
+
&& spec[i][0] * timeUnitSize[spec[i][1]] >= minSize) {
|
230
|
+
break;
|
231
|
+
}
|
232
|
+
}
|
233
|
+
|
234
|
+
var size = spec[i][0];
|
235
|
+
var unit = spec[i][1];
|
236
|
+
|
237
|
+
// special-case the possibility of several years
|
238
|
+
|
239
|
+
if (unit == "year") {
|
240
|
+
|
241
|
+
// if given a minTickSize in years, just use it,
|
242
|
+
// ensuring that it's an integer
|
243
|
+
|
244
|
+
if (opts.minTickSize != null && opts.minTickSize[1] == "year") {
|
245
|
+
size = Math.floor(opts.minTickSize[0]);
|
246
|
+
} else {
|
247
|
+
|
248
|
+
var magn = Math.pow(10, Math.floor(Math.log(axis.delta / timeUnitSize.year) / Math.LN10));
|
249
|
+
var norm = (axis.delta / timeUnitSize.year) / magn;
|
250
|
+
|
251
|
+
if (norm < 1.5) {
|
252
|
+
size = 1;
|
253
|
+
} else if (norm < 3) {
|
254
|
+
size = 2;
|
255
|
+
} else if (norm < 7.5) {
|
256
|
+
size = 5;
|
257
|
+
} else {
|
258
|
+
size = 10;
|
259
|
+
}
|
260
|
+
|
261
|
+
size *= magn;
|
262
|
+
}
|
263
|
+
|
264
|
+
// minimum size for years is 1
|
265
|
+
|
266
|
+
if (size < 1) {
|
267
|
+
size = 1;
|
268
|
+
}
|
269
|
+
}
|
270
|
+
|
271
|
+
axis.tickSize = opts.tickSize || [size, unit];
|
272
|
+
var tickSize = axis.tickSize[0];
|
273
|
+
unit = axis.tickSize[1];
|
274
|
+
|
275
|
+
var step = tickSize * timeUnitSize[unit];
|
276
|
+
|
277
|
+
if (unit == "second") {
|
278
|
+
d.setSeconds(floorInBase(d.getSeconds(), tickSize));
|
279
|
+
} else if (unit == "minute") {
|
280
|
+
d.setMinutes(floorInBase(d.getMinutes(), tickSize));
|
281
|
+
} else if (unit == "hour") {
|
282
|
+
d.setHours(floorInBase(d.getHours(), tickSize));
|
283
|
+
} else if (unit == "month") {
|
284
|
+
d.setMonth(floorInBase(d.getMonth(), tickSize));
|
285
|
+
} else if (unit == "quarter") {
|
286
|
+
d.setMonth(3 * floorInBase(d.getMonth() / 3,
|
287
|
+
tickSize));
|
288
|
+
} else if (unit == "year") {
|
289
|
+
d.setFullYear(floorInBase(d.getFullYear(), tickSize));
|
290
|
+
}
|
291
|
+
|
292
|
+
// reset smaller components
|
293
|
+
|
294
|
+
d.setMilliseconds(0);
|
295
|
+
|
296
|
+
if (step >= timeUnitSize.minute) {
|
297
|
+
d.setSeconds(0);
|
298
|
+
}
|
299
|
+
if (step >= timeUnitSize.hour) {
|
300
|
+
d.setMinutes(0);
|
301
|
+
}
|
302
|
+
if (step >= timeUnitSize.day) {
|
303
|
+
d.setHours(0);
|
304
|
+
}
|
305
|
+
if (step >= timeUnitSize.day * 4) {
|
306
|
+
d.setDate(1);
|
307
|
+
}
|
308
|
+
if (step >= timeUnitSize.month * 2) {
|
309
|
+
d.setMonth(floorInBase(d.getMonth(), 3));
|
310
|
+
}
|
311
|
+
if (step >= timeUnitSize.quarter * 2) {
|
312
|
+
d.setMonth(floorInBase(d.getMonth(), 6));
|
313
|
+
}
|
314
|
+
if (step >= timeUnitSize.year) {
|
315
|
+
d.setMonth(0);
|
316
|
+
}
|
317
|
+
|
318
|
+
var carry = 0;
|
319
|
+
var v = Number.NaN;
|
320
|
+
var prev;
|
321
|
+
|
322
|
+
do {
|
323
|
+
|
324
|
+
prev = v;
|
325
|
+
v = d.getTime();
|
326
|
+
ticks.push(v);
|
327
|
+
|
328
|
+
if (unit == "month" || unit == "quarter") {
|
329
|
+
if (tickSize < 1) {
|
330
|
+
|
331
|
+
// a bit complicated - we'll divide the
|
332
|
+
// month/quarter up but we need to take
|
333
|
+
// care of fractions so we don't end up in
|
334
|
+
// the middle of a day
|
335
|
+
|
336
|
+
d.setDate(1);
|
337
|
+
var start = d.getTime();
|
338
|
+
d.setMonth(d.getMonth() +
|
339
|
+
(unit == "quarter" ? 3 : 1));
|
340
|
+
var end = d.getTime();
|
341
|
+
d.setTime(v + carry * timeUnitSize.hour + (end - start) * tickSize);
|
342
|
+
carry = d.getHours();
|
343
|
+
d.setHours(0);
|
344
|
+
} else {
|
345
|
+
d.setMonth(d.getMonth() +
|
346
|
+
tickSize * (unit == "quarter" ? 3 : 1));
|
347
|
+
}
|
348
|
+
} else if (unit == "year") {
|
349
|
+
d.setFullYear(d.getFullYear() + tickSize);
|
350
|
+
} else {
|
351
|
+
d.setTime(v + step);
|
352
|
+
}
|
353
|
+
} while (v < axis.max && v != prev);
|
354
|
+
|
355
|
+
return ticks;
|
356
|
+
};
|
357
|
+
|
358
|
+
axis.tickFormatter = function (v, axis) {
|
359
|
+
|
360
|
+
var d = dateGenerator(v, axis.options);
|
361
|
+
|
362
|
+
// first check global format
|
363
|
+
|
364
|
+
if (opts.timeformat != null) {
|
365
|
+
return formatDate(d, opts.timeformat, opts.monthNames, opts.dayNames);
|
366
|
+
}
|
367
|
+
|
368
|
+
// possibly use quarters if quarters are mentioned in
|
369
|
+
// any of these places
|
370
|
+
|
371
|
+
var useQuarters = (axis.options.tickSize &&
|
372
|
+
axis.options.tickSize[1] == "quarter") ||
|
373
|
+
(axis.options.minTickSize &&
|
374
|
+
axis.options.minTickSize[1] == "quarter");
|
375
|
+
|
376
|
+
var t = axis.tickSize[0] * timeUnitSize[axis.tickSize[1]];
|
377
|
+
var span = axis.max - axis.min;
|
378
|
+
var suffix = (opts.twelveHourClock) ? " %p" : "";
|
379
|
+
var hourCode = (opts.twelveHourClock) ? "%I" : "%H";
|
380
|
+
var fmt;
|
381
|
+
|
382
|
+
if (t < timeUnitSize.minute) {
|
383
|
+
fmt = hourCode + ":%M:%S" + suffix;
|
384
|
+
} else if (t < timeUnitSize.day) {
|
385
|
+
if (span < 2 * timeUnitSize.day) {
|
386
|
+
fmt = hourCode + ":%M" + suffix;
|
387
|
+
} else {
|
388
|
+
fmt = "%b %d " + hourCode + ":%M" + suffix;
|
389
|
+
}
|
390
|
+
} else if (t < timeUnitSize.month) {
|
391
|
+
fmt = "%b %d";
|
392
|
+
} else if ((useQuarters && t < timeUnitSize.quarter) ||
|
393
|
+
(!useQuarters && t < timeUnitSize.year)) {
|
394
|
+
if (span < timeUnitSize.year) {
|
395
|
+
fmt = "%b";
|
396
|
+
} else {
|
397
|
+
fmt = "%b %Y";
|
398
|
+
}
|
399
|
+
} else if (useQuarters && t < timeUnitSize.year) {
|
400
|
+
if (span < timeUnitSize.year) {
|
401
|
+
fmt = "Q%q";
|
402
|
+
} else {
|
403
|
+
fmt = "Q%q %Y";
|
404
|
+
}
|
405
|
+
} else {
|
406
|
+
fmt = "%Y";
|
407
|
+
}
|
408
|
+
|
409
|
+
var rt = formatDate(d, fmt, opts.monthNames, opts.dayNames);
|
410
|
+
|
411
|
+
return rt;
|
412
|
+
};
|
413
|
+
}
|
414
|
+
});
|
415
|
+
});
|
416
|
+
}
|
417
|
+
|
418
|
+
$.plot.plugins.push({
|
419
|
+
init: init,
|
420
|
+
options: options,
|
421
|
+
name: 'time',
|
422
|
+
version: '1.0'
|
423
|
+
});
|
424
|
+
|
425
|
+
// Time-axis support used to be in Flot core, which exposed the
|
426
|
+
// formatDate function on the plot object. Various plugins depend
|
427
|
+
// on the function, so we need to re-expose it here.
|
428
|
+
|
429
|
+
$.plot.formatDate = formatDate;
|
430
|
+
|
431
|
+
})(jQuery);
|
@@ -0,0 +1,9 @@
|
|
1
|
+
/* Pretty handling of time axes.
|
2
|
+
|
3
|
+
Copyright (c) 2007-2013 IOLA and Ole Laursen.
|
4
|
+
Licensed under the MIT license.
|
5
|
+
|
6
|
+
Set axis.mode to "time" to enable. See the section "Time series data" in
|
7
|
+
API.txt for details.
|
8
|
+
|
9
|
+
*/(function(e){function n(e,t){return t*Math.floor(e/t)}function r(e,t,n,r){if(typeof e.strftime=="function")return e.strftime(t);var i=function(e,t){return e=""+e,t=""+(t==null?"0":t),e.length==1?t+e:e},s=[],o=!1,u=e.getHours(),a=u<12;n==null&&(n=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"]),r==null&&(r=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"]);var f;u>12?f=u-12:u==0?f=12:f=u;for(var l=0;l<t.length;++l){var c=t.charAt(l);if(o){switch(c){case"a":c=""+r[e.getDay()];break;case"b":c=""+n[e.getMonth()];break;case"d":c=i(e.getDate());break;case"e":c=i(e.getDate()," ");break;case"h":case"H":c=i(u);break;case"I":c=i(f);break;case"l":c=i(f," ");break;case"m":c=i(e.getMonth()+1);break;case"M":c=i(e.getMinutes());break;case"q":c=""+(Math.floor(e.getMonth()/3)+1);break;case"S":c=i(e.getSeconds());break;case"y":c=i(e.getFullYear()%100);break;case"Y":c=""+e.getFullYear();break;case"p":c=a?"am":"pm";break;case"P":c=a?"AM":"PM";break;case"w":c=""+e.getDay()}s.push(c),o=!1}else c=="%"?o=!0:s.push(c)}return s.join("")}function i(e){function t(e,t,n,r){e[t]=function(){return n[r].apply(n,arguments)}}var n={date:e};e.strftime!=undefined&&t(n,"strftime",e,"strftime"),t(n,"getTime",e,"getTime"),t(n,"setTime",e,"setTime");var r=["Date","Day","FullYear","Hours","Milliseconds","Minutes","Month","Seconds"];for(var i=0;i<r.length;i++)t(n,"get"+r[i],e,"getUTC"+r[i]),t(n,"set"+r[i],e,"setUTC"+r[i]);return n}function s(e,t){if(t.timezone=="browser")return new Date(e);if(!t.timezone||t.timezone=="utc")return i(new Date(e));if(typeof timezoneJS!="undefined"&&typeof timezoneJS.Date!="undefined"){var n=new timezoneJS.Date;return n.setTimezone(t.timezone),n.setTime(e),n}return i(new Date(e))}function l(t){t.hooks.processOptions.push(function(t,i){e.each(t.getAxes(),function(e,t){var i=t.options;i.mode=="time"&&(t.tickGenerator=function(e){var t=[],r=s(e.min,i),u=0,l=i.tickSize&&i.tickSize[1]==="quarter"||i.minTickSize&&i.minTickSize[1]==="quarter"?f:a;i.minTickSize!=null&&(typeof i.tickSize=="number"?u=i.tickSize:u=i.minTickSize[0]*o[i.minTickSize[1]]);for(var c=0;c<l.length-1;++c)if(e.delta<(l[c][0]*o[l[c][1]]+l[c+1][0]*o[l[c+1][1]])/2&&l[c][0]*o[l[c][1]]>=u)break;var h=l[c][0],p=l[c][1];if(p=="year"){if(i.minTickSize!=null&&i.minTickSize[1]=="year")h=Math.floor(i.minTickSize[0]);else{var d=Math.pow(10,Math.floor(Math.log(e.delta/o.year)/Math.LN10)),v=e.delta/o.year/d;v<1.5?h=1:v<3?h=2:v<7.5?h=5:h=10,h*=d}h<1&&(h=1)}e.tickSize=i.tickSize||[h,p];var m=e.tickSize[0];p=e.tickSize[1];var g=m*o[p];p=="second"?r.setSeconds(n(r.getSeconds(),m)):p=="minute"?r.setMinutes(n(r.getMinutes(),m)):p=="hour"?r.setHours(n(r.getHours(),m)):p=="month"?r.setMonth(n(r.getMonth(),m)):p=="quarter"?r.setMonth(3*n(r.getMonth()/3,m)):p=="year"&&r.setFullYear(n(r.getFullYear(),m)),r.setMilliseconds(0),g>=o.minute&&r.setSeconds(0),g>=o.hour&&r.setMinutes(0),g>=o.day&&r.setHours(0),g>=o.day*4&&r.setDate(1),g>=o.month*2&&r.setMonth(n(r.getMonth(),3)),g>=o.quarter*2&&r.setMonth(n(r.getMonth(),6)),g>=o.year&&r.setMonth(0);var y=0,b=Number.NaN,w;do{w=b,b=r.getTime(),t.push(b);if(p=="month"||p=="quarter")if(m<1){r.setDate(1);var E=r.getTime();r.setMonth(r.getMonth()+(p=="quarter"?3:1));var S=r.getTime();r.setTime(b+y*o.hour+(S-E)*m),y=r.getHours(),r.setHours(0)}else r.setMonth(r.getMonth()+m*(p=="quarter"?3:1));else p=="year"?r.setFullYear(r.getFullYear()+m):r.setTime(b+g)}while(b<e.max&&b!=w);return t},t.tickFormatter=function(e,t){var n=s(e,t.options);if(i.timeformat!=null)return r(n,i.timeformat,i.monthNames,i.dayNames);var u=t.options.tickSize&&t.options.tickSize[1]=="quarter"||t.options.minTickSize&&t.options.minTickSize[1]=="quarter",a=t.tickSize[0]*o[t.tickSize[1]],f=t.max-t.min,l=i.twelveHourClock?" %p":"",c=i.twelveHourClock?"%I":"%H",h;a<o.minute?h=c+":%M:%S"+l:a<o.day?f<2*o.day?h=c+":%M"+l:h="%b %d "+c+":%M"+l:a<o.month?h="%b %d":u&&a<o.quarter||!u&&a<o.year?f<o.year?h="%b":h="%b %Y":u&&a<o.year?f<o.year?h="Q%q":h="Q%q %Y":h="%Y";var p=r(n,h,i.monthNames,i.dayNames);return p})})})}var t={xaxis:{timezone:null,timeformat:null,twelveHourClock:!1,monthNames:null}},o={second:1e3,minute:6e4,hour:36e5,day:864e5,month:2592e6,quarter:7776e6,year:525949.2*60*1e3},u=[[1,"second"],[2,"second"],[5,"second"],[10,"second"],[30,"second"],[1,"minute"],[2,"minute"],[5,"minute"],[10,"minute"],[30,"minute"],[1,"hour"],[2,"hour"],[4,"hour"],[8,"hour"],[12,"hour"],[1,"day"],[2,"day"],[3,"day"],[.25,"month"],[.5,"month"],[1,"month"],[2,"month"]],a=u.concat([[3,"month"],[6,"month"],[1,"year"]]),f=u.concat([[1,"quarter"],[2,"quarter"],[1,"year"]]);e.plot.plugins.push({init:l,options:t,name:"time",version:"1.0"}),e.plot.formatDate=r})(jQuery);
|
@@ -81,7 +81,9 @@ var view = (function() {
|
|
81
81
|
72: function() { focused.split('HStack', 1) }, // h
|
82
82
|
|
83
83
|
187: function() { focused.grow(); }, // +
|
84
|
-
189: function() { focused.shrink(); }
|
84
|
+
189: function() { focused.shrink(); }, // -
|
85
|
+
107: function() { focused.grow(); }, // + (NumPad)
|
86
|
+
109: function() { focused.shrink(); } // - (NumPad)
|
85
87
|
|
86
88
|
};
|
87
89
|
|
@@ -404,24 +406,25 @@ var view = (function() {
|
|
404
406
|
'<button name="apply">Apply</button>' +
|
405
407
|
'</form></div>');
|
406
408
|
dialog.find('h1').text("Edit " + this.type);
|
409
|
+
|
410
|
+
// The serialized representation of a view that we're editing.
|
411
|
+
// Carried between various view types; when Apply is clicked, projected
|
412
|
+
// into an actual view.
|
413
|
+
var replacementJson = this.json();
|
414
|
+
replacementJson.virtual = true;
|
407
415
|
|
408
416
|
// Build type selector.
|
409
417
|
var typeSelector = dialog.find('select[name=type]');
|
410
418
|
var editForm = dialog.find('.edit-form');
|
411
419
|
var type;
|
412
420
|
for (type in types) {
|
413
|
-
if (type ==
|
421
|
+
if (type == replacementJson.type) {
|
414
422
|
typeSelector.append("<option selected>" + type + "</option>");
|
415
423
|
} else {
|
416
424
|
typeSelector.append("<option>" + type + "</option>");
|
417
425
|
}
|
418
426
|
}
|
419
427
|
|
420
|
-
// The serialized representation of a view that we're editing.
|
421
|
-
// Carried between various view types; when Apply is clicked, projected
|
422
|
-
// into an actual view.
|
423
|
-
var replacementJson = this.json();
|
424
|
-
|
425
428
|
// Update the replacement structure with the current values.
|
426
429
|
var mergeCurrentValues = function() {
|
427
430
|
dialog.find('form').first().serializeArray().forEach(function(input) {
|
@@ -452,6 +455,7 @@ var view = (function() {
|
|
452
455
|
mergeCurrentValues();
|
453
456
|
|
454
457
|
// Replace view.
|
458
|
+
delete replacementJson.virtual;
|
455
459
|
replacement = me.replace(reify(replacementJson));
|
456
460
|
replacement.parent.reflow();
|
457
461
|
me.delete();
|