app/js/lib/views/legend.coffee in ela-1.1.0 vs app/js/lib/views/legend.coffee in ela-2.0.0

- old
+ new

@@ -1,7 +1,9 @@ ELA.Views ?= {} class ELA.Views.Legend extends Backbone.Poised.View + className: 'legend' + valueCurveColumnTemplate: _.template ' <div class="values col<%= activeClass %>" data-index="<%= curveIndex %>" style="color: <%= strokeColor %>; <%= borderStyle %>"> <div class="label"><%= label %></div> @@ -27,10 +29,11 @@ @render() @bindCalculatorEvents() @useValueAtRange = options.useValueAtRange @valueAtRangeAxis = options.valueAtRangeAxis or 'x' @valueAtRangeAttribute = options.valueAtRangeAttribute or 'valueAtRange' + @_curves = options.curves @model.on "change:#{@valueAtRangeAttribute}", @render events: 'click .values.col': 'selectCurveForAxisLabeling' @@ -113,26 +116,34 @@ # # @return [String] The identifier of the calculator function calculatorFunction: (curve) -> "#{curve.get('function')}_value" + curves: => + curves = @model.curves.whereInHistory() + if @_curves + _.filter curves, (curve) => + @_curves.indexOf(curve.get('function')) >= 0 + else + curves + render: => if @useValueAtRange @range = @model.get(@valueAtRangeAttribute) if @range? @labelingCurve = @model.get('axisLabelingForCurve') @calcs = @model.get('calculators') @$wrapper = $('<div class="values-at-range scroll-x">') @renderValueHeaderColumn() - _.each @model.curves.whereInHistory(), @renderValueCurveColumn + _.each(@curves(), @renderValueCurveColumn) # Replace keeping horizontal scroll position scrollLeft = @$el.find('.scroll-x').scrollLeft() @$el.html(@$wrapper) @$el.find('.scroll-x').scrollLeft(scrollLeft) this else @$el.empty().addClass('legend-simple') - _.each @model.curves.whereInHistory(), @renderSimpleCurveColumn + _.each(@curves(), @renderSimpleCurveColumn) this