cubism-rails 1.2.2 → 1.5.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 2a2636391b5921e934f476fc315d9292cbe0def8
4
+ data.tar.gz: 2b51c1a2cacc36aa86f88efe2c57882a96b01627
5
+ SHA512:
6
+ metadata.gz: 756f9289fc742f8e94cb386b794f9ab3b22827162fd36f211090e4bbcd722d38ad01bc322872147fdae2eb8648894796de1fe8b7aa8b60b05a082e0c5be855be
7
+ data.tar.gz: a78c6d692b9c47cbd562b0a9eea3efc4d85347b0547b290ec0cd34ecffea145e4b8e093090ad24ddaa8c2743636903fe40c64d8a2568dbbbc925d64256e53cbc
data/README.md CHANGED
@@ -6,15 +6,15 @@ Cubism.js is a [D3](http://mbostock.github.com/d3/) plugin for visualizing time
6
6
 
7
7
  Add the following to your gemfile:
8
8
 
9
- gem 'cubism-rails'
9
+ gem 'cubism-rails'
10
10
 
11
11
  And then execute:
12
12
 
13
- $ bundle
13
+ $ bundle
14
14
 
15
15
  Add the following directive to your JavaScript manifest file (application.js):
16
16
 
17
- //= require cubism
17
+ //= require cubism
18
18
 
19
19
  ## Contributing
20
20
 
@@ -1,5 +1,5 @@
1
1
  module Cubism
2
2
  module Rails
3
- VERSION = "1.2.2"
3
+ VERSION = "1.5.0.1"
4
4
  end
5
5
  end
@@ -1,5 +1,5 @@
1
1
  (function(exports){
2
- var cubism = exports.cubism = {version: "1.2.2"};
2
+ var cubism = exports.cubism = {version: "1.5.0"};
3
3
  var cubism_id = 0;
4
4
  function cubism_identity(d) { return d; }
5
5
  cubism.option = function(name, defaultValue) {
@@ -185,6 +185,210 @@ cubism_contextPrototype.cube = function(host) {
185
185
  };
186
186
 
187
187
  var cubism_cubeFormatDate = d3.time.format.iso;
188
+ /* librato (http://dev.librato.com/v1/post/metrics) source
189
+ * If you want to see an example of how to use this source, check: https://gist.github.com/drio/5792680
190
+ */
191
+ cubism_contextPrototype.librato = function(user, token) {
192
+ var source = {},
193
+ context = this;
194
+ auth_string = "Basic " + btoa(user + ":" + token);
195
+ enable_log = true,
196
+ avail_rsts = [ 1, 60, 900, 3600 ];
197
+
198
+ function log(msg) { if (enable_log) console.log(msg); }
199
+
200
+ function log_interval(start, stop, step) {
201
+ log("---------------------- Starting request");
202
+ log("START: " + new Date(start * 1000));
203
+ log("STOP : " + new Date(stop * 1000));
204
+ log("STEP : " + step);
205
+ var nes_num_mes = (stop - start)/step;
206
+ log("# of measurements necessary: " + nes_num_mes);
207
+ }
208
+
209
+ /* Given a step, find the best librato resolution to use.
210
+ *
211
+ * Example:
212
+ *
213
+ * (s) : cubism step
214
+ *
215
+ * avail_rsts 1 --------------- 60 --------------- 900 ---------------- 3600
216
+ * | (s) |
217
+ * | |
218
+ * [low_res top_res]
219
+ *
220
+ * return: low_res (60)
221
+ */
222
+ function find_ideal_librato_resolution(step) {
223
+ var highest_res = avail_rsts[0],
224
+ lowest_res = avail_rsts[avail_rsts.length]; // high and lowest available resolution from librato
225
+
226
+ /* If step is outside the highest or lowest librato resolution, pick them and we are done */
227
+ if (step >= lowest_res)
228
+ return lowest_res;
229
+
230
+ if (step <= highest_res)
231
+ return highest_res;
232
+
233
+ /* If not, find in what resolution interval the step lands. */
234
+ var iof, top_res, i;
235
+ for (i=step; i<=lowest_res; i++) {
236
+ iof = avail_rsts.indexOf(i);
237
+ if (iof > -1) {
238
+ top_res = avail_rsts[iof];
239
+ break;
240
+ }
241
+ }
242
+
243
+ var low_res;
244
+ for (i=step; i>=highest_res; i--) {
245
+ iof = avail_rsts.indexOf(i);
246
+ if (iof > -1) {
247
+ low_res = avail_rsts[iof];
248
+ break;
249
+ }
250
+ }
251
+
252
+ /* What's the closest librato resolution given the step ? */
253
+ return ((top_res-step) < (step-low_res)) ? top_res : low_res;
254
+ }
255
+
256
+ function find_librato_resolution(sdate, edate, step) {
257
+ var i_size = edate - sdate, // interval size
258
+ month = 2419200,
259
+ week = 604800,
260
+ two_days = 172800,
261
+ ideal_res;
262
+
263
+ if (i_size > month)
264
+ return 3600;
265
+
266
+ ideal_res = find_ideal_librato_resolution(step);
267
+
268
+ /*
269
+ * Now we have the ideal resolution, but due to the retention policies at librato, maybe we have
270
+ * to use a higher resolution.
271
+ * http://support.metrics.librato.com/knowledgebase/articles/66838-understanding-metrics-roll-ups-retention-and-grap
272
+ */
273
+ if (i_size > week && ideal_res < 900)
274
+ return 900;
275
+ else if (i_size > two_days && ideal_res < 60)
276
+ return 60;
277
+ else
278
+ return ideal_res;
279
+ }
280
+
281
+ /* All the logic to query the librato API is here */
282
+ var librato_request = function(metric, source) {
283
+ var url_prefix = "https://metrics-api.librato.com/v1/metrics";
284
+
285
+ function make_url(sdate, edate, step) {
286
+ var params = "start_time=" + sdate +
287
+ "&end_time=" + edate +
288
+ "&resolution=" + find_librato_resolution(sdate, edate, step);
289
+ full_url = url_prefix + "/" + metric + "?" + params;
290
+
291
+ log("full_url = " + full_url);
292
+ log_interval(sdate, edate, step);
293
+ return full_url;
294
+ }
295
+
296
+ /*
297
+ * We are most likely not going to get the same number of measurements
298
+ * cubism expects for a particular context: We have to perform down/up
299
+ * sampling
300
+ */
301
+ function down_up_sampling(isdate, iedate, step, librato_mm) {
302
+ var av = [];
303
+
304
+ for (i=isdate; i<=iedate; i+=step) {
305
+ var int_mes = [];
306
+ while (librato_mm.length && librato_mm[0].measure_time <= i) {
307
+ int_mes.push(librato_mm.shift().value);
308
+ }
309
+
310
+ var v;
311
+ if (int_mes.length) { /* Compute the average */
312
+ v = int_mes.reduce(function(a, b) { return a + b }) / int_mes.length;
313
+ } else { /* No librato values on interval */
314
+ v = (av.length) ? av[av.length-1] : 0;
315
+ }
316
+ av.push(v);
317
+ }
318
+
319
+ return av;
320
+ }
321
+
322
+ request = {};
323
+
324
+ request.fire = function(isdate, iedate, step, callback_done) {
325
+ var a_values = []; /* Store partial values from librato */
326
+
327
+ /*
328
+ * Librato has a limit in the number of measurements we get back in a request (100).
329
+ * We recursively perform requests to the API to ensure we have all the data points
330
+ * for the interval we are working on.
331
+ */
332
+ function actual_request(full_url) {
333
+ d3.json(full_url)
334
+ .header("X-Requested-With", "XMLHttpRequest")
335
+ .header("Authorization", auth_string)
336
+ .header("Librato-User-Agent", 'cubism/' + cubism.version)
337
+ .get(function (error, data) { /* Callback; data available */
338
+ if (!error) {
339
+ log("# of partial measurements: " + data.measurements[source].length);
340
+ data.measurements[source].forEach(function(o) { a_values.push(o); });
341
+
342
+ var still_more_values = 'query' in data && 'next_time' in data.query;
343
+ if (still_more_values) {
344
+ log("Requesting more values");
345
+ actual_request(make_url(data.query.next_time, iedate, step));
346
+ } else {
347
+ log("total number of measurements from librato: " + a_values.length);
348
+ var a_adjusted = down_up_sampling(isdate, iedate, step, a_values);
349
+ log("number of measurements after adjusting time values: " + a_adjusted.length);
350
+ callback_done(a_adjusted);
351
+ }
352
+ } else {
353
+ log("There was an error when performing the librato request:");
354
+ log(error);
355
+ }
356
+ });
357
+ }
358
+
359
+ actual_request(make_url(isdate, iedate, step));
360
+ };
361
+
362
+ return request;
363
+ };
364
+
365
+ /*
366
+ * The user will use this method to create a cubism source (librato in this case)
367
+ * and call .metric() as necessary to create metrics.
368
+ */
369
+ source.metric = function(m_name, m_source) {
370
+ return context.metric(function(start, stop, step, callback) {
371
+ /* All the librato logic is here; .fire() retrieves the metrics' data */
372
+ librato_request(m_name, m_source)
373
+ .fire(cubism_libratoFormatDate(start),
374
+ cubism_libratoFormatDate(stop),
375
+ cubism_libratoFormatDate(step),
376
+ function(a_values) { callback(null, a_values); });
377
+
378
+ }, m_name += "");
379
+ };
380
+
381
+ /* This is not used when the source is librato */
382
+ source.toString = function() {
383
+ return "librato";
384
+ };
385
+
386
+ return source;
387
+ };
388
+
389
+ var cubism_libratoFormatDate = function(time) {
390
+ return Math.floor(time / 1000);
391
+ };
188
392
  cubism_contextPrototype.graphite = function(host) {
189
393
  if (!arguments.length) host = "";
190
394
  var source = {},
@@ -254,6 +458,99 @@ function cubism_graphiteParse(text) {
254
458
  .slice(1) // the first value is always None?
255
459
  .map(function(d) { return +d; });
256
460
  }
461
+ cubism_contextPrototype.gangliaWeb = function(config) {
462
+ var host = '',
463
+ uriPathPrefix = '/ganglia2/';
464
+
465
+ if (arguments.length) {
466
+ if (config.host) {
467
+ host = config.host;
468
+ }
469
+
470
+ if (config.uriPathPrefix) {
471
+ uriPathPrefix = config.uriPathPrefix;
472
+
473
+ /* Add leading and trailing slashes, as appropriate. */
474
+ if( uriPathPrefix[0] != '/' ) {
475
+ uriPathPrefix = '/' + uriPathPrefix;
476
+ }
477
+
478
+ if( uriPathPrefix[uriPathPrefix.length - 1] != '/' ) {
479
+ uriPathPrefix += '/';
480
+ }
481
+ }
482
+ }
483
+
484
+ var source = {},
485
+ context = this;
486
+
487
+ source.metric = function(metricInfo) {
488
+
489
+ /* Store the members from metricInfo into local variables. */
490
+ var clusterName = metricInfo.clusterName,
491
+ metricName = metricInfo.metricName,
492
+ hostName = metricInfo.hostName,
493
+ isReport = metricInfo.isReport || false,
494
+ titleGenerator = metricInfo.titleGenerator ||
495
+ /* Reasonable (not necessarily pretty) default for titleGenerator. */
496
+ function(unusedMetricInfo) {
497
+ /* unusedMetricInfo is, well, unused in this default case. */
498
+ return ('clusterName:' + clusterName +
499
+ ' metricName:' + metricName +
500
+ (hostName ? ' hostName:' + hostName : ''));
501
+ },
502
+ onChangeCallback = metricInfo.onChangeCallback;
503
+
504
+ /* Default to plain, simple metrics. */
505
+ var metricKeyName = isReport ? 'g' : 'm';
506
+
507
+ var gangliaWebMetric = context.metric(function(start, stop, step, callback) {
508
+
509
+ function constructGangliaWebRequestQueryParams() {
510
+ return ('c=' + clusterName +
511
+ '&' + metricKeyName + '=' + metricName +
512
+ (hostName ? '&h=' + hostName : '') +
513
+ '&cs=' + start/1000 + '&ce=' + stop/1000 + '&step=' + step/1000 + '&graphlot=1');
514
+ }
515
+
516
+ d3.json(host + uriPathPrefix + 'graph.php?' + constructGangliaWebRequestQueryParams(),
517
+ function(result) {
518
+ if( !result ) {
519
+ return callback(new Error("Unable to fetch GangliaWeb data"));
520
+ }
521
+
522
+ callback(null, result[0].data);
523
+ });
524
+
525
+ }, titleGenerator(metricInfo));
526
+
527
+ gangliaWebMetric.toString = function() {
528
+ return titleGenerator(metricInfo);
529
+ };
530
+
531
+ /* Allow users to run their custom code each time a gangliaWebMetric changes.
532
+ *
533
+ * TODO Consider abstracting away the naked Cubism call, and instead exposing
534
+ * a callback that takes in the values array (maybe alongwith the original
535
+ * start and stop 'naked' parameters), since it's handy to have the entire
536
+ * dataset at your disposal (and users will likely implement onChangeCallback
537
+ * primarily to get at this dataset).
538
+ */
539
+ if (onChangeCallback) {
540
+ gangliaWebMetric.on('change', onChangeCallback);
541
+ }
542
+
543
+ return gangliaWebMetric;
544
+ };
545
+
546
+ // Returns the gangliaWeb host + uriPathPrefix.
547
+ source.toString = function() {
548
+ return host + uriPathPrefix;
549
+ };
550
+
551
+ return source;
552
+ };
553
+
257
554
  function cubism_metric(context) {
258
555
  if (!(context instanceof cubism_context)) throw new Error("invalid context");
259
556
  this.context = context;
@@ -547,6 +844,7 @@ cubism_contextPrototype.horizon = function() {
547
844
  for (var i = i0, n = width, y1; i < n; ++i) {
548
845
  y1 = metric_.valueAt(i);
549
846
  if (y1 <= 0) { negative = true; continue; }
847
+ if (y1 === undefined) continue;
550
848
  canvas.fillRect(i, y1 = scale(y1), 1, y0 - y1);
551
849
  }
552
850
  }
@@ -904,9 +1202,10 @@ cubism_contextPrototype.axis = function() {
904
1202
  scale = context.scale,
905
1203
  axis_ = d3.svg.axis().scale(scale);
906
1204
 
907
- var format = context.step() < 6e4 ? cubism_axisFormatSeconds
1205
+ var formatDefault = context.step() < 6e4 ? cubism_axisFormatSeconds
908
1206
  : context.step() < 864e5 ? cubism_axisFormatMinutes
909
1207
  : cubism_axisFormatDays;
1208
+ var format = formatDefault;
910
1209
 
911
1210
  function axis(selection) {
912
1211
  var id = ++cubism_id,
@@ -953,6 +1252,12 @@ cubism_contextPrototype.axis = function() {
953
1252
  }
954
1253
  };
955
1254
 
1255
+ axis.focusFormat = function(_) {
1256
+ if (!arguments.length) return format == formatDefault ? null : _;
1257
+ format = _ == null ? formatDefault : _;
1258
+ return axis;
1259
+ };
1260
+
956
1261
  return d3.rebind(axis, axis_,
957
1262
  "orient",
958
1263
  "ticks",
@@ -1 +1 @@
1
- (function(a){function d(a){return a}function e(){}function h(a){return Math.floor(a/1e3)}function i(a){var b=a.indexOf("|"),c=a.substring(0,b),d=c.lastIndexOf(","),e=c.lastIndexOf(",",d-1),f=c.lastIndexOf(",",e-1),g=c.substring(f+1,e)*1e3,h=c.substring(d+1)*1e3;return a.substring(b+1).split(",").slice(1).map(function(a){return+a})}function j(a){if(!(a instanceof e))throw new Error("invalid context");this.context=a}function m(a,b){return function(c,d,e,f){a(new Date(+c+b),new Date(+d+b),e,f)}}function n(a,b){j.call(this,a),b=+b;var c=b+"";this.valueOf=function(){return b},this.toString=function(){return c}}function p(a,b){function c(b,c){if(c instanceof j){if(b.context!==c.context)throw new Error("mismatch context")}else c=new n(b.context,c);j.call(this,b.context),this.left=b,this.right=c,this.toString=function(){return b+" "+a+" "+c}}var d=c.prototype=Object.create(j.prototype);return d.valueAt=function(a){return b(this.left.valueAt(a),this.right.valueAt(a))},d.shift=function(a){return new c(this.left.shift(a),this.right.shift(a))},d.on=function(a,b){return arguments.length<2?this.left.on(a):(this.left.on(a,b),this.right.on(a,b),this)},function(a){return new c(this,a)}}function s(a){return a&16777214}function t(a){return(a+1&16777214)-1}function x(a){a.style("position","absolute").style("top",0).style("bottom",0).style("width","1px").style("pointer-events","none")}function y(a){return a+"px"}var b=a.cubism={version:"1.2.2"},c=0;b.option=function(a,c){var d=b.options(a);return d.length?d[0]:c},b.options=function(a,b){var c=location.search.substring(1).split("&"),d=[],e=-1,f=c.length,g;while(++e<f)(g=c[e].split("="))[0]==a&&d.push(decodeURIComponent(g[1]));return d.length||arguments.length<2?d:b},b.context=function(){function p(){var c=Date.now();return g=new Date(Math.floor((c-j-k)/b)*b),f=new Date(g-d*b),i=new Date(Math.floor((c-j)/b)*b),h=new Date(i-d*b),m.domain([f,g]),a}var a=new e,b=1e4,d=1440,f,g,h,i,j=5e3,k=5e3,l=d3.dispatch("prepare","beforechange","change","focus"),m=a.scale=d3.time.scale().range([0,d]),n,o;return a.start=function(){n&&clearTimeout(n);var c=+i+j-Date.now();return c<k&&(c+=b),n=setTimeout(function e(){i=new Date(Math.floor((Date.now()-j)/b)*b),h=new Date(i-d*b),l.prepare.call(a,h,i),setTimeout(function(){m.domain([f=h,g=i]),l.beforechange.call(a,h,i),l.change.call(a,h,i),l.focus.call(a,o)},k),n=setTimeout(e,b)},c),a},a.stop=function(){return n=clearTimeout(n),a},n=setTimeout(a.start,10),a.step=function(a){return arguments.length?(b=+a,p()):b},a.size=function(a){return arguments.length?(m.range([0,d=+a]),p()):d},a.serverDelay=function(a){return arguments.length?(j=+a,p()):j},a.clientDelay=function(a){return arguments.length?(k=+a,p()):k},a.focus=function(b){return l.focus.call(a,o=b),a},a.on=function(b,c){return arguments.length<2?l.on(b):(l.on(b,c),c!=null&&(/^prepare(\.|$)/.test(b)&&c.call(a,h,i),/^beforechange(\.|$)/.test(b)&&c.call(a,f,g),/^change(\.|$)/.test(b)&&c.call(a,f,g),/^focus(\.|$)/.test(b)&&c.call(a,o)),a)},d3.select(window).on("keydown.context-"+ ++c,function(){switch(!d3.event.metaKey&&d3.event.keyCode){case 37:o==null&&(o=d-1),o>0&&a.focus(--o);break;case 39:o==null&&(o=d-2),o<d-1&&a.focus(++o);break;default:return}d3.event.preventDefault()}),p()};var f=b.context.prototype=e.prototype;f.constant=function(a){return new n(this,+a)},f.cube=function(a){arguments.length||(a="");var b={},c=this;return b.metric=function(b){return c.metric(function(c,d,e,f){d3.json(a+"/1.0/metric"+"?expression="+encodeURIComponent(b)+"&start="+g(c)+"&stop="+g(d)+"&step="+e,function(a){if(!a)return f(new Error("unable to load data"));f(null,a.map(function(a){return a.value}))})},b+="")},b.toString=function(){return a},b};var g=d3.time.format.iso;f.graphite=function(a){arguments.length||(a="");var b={},c=this;return b.metric=function(b){var d="sum",e=c.metric(function(c,e,f,g){var j=b;f!==1e4&&(j="summarize("+j+",'"+(f%36e5?f%6e4?f/1e3+"sec":f/6e4+"min":f/36e5+"hour")+"','"+d+"')"),d3.text(a+"/render?format=raw"+"&target="+encodeURIComponent("alias("+j+",'')")+"&from="+h(c-2*f)+"&until="+h(e-1e3),function(a){if(!a)return g(new Error("unable to load data"));g(null,i(a))})},b+="");return e.summarize=function(a){return d=a,e},e},b.find=function(b,c){d3.json(a+"/metrics/find?format=completer"+"&query="+encodeURIComponent(b),function(a){if(!a)return c(new Error("unable to find metrics"));c(null,a.metrics.map(function(a){return a.path}))})},b.toString=function(){return a},b};var k=j.prototype;b.metric=j,k.valueAt=function(){return NaN},k.alias=function(a){return this.toString=function(){return a},this},k.extent=function(){var a=0,b=this.context.size(),c,d=Infinity,e=-Infinity;while(++a<b)c=this.valueAt(a),c<d&&(d=c),c>e&&(e=c);return[d,e]},k.on=function(a,b){return arguments.length<2?null:this},k.shift=function(){return this},k.on=function(){return arguments.length<2?null:this},f.metric=function(a,b){function r(b,c){var d=Math.min(k,Math.round((b-g)/i));if(!d||q)return;q=!0,d=Math.min(k,d+l);var f=new Date(c-d*i);a(f,c,i,function(a,b){q=!1;if(a)return console.warn(a);var d=isFinite(g)?Math.round((f-g)/i):0;for(var h=0,j=b.length;h<j;++h)n[h+d]=b[h];o.change.call(e,g,c)})}function s(a,b){isFinite(g)||(g=a),n.splice(0,Math.max(0,Math.min(k,Math.round((a-g)/i)))),g=a,h=b}var d=this,e=new j(d),f=".metric-"+ ++c,g=-Infinity,h,i=d.step(),k=d.size(),n=[],o=d3.dispatch("change"),p=0,q;return e.valueAt=function(a){return n[a]},e.shift=function(b){return d.metric(m(a,+b))},e.on=function(a,b){return arguments.length?(b==null?o.on(a)!=null&&--p==0&&d.on("prepare"+f,null).on("beforechange"+f,null):o.on(a)==null&&++p==1&&d.on("prepare"+f,r).on("beforechange"+f,s),o.on(a,b),b!=null&&/^change(\.|$)/.test(a)&&b.call(d,g,h),e):o.on(a)},arguments.length>1&&(e.toString=function(){return b}),e};var l=6,o=n.prototype=Object.create(j.prototype);o.valueAt=function(){return+this},o.extent=function(){return[+this,+this]},k.add=p("+",function(a,b){return a+b}),k.subtract=p("-",function(a,b){return a-b}),k.multiply=p("*",function(a,b){return a*b}),k.divide=p("/",function(a,b){return a/b}),f.horizon=function(){function o(o){o.on("mousemove.horizon",function(){a.focus(Math.round(d3.mouse(this)[0]))}).on("mouseout.horizon",function(){a.focus(null)}),o.append("canvas").attr("width",f).attr("height",g),o.append("span").attr("class","title").text(k),o.append("span").attr("class","value"),o.each(function(k,o){function B(c,d){w.save();var i=r.extent();A=i.every(isFinite),t!=null&&(i=t);var j=0,k=Math.max(-i[0],i[1]);if(this===a){if(k==y){j=f-l;var m=(c-u)/v;if(m<f){var n=e.getContext("2d");n.clearRect(0,0,f,g),n.drawImage(w.canvas,m,0,f-m,g,0,0,f-m,g),w.clearRect(0,0,f,g),w.drawImage(n.canvas,0,0)}}u=c}h.domain([0,y=k]),w.clearRect(j,0,f-j,g);var o;for(var p=0;p<z;++p){w.fillStyle=s[z+p];var q=(p-z+1)*g;h.range([z*g+q,q]),q=h(0);for(var x=j,B=f,C;x<B;++x){C=r.valueAt(x);if(C<=0){o=!0;continue}w.fillRect(x,C=h(C),1,q-C)}}if(o){b==="offset"&&(w.translate(0,g),w.scale(1,-1));for(var p=0;p<z;++p){w.fillStyle=s[z-1-p];var q=(p-z+1)*g;h.range([z*g+q,q]),q=h(0);for(var x=j,B=f,C;x<B;++x){C=r.valueAt(x);if(C>=0)continue;w.fillRect(x,h(-C),1,q-h(-C))}}}w.restore()}function C(a){a==null&&(a=f-1);var b=r.valueAt(a);x.datum(b).text(isNaN(b)?null:m)}var p=this,q=++c,r=typeof i=="function"?i.call(p,k,o):i,s=typeof n=="function"?n.call(p,k,o):n,t=typeof j=="function"?j.call(p,k,o):j,u=-Infinity,v=a.step(),w=d3.select(p).select("canvas"),x=d3.select(p).select(".value"),y,z=s.length>>1,A;w.datum({id:q,metric:r}),w=w.node().getContext("2d"),a.on("change.horizon-"+q,B),a.on("focus.horizon-"+q,C),r.on("change.horizon-"+q,function(a,b){B(a,b),C(),A&&r.on("change.horizon-"+q,d)})})}var a=this,b="offset",e=document.createElement("canvas"),f=e.width=a.size(),g=e.height=30,h=d3.scale.linear().interpolate(d3.interpolateRound),i=d,j=null,k=d,m=d3.format(".2s"),n=["#08519c","#3182bd","#6baed6","#bdd7e7","#bae4b3","#74c476","#31a354","#006d2c"];return o.remove=function(b){function c(b){b.metric.on("change.horizon-"+b.id,null),a.on("change.horizon-"+b.id,null),a.on("focus.horizon-"+b.id,null)}b.on("mousemove.horizon",null).on("mouseout.horizon",null),b.selectAll("canvas").each(c).remove(),b.selectAll(".title,.value").remove()},o.mode=function(a){return arguments.length?(b=a+"",o):b},o.height=function(a){return arguments.length?(e.height=g=+a,o):g},o.metric=function(a){return arguments.length?(i=a,o):i},o.scale=function(a){return arguments.length?(h=a,o):h},o.extent=function(a){return arguments.length?(j=a,o):j},o.title=function(a){return arguments.length?(k=a,o):k},o.format=function(a){return arguments.length?(m=a,o):m},o.colors=function(a){return arguments.length?(n=a,o):n},o},f.comparison=function(){function o(o){o.on("mousemove.comparison",function(){a.focus(Math.round(d3.mouse(this)[0]))}).on("mouseout.comparison",function(){a.focus(null)}),o.append("canvas").attr("width",b).attr("height",e),o.append("span").attr("class","title").text(j),o.append("span").attr("class","value primary"),o.append("span").attr("class","value change"),o.each(function(j,o){function B(c,d){x.save(),x.clearRect(0,0,b,e);var g=r.extent(),h=u.extent(),i=v==null?g:v;f.domain(i).range([e,0]),A=g.concat(h).every(isFinite);var j=c/a.step()&1?t:s;x.fillStyle=m[2];for(var k=0,l=b;k<l;++k){var o=f(r.valueAt(k)),p=f(u.valueAt(k));o<p&&x.fillRect(j(k),o,1,p-o)}x.fillStyle=m[0];for(k=0;k<l;++k){var o=f(r.valueAt(k)),p=f(u.valueAt(k));o>p&&x.fillRect(j(k),p,1,o-p)}x.fillStyle=m[3];for(k=0;k<l;++k){var o=f(r.valueAt(k)),p=f(u.valueAt(k));o<=p&&x.fillRect(j(k),o,1,n)}x.fillStyle=m[1];for(k=0;k<l;++k){var o=f(r.valueAt(k)),p=f(u.valueAt(k));o>p&&x.fillRect(j(k),o-n,1,n)}x.restore()}function C(a){a==null&&(a=b-1);var c=r.valueAt(a),d=u.valueAt(a),e=(c-d)/d;y.datum(c).text(isNaN(c)?null:k),z.datum(e).text(isNaN(e)?null:l).attr("class","value change "+(e>0?"positive":e<0?"negative":""))}function D(a,b){B(a,b),C(),A&&(r.on("change.comparison-"+q,d),u.on("change.comparison-"+q,d))}var p=this,q=++c,r=typeof g=="function"?g.call(p,j,o):g,u=typeof h=="function"?h.call(p,j,o):h,v=typeof i=="function"?i.call(p,j,o):i,w=d3.select(p),x=w.select("canvas"),y=w.select(".value.primary"),z=w.select(".value.change"),A;x.datum({id:q,primary:r,secondary:u}),x=x.node().getContext("2d"),r.on("change.comparison-"+q,D),u.on("change.comparison-"+q,D),a.on("change.comparison-"+q,B),a.on("focus.comparison-"+q,C)})}var a=this,b=a.size(),e=120,f=d3.scale.linear().interpolate(d3.interpolateRound),g=function(a){return a[0]},h=function(a){return a[1]},i=null,j=d,k=q,l=r,m=["#9ecae1","#225b84","#a1d99b","#22723a"],n=1.5;return o.remove=function(b){function c(b){b.primary.on("change.comparison-"+b.id,null),b.secondary.on("change.comparison-"+b.id,null),a.on("change.comparison-"+b.id,null),a.on("focus.comparison-"+b.id,null)}b.on("mousemove.comparison",null).on("mouseout.comparison",null),b.selectAll("canvas").each(c).remove(),b.selectAll(".title,.value").remove()},o.height=function(a){return arguments.length?(e=+a,o):e},o.primary=function(a){return arguments.length?(g=a,o):g},o.secondary=function(a){return arguments.length?(h=a,o):h},o.scale=function(a){return arguments.length?(f=a,o):f},o.extent=function(a){return arguments.length?(i=a,o):i},o.title=function(a){return arguments.length?(j=a,o):j},o.formatPrimary=function(a){return arguments.length?(k=a,o):k},o.formatChange=function(a){return arguments.length?(l=a,o):l},o.colors=function(a){return arguments.length?(m=a,o):m},o.strokeWidth=function(a){return arguments.length?(n=a,o):n},o};var q=d3.format(".2s"),r=d3.format("+.0%");f.axis=function(){function f(g){var h=++c,i,j=g.append("svg").datum({id:h}).attr("width",a.size()).attr("height",Math.max(28,-f.tickSize())).append("g").attr("transform","translate(0,"+(d.orient()==="top"?27:4)+")").call(d);a.on("change.axis-"+h,function(){j.call(d),i||(i=d3.select(j.node().appendChild(j.selectAll("text").node().cloneNode(!0))).style("display","none").text(null))}),a.on("focus.axis-"+h,function(a){if(i)if(a==null)i.style("display","none"),j.selectAll("text").style("fill-opacity",null);else{i.style("display",null).attr("x",a).text(e(b.invert(a)));var c=i.node().getComputedTextLength()+6;j.selectAll("text").style("fill-opacity",function(d){return Math.abs(b(d)-a)<c?0:1})}})}var a=this,b=a.scale,d=d3.svg.axis().scale(b),e=a.step()<6e4?u:a.step()<864e5?v:w;return f.remove=function(b){function c(b){a.on("change.axis-"+b.id,null),a.on("focus.axis-"+b.id,null)}b.selectAll("svg").each(c).remove()},d3.rebind(f,d,"orient","ticks","tickSubdivide","tickSize","tickPadding","tickFormat")};var u=d3.time.format("%I:%M:%S %p"),v=d3.time.format("%I:%M %p"),w=d3.time.format("%B %d");f.rule=function(){function e(d){var e=++c,f=d.append("div").datum({id:e}).attr("class","line").call(x);d.each(function(e,f){function j(b,c){var e=[];for(var f=0,g=a.size();f<g;++f)i.valueAt(f)&&e.push(f);var h=d.selectAll(".metric").data(e);h.exit().remove(),h.enter().append("div").attr("class","metric line").call(x),h.style("left",y)}var g=this,h=++c,i=typeof b=="function"?b.call(g,e,f):b;if(!i)return;a.on("change.rule-"+h,j),i.on("change.rule-"+h,j)}),a.on("focus.rule-"+e,function(a){f.datum(a).style("display",a==null?"none":null).style("left",a==null?null:y)})}var a=this,b=d;return e.remove=function(b){function c(b){a.on("focus.rule-"+b.id,null)}b.selectAll(".line").each(c).remove()},e.metric=function(a){return arguments.length?(b=a,e):b},e}})(this);
1
+ (function(a){function d(a){return a}function e(){}function j(a){return Math.floor(a/1e3)}function k(a){var b=a.indexOf("|"),c=a.substring(0,b),d=c.lastIndexOf(","),e=c.lastIndexOf(",",d-1),f=c.lastIndexOf(",",e-1),g=c.substring(f+1,e)*1e3,h=c.substring(d+1)*1e3;return a.substring(b+1).split(",").slice(1).map(function(a){return+a})}function l(a){if(!(a instanceof e))throw new Error("invalid context");this.context=a}function o(a,b){return function(c,d,e,f){a(new Date(+c+b),new Date(+d+b),e,f)}}function p(a,b){l.call(this,a),b=+b;var c=b+"";this.valueOf=function(){return b},this.toString=function(){return c}}function r(a,b){function c(b,c){if(c instanceof l){if(b.context!==c.context)throw new Error("mismatch context")}else c=new p(b.context,c);l.call(this,b.context),this.left=b,this.right=c,this.toString=function(){return b+" "+a+" "+c}}var d=c.prototype=Object.create(l.prototype);return d.valueAt=function(a){return b(this.left.valueAt(a),this.right.valueAt(a))},d.shift=function(a){return new c(this.left.shift(a),this.right.shift(a))},d.on=function(a,b){return arguments.length<2?this.left.on(a):(this.left.on(a,b),this.right.on(a,b),this)},function(a){return new c(this,a)}}function u(a){return a&16777214}function v(a){return(a+1&16777214)-1}function z(a){a.style("position","absolute").style("top",0).style("bottom",0).style("width","1px").style("pointer-events","none")}function A(a){return a+"px"}var b=a.cubism={version:"1.5.0"},c=0;b.option=function(a,c){var d=b.options(a);return d.length?d[0]:c},b.options=function(a,b){var c=location.search.substring(1).split("&"),d=[],e=-1,f=c.length,g;while(++e<f)(g=c[e].split("="))[0]==a&&d.push(decodeURIComponent(g[1]));return d.length||arguments.length<2?d:b},b.context=function(){function p(){var c=Date.now();return g=new Date(Math.floor((c-j-k)/b)*b),f=new Date(g-d*b),i=new Date(Math.floor((c-j)/b)*b),h=new Date(i-d*b),m.domain([f,g]),a}var a=new e,b=1e4,d=1440,f,g,h,i,j=5e3,k=5e3,l=d3.dispatch("prepare","beforechange","change","focus"),m=a.scale=d3.time.scale().range([0,d]),n,o;return a.start=function(){n&&clearTimeout(n);var c=+i+j-Date.now();return c<k&&(c+=b),n=setTimeout(function e(){i=new Date(Math.floor((Date.now()-j)/b)*b),h=new Date(i-d*b),l.prepare.call(a,h,i),setTimeout(function(){m.domain([f=h,g=i]),l.beforechange.call(a,h,i),l.change.call(a,h,i),l.focus.call(a,o)},k),n=setTimeout(e,b)},c),a},a.stop=function(){return n=clearTimeout(n),a},n=setTimeout(a.start,10),a.step=function(a){return arguments.length?(b=+a,p()):b},a.size=function(a){return arguments.length?(m.range([0,d=+a]),p()):d},a.serverDelay=function(a){return arguments.length?(j=+a,p()):j},a.clientDelay=function(a){return arguments.length?(k=+a,p()):k},a.focus=function(b){return l.focus.call(a,o=b),a},a.on=function(b,c){return arguments.length<2?l.on(b):(l.on(b,c),c!=null&&(/^prepare(\.|$)/.test(b)&&c.call(a,h,i),/^beforechange(\.|$)/.test(b)&&c.call(a,f,g),/^change(\.|$)/.test(b)&&c.call(a,f,g),/^focus(\.|$)/.test(b)&&c.call(a,o)),a)},d3.select(window).on("keydown.context-"+ ++c,function(){switch(!d3.event.metaKey&&d3.event.keyCode){case 37:o==null&&(o=d-1),o>0&&a.focus(--o);break;case 39:o==null&&(o=d-2),o<d-1&&a.focus(++o);break;default:return}d3.event.preventDefault()}),p()};var f=b.context.prototype=e.prototype;f.constant=function(a){return new p(this,+a)},f.cube=function(a){arguments.length||(a="");var b={},c=this;return b.metric=function(b){return c.metric(function(c,d,e,f){d3.json(a+"/1.0/metric"+"?expression="+encodeURIComponent(b)+"&start="+g(c)+"&stop="+g(d)+"&step="+e,function(a){if(!a)return f(new Error("unable to load data"));f(null,a.map(function(a){return a.value}))})},b+="")},b.toString=function(){return a},b};var g=d3.time.format.iso;f.librato=function(a,c){function f(a){enable_log&&console.log(a)}function g(a,b,c){f("---------------------- Starting request"),f("START: "+new Date(a*1e3)),f("STOP : "+new Date(b*1e3)),f("STEP : "+c);var d=(b-a)/c;f("# of measurements necessary: "+d)}function j(a){var b=avail_rsts[0],c=avail_rsts[avail_rsts.length];if(a>=c)return c;if(a<=b)return b;var d,e,f;for(f=a;f<=c;f++){d=avail_rsts.indexOf(f);if(d>-1){e=avail_rsts[d];break}}var g;for(f=a;f>=b;f--){d=avail_rsts.indexOf(f);if(d>-1){g=avail_rsts[d];break}}return e-a<a-g?e:g}function k(a,b,c){var d=b-a,e=2419200,f=604800,g=172800,h;return d>e?3600:(h=j(c),d>f&&h<900?900:d>g&&h<60?60:h)}var d={},e=this;auth_string="Basic "+btoa(a+":"+c),enable_log=!0,avail_rsts=[1,60,900,3600];var l=function(a,c){function e(b,c,e){var h="start_time="+b+"&end_time="+c+"&resolution="+k(b,c,e);return full_url=d+"/"+a+"?"+h,f("full_url = "+full_url),g(b,c,e),full_url}function h(a,b,c,d){var e=[];for(i=a;i<=b;i+=c){var f=[];while(d.length&&d[0].measure_time<=i)f.push(d.shift().value);var g;f.length?g=f.reduce(function(a,b){return a+b})/f.length:g=e.length?e[e.length-1]:0,e.push(g)}return e}var d="https://metrics-api.librato.com/v1/metrics";return request={},request.fire=function(a,d,g,i){function k(l){d3.json(l).header("X-Requested-With","XMLHttpRequest").header("Authorization",auth_string).header("Librato-User-Agent","cubism/"+b.version).get(function(b,l){if(!b){f("# of partial measurements: "+l.measurements[c].length),l.measurements[c].forEach(function(a){j.push(a)});var m="query"in l&&"next_time"in l.query;if(m)f("Requesting more values"),k(e(l.query.next_time,d,g));else{f("total number of measurements from librato: "+j.length);var n=h(a,d,g,j);f("number of measurements after adjusting time values: "+n.length),i(n)}}else f("There was an error when performing the librato request:"),f(b)})}var j=[];k(e(a,d,g))},request};return d.metric=function(a,b){return e.metric(function(c,d,e,f){l(a,b).fire(h(c),h(d),h(e),function(a){f(null,a)})},a+="")},d.toString=function(){return"librato"},d};var h=function(a){return Math.floor(a/1e3)};f.graphite=function(a){arguments.length||(a="");var b={},c=this;return b.metric=function(b){var d="sum",e=c.metric(function(c,e,f,g){var h=b;f!==1e4&&(h="summarize("+h+",'"+(f%36e5?f%6e4?f/1e3+"sec":f/6e4+"min":f/36e5+"hour")+"','"+d+"')"),d3.text(a+"/render?format=raw"+"&target="+encodeURIComponent("alias("+h+",'')")+"&from="+j(c-2*f)+"&until="+j(e-1e3),function(a){if(!a)return g(new Error("unable to load data"));g(null,k(a))})},b+="");return e.summarize=function(a){return d=a,e},e},b.find=function(b,c){d3.json(a+"/metrics/find?format=completer"+"&query="+encodeURIComponent(b),function(a){if(!a)return c(new Error("unable to find metrics"));c(null,a.metrics.map(function(a){return a.path}))})},b.toString=function(){return a},b},f.gangliaWeb=function(a){var b="",c="/ganglia2/";arguments.length&&(a.host&&(b=a.host),a.uriPathPrefix&&(c=a.uriPathPrefix,c[0]!="/"&&(c="/"+c),c[c.length-1]!="/"&&(c+="/")));var d={},e=this;return d.metric=function(a){var d=a.clusterName,f=a.metricName,g=a.hostName,h=a.isReport||!1,i=a.titleGenerator||function(a){return"clusterName:"+d+" metricName:"+f+(g?" hostName:"+g:"")},j=a.onChangeCallback,k=h?"g":"m",l=e.metric(function(a,e,h,i){function j(){return"c="+d+"&"+k+"="+f+(g?"&h="+g:"")+"&cs="+a/1e3+"&ce="+e/1e3+"&step="+h/1e3+"&graphlot=1"}d3.json(b+c+"graph.php?"+j(),function(a){if(!a)return i(new Error("Unable to fetch GangliaWeb data"));i(null,a[0].data)})},i(a));return l.toString=function(){return i(a)},j&&l.on("change",j),l},d.toString=function(){return b+c},d};var m=l.prototype;b.metric=l,m.valueAt=function(){return NaN},m.alias=function(a){return this.toString=function(){return a},this},m.extent=function(){var a=0,b=this.context.size(),c,d=Infinity,e=-Infinity;while(++a<b)c=this.valueAt(a),c<d&&(d=c),c>e&&(e=c);return[d,e]},m.on=function(a,b){return arguments.length<2?null:this},m.shift=function(){return this},m.on=function(){return arguments.length<2?null:this},f.metric=function(a,b){function r(b,c){var d=Math.min(j,Math.round((b-g)/i));if(!d||q)return;q=!0,d=Math.min(j,d+n);var f=new Date(c-d*i);a(f,c,i,function(a,b){q=!1;if(a)return console.warn(a);var d=isFinite(g)?Math.round((f-g)/i):0;for(var h=0,j=b.length;h<j;++h)k[h+d]=b[h];m.change.call(e,g,c)})}function s(a,b){isFinite(g)||(g=a),k.splice(0,Math.max(0,Math.min(j,Math.round((a-g)/i)))),g=a,h=b}var d=this,e=new l(d),f=".metric-"+ ++c,g=-Infinity,h,i=d.step(),j=d.size(),k=[],m=d3.dispatch("change"),p=0,q;return e.valueAt=function(a){return k[a]},e.shift=function(b){return d.metric(o(a,+b))},e.on=function(a,b){return arguments.length?(b==null?m.on(a)!=null&&--p==0&&d.on("prepare"+f,null).on("beforechange"+f,null):m.on(a)==null&&++p==1&&d.on("prepare"+f,r).on("beforechange"+f,s),m.on(a,b),b!=null&&/^change(\.|$)/.test(a)&&b.call(d,g,h),e):m.on(a)},arguments.length>1&&(e.toString=function(){return b}),e};var n=6,q=p.prototype=Object.create(l.prototype);q.valueAt=function(){return+this},q.extent=function(){return[+this,+this]},m.add=r("+",function(a,b){return a+b}),m.subtract=r("-",function(a,b){return a-b}),m.multiply=r("*",function(a,b){return a*b}),m.divide=r("/",function(a,b){return a/b}),f.horizon=function(){function o(o){o.on("mousemove.horizon",function(){a.focus(Math.round(d3.mouse(this)[0]))}).on("mouseout.horizon",function(){a.focus(null)}),o.append("canvas").attr("width",f).attr("height",g),o.append("span").attr("class","title").text(k),o.append("span").attr("class","value"),o.each(function(k,o){function B(c,d){w.save();var i=r.extent();A=i.every(isFinite),t!=null&&(i=t);var j=0,k=Math.max(-i[0],i[1]);if(this===a){if(k==y){j=f-n;var l=(c-u)/v;if(l<f){var m=e.getContext("2d");m.clearRect(0,0,f,g),m.drawImage(w.canvas,l,0,f-l,g,0,0,f-l,g),w.clearRect(0,0,f,g),w.drawImage(m.canvas,0,0)}}u=c}h.domain([0,y=k]),w.clearRect(j,0,f-j,g);var o;for(var p=0;p<z;++p){w.fillStyle=s[z+p];var q=(p-z+1)*g;h.range([z*g+q,q]),q=h(0);for(var x=j,B=f,C;x<B;++x){C=r.valueAt(x);if(C<=0){o=!0;continue}if(C===undefined)continue;w.fillRect(x,C=h(C),1,q-C)}}if(o){b==="offset"&&(w.translate(0,g),w.scale(1,-1));for(var p=0;p<z;++p){w.fillStyle=s[z-1-p];var q=(p-z+1)*g;h.range([z*g+q,q]),q=h(0);for(var x=j,B=f,C;x<B;++x){C=r.valueAt(x);if(C>=0)continue;w.fillRect(x,h(-C),1,q-h(-C))}}}w.restore()}function C(a){a==null&&(a=f-1);var b=r.valueAt(a);x.datum(b).text(isNaN(b)?null:l)}var p=this,q=++c,r=typeof i=="function"?i.call(p,k,o):i,s=typeof m=="function"?m.call(p,k,o):m,t=typeof j=="function"?j.call(p,k,o):j,u=-Infinity,v=a.step(),w=d3.select(p).select("canvas"),x=d3.select(p).select(".value"),y,z=s.length>>1,A;w.datum({id:q,metric:r}),w=w.node().getContext("2d"),a.on("change.horizon-"+q,B),a.on("focus.horizon-"+q,C),r.on("change.horizon-"+q,function(a,b){B(a,b),C(),A&&r.on("change.horizon-"+q,d)})})}var a=this,b="offset",e=document.createElement("canvas"),f=e.width=a.size(),g=e.height=30,h=d3.scale.linear().interpolate(d3.interpolateRound),i=d,j=null,k=d,l=d3.format(".2s"),m=["#08519c","#3182bd","#6baed6","#bdd7e7","#bae4b3","#74c476","#31a354","#006d2c"];return o.remove=function(b){function c(b){b.metric.on("change.horizon-"+b.id,null),a.on("change.horizon-"+b.id,null),a.on("focus.horizon-"+b.id,null)}b.on("mousemove.horizon",null).on("mouseout.horizon",null),b.selectAll("canvas").each(c).remove(),b.selectAll(".title,.value").remove()},o.mode=function(a){return arguments.length?(b=a+"",o):b},o.height=function(a){return arguments.length?(e.height=g=+a,o):g},o.metric=function(a){return arguments.length?(i=a,o):i},o.scale=function(a){return arguments.length?(h=a,o):h},o.extent=function(a){return arguments.length?(j=a,o):j},o.title=function(a){return arguments.length?(k=a,o):k},o.format=function(a){return arguments.length?(l=a,o):l},o.colors=function(a){return arguments.length?(m=a,o):m},o},f.comparison=function(){function o(o){o.on("mousemove.comparison",function(){a.focus(Math.round(d3.mouse(this)[0]))}).on("mouseout.comparison",function(){a.focus(null)}),o.append("canvas").attr("width",b).attr("height",e),o.append("span").attr("class","title").text(j),o.append("span").attr("class","value primary"),o.append("span").attr("class","value change"),o.each(function(j,o){function B(c,d){x.save(),x.clearRect(0,0,b,e);var g=r.extent(),h=s.extent(),i=t==null?g:t;f.domain(i).range([e,0]),A=g.concat(h).every(isFinite);var j=c/a.step()&1?v:u;x.fillStyle=m[2];for(var k=0,l=b;k<l;++k){var o=f(r.valueAt(k)),p=f(s.valueAt(k));o<p&&x.fillRect(j(k),o,1,p-o)}x.fillStyle=m[0];for(k=0;k<l;++k){var o=f(r.valueAt(k)),p=f(s.valueAt(k));o>p&&x.fillRect(j(k),p,1,o-p)}x.fillStyle=m[3];for(k=0;k<l;++k){var o=f(r.valueAt(k)),p=f(s.valueAt(k));o<=p&&x.fillRect(j(k),o,1,n)}x.fillStyle=m[1];for(k=0;k<l;++k){var o=f(r.valueAt(k)),p=f(s.valueAt(k));o>p&&x.fillRect(j(k),o-n,1,n)}x.restore()}function C(a){a==null&&(a=b-1);var c=r.valueAt(a),d=s.valueAt(a),e=(c-d)/d;y.datum(c).text(isNaN(c)?null:k),z.datum(e).text(isNaN(e)?null:l).attr("class","value change "+(e>0?"positive":e<0?"negative":""))}function D(a,b){B(a,b),C(),A&&(r.on("change.comparison-"+q,d),s.on("change.comparison-"+q,d))}var p=this,q=++c,r=typeof g=="function"?g.call(p,j,o):g,s=typeof h=="function"?h.call(p,j,o):h,t=typeof i=="function"?i.call(p,j,o):i,w=d3.select(p),x=w.select("canvas"),y=w.select(".value.primary"),z=w.select(".value.change"),A;x.datum({id:q,primary:r,secondary:s}),x=x.node().getContext("2d"),r.on("change.comparison-"+q,D),s.on("change.comparison-"+q,D),a.on("change.comparison-"+q,B),a.on("focus.comparison-"+q,C)})}var a=this,b=a.size(),e=120,f=d3.scale.linear().interpolate(d3.interpolateRound),g=function(a){return a[0]},h=function(a){return a[1]},i=null,j=d,k=s,l=t,m=["#9ecae1","#225b84","#a1d99b","#22723a"],n=1.5;return o.remove=function(b){function c(b){b.primary.on("change.comparison-"+b.id,null),b.secondary.on("change.comparison-"+b.id,null),a.on("change.comparison-"+b.id,null),a.on("focus.comparison-"+b.id,null)}b.on("mousemove.comparison",null).on("mouseout.comparison",null),b.selectAll("canvas").each(c).remove(),b.selectAll(".title,.value").remove()},o.height=function(a){return arguments.length?(e=+a,o):e},o.primary=function(a){return arguments.length?(g=a,o):g},o.secondary=function(a){return arguments.length?(h=a,o):h},o.scale=function(a){return arguments.length?(f=a,o):f},o.extent=function(a){return arguments.length?(i=a,o):i},o.title=function(a){return arguments.length?(j=a,o):j},o.formatPrimary=function(a){return arguments.length?(k=a,o):k},o.formatChange=function(a){return arguments.length?(l=a,o):l},o.colors=function(a){return arguments.length?(m=a,o):m},o.strokeWidth=function(a){return arguments.length?(n=a,o):n},o};var s=d3.format(".2s"),t=d3.format("+.0%");f.axis=function(){function g(e){var h=++c,i,j=e.append("svg").datum({id:h}).attr("width",a.size()).attr("height",Math.max(28,-g.tickSize())).append("g").attr("transform","translate(0,"+(d.orient()==="top"?27:4)+")").call(d);a.on("change.axis-"+h,function(){j.call(d),i||(i=d3.select(j.node().appendChild(j.selectAll("text").node().cloneNode(!0))).style("display","none").text(null))}),a.on("focus.axis-"+h,function(a){if(i)if(a==null)i.style("display","none"),j.selectAll("text").style("fill-opacity",null);else{i.style("display",null).attr("x",a).text(f(b.invert(a)));var c=i.node().getComputedTextLength()+6;j.selectAll("text").style("fill-opacity",function(d){return Math.abs(b(d)-a)<c?0:1})}})}var a=this,b=a.scale,d=d3.svg.axis().scale(b),e=a.step()<6e4?w:a.step()<864e5?x:y,f=e;return g.remove=function(b){function c(b){a.on("change.axis-"+b.id,null),a.on("focus.axis-"+b.id,null)}b.selectAll("svg").each(c).remove()},g.focusFormat=function(a){return arguments.length?(f=a==null?e:a,g):f==e?null:a},d3.rebind(g,d,"orient","ticks","tickSubdivide","tickSize","tickPadding","tickFormat")};var w=d3.time.format("%I:%M:%S %p"),x=d3.time.format("%I:%M %p"),y=d3.time.format("%B %d");f.rule=function(){function e(d){var e=++c,f=d.append("div").datum({id:e}).attr("class","line").call(z);d.each(function(e,f){function j(b,c){var e=[];for(var f=0,g=a.size();f<g;++f)i.valueAt(f)&&e.push(f);var h=d.selectAll(".metric").data(e);h.exit().remove(),h.enter().append("div").attr("class","metric line").call(z),h.style("left",A)}var g=this,h=++c,i=typeof b=="function"?b.call(g,e,f):b;if(!i)return;a.on("change.rule-"+h,j),i.on("change.rule-"+h,j)}),a.on("focus.rule-"+e,function(a){f.datum(a).style("display",a==null?"none":null).style("left",a==null?null:A)})}var a=this,b=d;return e.remove=function(b){function c(b){a.on("focus.rule-"+b.id,null)}b.selectAll(".line").each(c).remove()},e.metric=function(a){return arguments.length?(b=a,e):b},e}})(this);
metadata CHANGED
@@ -1,46 +1,43 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cubism-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.2
5
- prerelease:
4
+ version: 1.5.0.1
6
5
  platform: ruby
7
6
  authors:
8
7
  - Vlad Gorodetsky
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2013-01-06 00:00:00.000000000 Z
11
+ date: 2014-03-10 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: railties
16
15
  requirement: !ruby/object:Gem::Requirement
17
- none: false
18
16
  requirements:
19
- - - ! '>='
17
+ - - ">="
20
18
  - !ruby/object:Gem::Version
21
19
  version: '3.0'
22
- - - <
20
+ - - "<"
23
21
  - !ruby/object:Gem::Version
24
22
  version: '5.0'
25
23
  type: :runtime
26
24
  prerelease: false
27
25
  version_requirements: !ruby/object:Gem::Requirement
28
- none: false
29
26
  requirements:
30
- - - ! '>='
27
+ - - ">="
31
28
  - !ruby/object:Gem::Version
32
29
  version: '3.0'
33
- - - <
30
+ - - "<"
34
31
  - !ruby/object:Gem::Version
35
32
  version: '5.0'
36
- description: ! 'Cubism.js: A JavaScript library for time series visualization.'
33
+ description: 'Cubism.js: A JavaScript library for time series visualization.'
37
34
  email:
38
35
  - v@gor.io
39
36
  executables: []
40
37
  extensions: []
41
38
  extra_rdoc_files: []
42
39
  files:
43
- - .gitignore
40
+ - ".gitignore"
44
41
  - Gemfile
45
42
  - LICENSE
46
43
  - README.md
@@ -52,26 +49,25 @@ files:
52
49
  - vendor/assets/javascripts/cubism.min.js
53
50
  homepage: http://github.com/bai/cubism-rails
54
51
  licenses: []
52
+ metadata: {}
55
53
  post_install_message:
56
54
  rdoc_options: []
57
55
  require_paths:
58
56
  - lib
59
57
  required_ruby_version: !ruby/object:Gem::Requirement
60
- none: false
61
58
  requirements:
62
- - - ! '>='
59
+ - - ">="
63
60
  - !ruby/object:Gem::Version
64
61
  version: '0'
65
62
  required_rubygems_version: !ruby/object:Gem::Requirement
66
- none: false
67
63
  requirements:
68
- - - ! '>='
64
+ - - ">="
69
65
  - !ruby/object:Gem::Version
70
66
  version: '0'
71
67
  requirements: []
72
68
  rubyforge_project:
73
- rubygems_version: 1.8.24
69
+ rubygems_version: 2.2.2
74
70
  signing_key:
75
- specification_version: 3
71
+ specification_version: 4
76
72
  summary: Gemified cubism.js asset for Rails
77
73
  test_files: []