ELA.Views ?= {} class ELA.Views.GraphView extends ELA.Views.ViewportView initialize: (options = {}) -> unless options.name? throw 'ELA.Views.GraphView: option `name` is required' if options.graph?.view @GraphView = options.graph.view.toFunction() else @GraphView = ELA.Views.InterpolatedGraph @displayParams = @model.displayParams[options.name] = new @GraphView.Params unless options.legend is false if _.isObject(options.legend) and options.legend.view? @LegendView = options.legend.view.toFunction() @legendValueAttribute = options.legend.valueAttribute else @LegendView = ELA.Views.Legend @legendValueAttribute ?= options.graph?.axes?.x?.attribute if options.graphOverlay?.view? @GraphOverlayView = options.graphOverlay.view.toFunction() if options.graph?.axes?.x?.y? @xAxis = _.pick(options.graph.axes.x, 'y') if options.graph?.axes?.y?.x? @yAxis = _.pick(options.graph.axes.y, 'x') for axis, props of options.graph?.axes if props.handler switch axis when 'x' then @bottomAxisHandler = attribute: props.attribute when 'y' then @leftAxisHandler = attribute: props.attribute if options.graph?.curves? @curves = options.graph.curves.slice() @axisLabelingForCurve = @model.curves.find (curve) => curve.get('function') is @curves[0] else @axisLabelingForCurve = @model.curves.first() @subviews = {} render: => @$el.empty() if @LegendView? view = @subviews.legend ?= new @LegendView model: @model parentView: this localePrefix: @localePrefix valueAttribute: @legendValueAttribute curves: @curves displayParams: @displayParams @$el.append(view.render().el) if @GraphOverlayView? view = @subviews.graphOverlay ?= new @GraphOverlayView model: @model parentView: this localePrefix: @localePrefix @$el.append(view.render().el) $horizontalWrapper = $('