(function() { var bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; }, extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; }, hasProp = {}.hasOwnProperty; if (ELA.Views == null) { ELA.Views = {}; } ELA.Views.GraphView = (function(superClass) { extend(GraphView, superClass); function GraphView() { this.render = bind(this.render, this); return GraphView.__super__.constructor.apply(this, arguments); } GraphView.prototype.initialize = function(options) { var axis, props, ref, ref1, ref2, ref3, ref4, ref5, ref6, ref7; if (options == null) { options = {}; } if (options.name == null) { throw 'ELA.Views.GraphView: option `name` is required'; } if ((ref = options.graph) != null ? ref.view : void 0) { this.GraphView = options.graph.view.toFunction(); } else { this.GraphView = ELA.Views.InterpolatedGraph; } this.displayParams = this.model.displayParams[options.name] = new this.GraphView.Params; if (options.legend !== false) { if (_.isObject(options.legend) && (options.legend.view != null)) { this.LegendView = options.legend.view.toFunction(); this.legendValueAttribute = options.legend.valueAttribute; } else { this.LegendView = ELA.Views.Legend; } if (this.legendValueAttribute == null) { this.legendValueAttribute = (ref1 = options.graph) != null ? (ref2 = ref1.axes) != null ? (ref3 = ref2.x) != null ? ref3.attribute : void 0 : void 0 : void 0; } } if (((ref4 = options.graphOverlay) != null ? ref4.view : void 0) != null) { this.GraphOverlayView = options.graphOverlay.view.toFunction(); } ref6 = (ref5 = options.graph) != null ? ref5.axes : void 0; for (axis in ref6) { props = ref6[axis]; if (props.handler) { ({ attribute: props.attribute, position: (function() { switch (axis) { case 'x': return this.bottomAxisHandler = { attribute: props.attribute }; case 'y': return this.leftAxisHandler = { attribute: props.attribute }; } }).call(this) }); } } if (((ref7 = options.graph) != null ? ref7.curves : void 0) != null) { this.curves = options.graph.curves.slice(); this.axisLabelingForCurve = this.model.curves.find((function(_this) { return function(curve) { return curve.get('function') === _this.curves[0]; }; })(this)); } else { this.axisLabelingForCurve = this.model.curves.first(); } return this.subviews = {}; }; GraphView.prototype.render = function() { var $horizontalWrapper, base, base1, base2, base3, view; this.$el.empty(); if (this.LegendView != null) { view = (base = this.subviews).legend != null ? base.legend : base.legend = new this.LegendView({ model: this.model, parentView: this, localePrefix: this.localePrefix, valueAttribute: this.legendValueAttribute, curves: this.curves, displayParams: this.displayParams }); this.$el.append(view.render().el); } if (this.GraphOverlayView != null) { view = (base1 = this.subviews).graphOverlay != null ? base1.graphOverlay : base1.graphOverlay = new this.GraphOverlayView({ model: this.model, parentView: this, localePrefix: this.localePrefix }); this.$el.append(view.render().el); } $horizontalWrapper = $('
', { "class": 'horizontal-wrapper' }); if (this.leftAxisHandler != null) { view = (base2 = this.subviews).leftAxisHandler != null ? base2.leftAxisHandler : base2.leftAxisHandler = new ELA.Views.AxisHandler({ model: this.model, displayParams: this.displayParams, attribute: this.leftAxisHandler.attribute, position: 'left', parentView: this, localePrefix: this.localePrefix }); $horizontalWrapper.append(view.render().el); } $horizontalWrapper.append($('
', { "class": 'graph' })); this.$el.append($horizontalWrapper); if (this.bottomAxisHandler != null) { view = (base3 = this.subviews).bottomAxisHandler != null ? base3.bottomAxisHandler : base3.bottomAxisHandler = new ELA.Views.AxisHandler({ model: this.model, displayParams: this.displayParams, attribute: this.bottomAxisHandler.attribute, position: 'bottom', parentView: this, localePrefix: this.localePrefix }); this.$el.append(view.render().el); } delay((function(_this) { return function() { var $graph, base4, guides; $graph = _this.$('.graph'); guides = []; if (_this.bottomAxisHandler != null) { guides.push({ orientation: 'vertical', attribute: _this.bottomAxisHandler.attribute }); } if (_this.leftAxisHandler != null) { guides.push({ orientation: 'horizontal', attribute: _this.leftAxisHandler.attribute }); } view = (base4 = _this.subviews).graph != null ? base4.graph : base4.graph = new _this.GraphView({ model: _this.model, parentView: _this, params: _this.displayParams, defaults: { width: $graph[0].clientWidth, height: $graph[0].clientHeight, guides: guides, curves: _this.curves, axisLabelingForCurve: _this.axisLabelingForCurve }, localePrefix: _this.localePrefix }); if (_this.leftAxisHandler != null) { view.$el.on('tap', _this.subviews.leftAxisHandler.updateValue); } if (_this.bottomAxisHandler != null) { view.$el.on('tap', _this.subviews.bottomAxisHandler.updateValue); } return $graph.html(view.render().el); }; })(this)); return this; }; return GraphView; })(ELA.Views.ViewportView); }).call(this);