app/js/lib/views/graph_view.coffee in ela-2.0.0 vs app/js/lib/views/graph_view.coffee in ela-3.0.0
- old
+ new
@@ -12,12 +12,14 @@
@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()
for axis, props of options.graph?.axes
@@ -25,11 +27,16 @@
attribute: props.attribute
position: switch axis
when 'x' then @bottomAxisHandler = attribute: props.attribute
when 'y' then @leftAxisHandler = attribute: props.attribute
- @curves = options.graph?.curves?.slice()
+ 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()
@@ -37,11 +44,13 @@
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
@@ -87,16 +96,16 @@
attribute: @leftAxisHandler.attribute
view = @subviews.graph ?= new @GraphView
model: @model
parentView: this
params: @displayParams
- defaults: _.defaults
+ defaults:
# Taken from ELA.Views.Canvas::readCanvasResolution
width: $graph[0].clientWidth
height: $graph[0].clientHeight
guides: guides
curves: @curves
- , @graphDefaults
+ axisLabelingForCurve: @axisLabelingForCurve
localePrefix: @localePrefix
$graph.html(view.render().el)
this