spec/dummy/tmp/cache/assets/test/sprockets/f4648036e284d9aa3468f4f7b9bbb967 in prosperity-0.0.6 vs spec/dummy/tmp/cache/assets/test/sprockets/f4648036e284d9aa3468f4f7b9bbb967 in prosperity-0.0.7
- old
+ new
@@ -1,96 +1,139 @@
{I"
class:ETI"ProcessedAsset; FI"logical_path; TI"prosperity/graph.js; FI"
pathname; TI"c/Users/simon/Documents/rainforest/prosperity/app/assets/javascripts/prosperity/graph.js.coffee; FI"content_type; TI"application/javascript; TI"
-mtime; Tl+¬[vSI"length; TiqI"digest; TI"%b9a17205ffa8192b322068d18f9c8874; FI"source; TI"q(function() {
+mtime; Tl+Ò–vSI"length; TiÊI"digest; TI"%ef3d45f936196a1a0f5d081845ac46e2; FI"source; TI"Ê(function() {
var Graph, SubGraph, updateMetricOptions,
__bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; };
SubGraph = (function() {
function SubGraph(options) {
- this.url = options.url;
- }
-
- SubGraph.prototype.render = function() {
- var chartEl, el, getSeries;
- el = $('<div>', {
+ var chartEl;
+ if (options == null) {
+ options = {};
+ }
+ this["class"] = __bind(this["class"], this);
+ this.el = $('<div>', {
"class": 'sub-graph'
});
- el.append("<div class='title'>Loading...</div>");
+ this.graphType = options.graphType;
+ if (options.showTitle) {
+ this.el.append("<div class='title'>Loading...</div>");
+ }
+ this.el.find('.title').html(options.label);
chartEl = $('<div>', {
"class": 'sub-graph-chart'
});
- el.append(chartEl);
- getSeries = (function(_this) {
- return function(url) {
- return $.get(url, function(json) {
- var chart, chartOptions, data, i, point, redraw, start_time, time, _i, _len, _ref;
- el.find('.title').html(json.label);
- chartOptions = {
- element: chartEl,
- series: [],
- xkey: "x",
- ykeys: [],
- labels: [],
- smooth: false
- };
- if (json.key === 'change') {
- chartOptions.postUnits = '%';
- }
- chart = new Morris.Line(chartOptions);
- data = [];
- start_time = Date.parse(json.start_time);
- _ref = json.data;
- for (i = _i = 0, _len = _ref.length; _i < _len; i = ++_i) {
- point = _ref[i];
- time = start_time + i * json.period_milliseconds;
- data[i] || (data[i] = {
- x: time
- });
- data[i][json.key] = point;
- }
- chart.options.ykeys.push(json.key);
- chart.options.labels.push(json.key);
- return chart.setData(data.slice(), redraw = true);
- });
- };
- })(this);
- getSeries(this.url);
- return el;
+ this.el.append(chartEl);
+ this.data = [];
+ this.chartOptions = {
+ element: chartEl,
+ series: [],
+ xkey: "x",
+ ykeys: [],
+ labels: [],
+ smooth: false,
+ data: this.data
+ };
+ if (options.key === 'change') {
+ this.chartOptions.postUnits = '%';
+ }
+ }
+
+ SubGraph.prototype.addSeries = function(json) {
+ var data, i, point, start_time, time, _i, _len, _ref;
+ data = this.data;
+ start_time = Date.parse(json.start_time);
+ _ref = json.data;
+ for (i = _i = 0, _len = _ref.length; _i < _len; i = ++_i) {
+ point = _ref[i];
+ time = start_time + i * json.period_milliseconds;
+ data[i] || (data[i] = {
+ x: time
+ });
+ data[i][json.uid] = point;
+ }
+ this.chartOptions.ykeys.push(json.uid);
+ this.chartOptions.labels.push(json.uid);
+ return this.el;
};
+ SubGraph.prototype["class"] = function() {
+ if (this.graphType === 'area') {
+ return Morris.Area;
+ } else {
+ return Morris.Line;
+ }
+ };
+
+ SubGraph.prototype.draw = function() {
+ return this.chart = new this["class"]()(this.chartOptions);
+ };
+
return SubGraph;
})();
Graph = (function() {
function Graph(options) {
+ this.getSubgraph = __bind(this.getSubgraph, this);
this.render = __bind(this.render, this);
this.url = options.url;
this.el = options.el;
this.$el = $(options.el);
+ console.log(this.$el);
}
Graph.prototype.render = function() {
$.getJSON(this.url, (function(_this) {
return function(json) {
- var el, extractor, index, subgraph, _i, _len, _ref, _results;
+ var extractor, index, _i, _len, _ref, _results;
_ref = json.extractors;
_results = [];
for (index = _i = 0, _len = _ref.length; _i < _len; index = ++_i) {
extractor = _ref[index];
- subgraph = new SubGraph({
- url: extractor.url
- });
- el = subgraph.render();
- _results.push(_this.$el.append(el));
+ _results.push($.get(extractor.url, function(line_json) {
+ var subgraph;
+ subgraph = _this.getSubgraph({
+ label: line_json.label,
+ key: line_json.key,
+ graphType: json.graph_type
+ });
+ subgraph.addSeries(line_json);
+ if (_this.$el.hasClass('dashboard')) {
+ if (subgraph.chartOptions.ykeys.length === json.extractors.length) {
+ return subgraph.draw();
+ }
+ } else {
+ return subgraph.draw();
+ }
+ }));
}
return _results;
};
})(this));
return this;
};
+ Graph.prototype.getSubgraph = function(options) {
+ var create;
+ create = (function(_this) {
+ return function(options) {
+ var subgraph;
+ subgraph = new SubGraph(options);
+ _this.$el.append(subgraph.el);
+ return subgraph;
+ };
+ })(this);
+ if (this.$el.hasClass('dashboard')) {
+ return this.subGraph || (this.subGraph = create(options));
+ } else {
+ return create($.extend(options, {
+ showTitle: true
+ }));
+ }
+ };
+
return Graph;
})();
this.Prosperity || (this.Prosperity = {});
@@ -130,7 +173,7 @@
return updateMetricOptions(el);
});
});
}).call(this);
-; TI"dependency_digest; TI"%9da377244b69e1a3bae3f921893d9072; FI"required_paths; T[I"c/Users/simon/Documents/rainforest/prosperity/app/assets/javascripts/prosperity/graph.js.coffee; FI"dependency_paths; T[{I" path; TI"c/Users/simon/Documents/rainforest/prosperity/app/assets/javascripts/prosperity/graph.js.coffee; FI"
-mtime; TI"2014-05-16T11:40:44-07:00; TI"digest; TI"%eb982557ca2b24dcb87cdb58b2d067ed; FI"
_version; TI"%2b66aa67c90052d553e0328c249bc9b0; F
+; TI"dependency_digest; TI"%a0521ce1dce2fe8c2c34f47d6fdb2cc5; FI"required_paths; T[I"c/Users/simon/Documents/rainforest/prosperity/app/assets/javascripts/prosperity/graph.js.coffee; FI"dependency_paths; T[{I" path; TI"c/Users/simon/Documents/rainforest/prosperity/app/assets/javascripts/prosperity/graph.js.coffee; FI"
+mtime; TI"2014-05-16T15:53:06-07:00; TI"digest; TI"%29586e08099c6d8566d8e573b25836c7; FI"
_version; TI"%2b66aa67c90052d553e0328c249bc9b0; F
\ No newline at end of file