{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+`¹åRI" length;Ti-I" digest;TI"%9d88e38b16f118de5b593de4c27576f8;FI" source;TI"-(function() { var Graph, updateMetricOptions; Graph = (function() { function Graph(option) { this.url = option.url; this.el = option.el; this.$el = $(option.el); } Graph.prototype.render = function() { var chart, getSeries, highchartsOptions; highchartsOptions = { chart: { type: 'line', renderTo: this.el }, tooltip: { crosshairs: [true, true] }, series: [], xAxis: { type: 'datetime', dateTimeLabelFormats: { day: '%e of %b' } }, yAxis: [{}, {}, {}], title: { text: "Loading..." } }; chart = new Highcharts.Chart(highchartsOptions); getSeries = (function(_this) { return function(url, axisIndex) { return $.get(url, function(json) { var axisSettings, serie; axisIndex = Math.min(axisIndex, chart.yAxis.length - 1); serie = { data: json.data, name: json.label, yAxis: axisIndex, pointStart: Date.parse(json.start_time), pointInterval: json.period_milliseconds }; axisSettings = { title: { text: json.key }, min: Math.min.apply(Math, json.data), max: Math.max.apply(Math, json.data) }; if (json.key === 'change') { axisSettings = $.extend(axisSettings, { min: 0, max: Math.max.apply(Math, json.data), labels: { formatter: function() { return this.value + '%'; } }, opposite: true }); serie = $.extend(serie, { tooltip: { valueDecimals: 2, valueSuffix: '%' } }); } chart.yAxis[axisIndex].update(axisSettings); return chart.addSeries(serie); }); }; })(this); $.getJSON(this.url, function(json) { var extractor, index, _i, _len, _ref, _results; chart.setTitle({ text: json.title }); _ref = json.extractors; _results = []; for (index = _i = 0, _len = _ref.length; _i < _len; index = ++_i) { extractor = _ref[index]; _results.push(getSeries(extractor.url, index)); } return _results; }); return this; }; return Graph; })(); this.Prosperity || (this.Prosperity = {}); this.Prosperity.Graph = Graph; updateMetricOptions = function(el) { var $el, $form, $optionSelect, option, options, possibleOptions, selectedOption, _i, _len, _results; $el = $(el); if ($el.length === 0) { return; } $form = $el.parents('form'); options = $form.data('metric-options'); possibleOptions = options[$el.val()] || []; $optionSelect = $el.parents(".graph-line").find(".metric-option-select select"); selectedOption = $form.find("input[type=\"hidden\"][name=\"" + ($optionSelect.attr('name')) + "\"]").val(); $optionSelect.html(''); _results = []; for (_i = 0, _len = possibleOptions.length; _i < _len; _i++) { option = possibleOptions[_i]; _results.push($optionSelect.append($('